Skip to content

Commit

Permalink
Add GH action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosestito committed Apr 19, 2023
1 parent 8c58164 commit 36beb6a
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# This workflow requires the following secrets:
# `SSH_PUBLIC_KEY`, `SSH_PRIVATE_KEY` ssh keys to access the e2e machines
# `AWS_SECRET_ACCESS_KEY`, `AWS_ACCESS_KEY_ID` aws credentials,
# used by terraform to deploy the infrastructure.
#
# An artifact containing the terraform state is uploaded in case something goes wrong,
# so it's easy to destroy the infrastructure.

name: e2e tests

on:
workflow_dispatch:

jobs:
e2e_tests:
name: Deploy e2e infrastructure
runs-on: ubuntu-latest
env:
TF_VAR_aws_region: 'eu-central-1'
TF_VAR_aws_secret_key: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
TF_VAR_aws_access_key_id: '${{ secrets.AWS_ACCESS_KEY_ID }}'
TF_VAR_public_key: '${{ secrets.SSH_PUBLIC_KEY }}'
TF_VAR_hana_instancetype: 'r6i.xlarge'
TF_VAR_hana_image_ids: '["ami-073792bfce1223304", "ami-0c3df2b35c3b0ec6f"]'
TF_VAR_trento_server_image_id: 'ami-073792bfce1223304'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Cache dependencies
id: node-modules-cache
uses: actions/cache@v3
with:
path: test/e2e/node_modules
key: node-modules-${{ hashFiles('test/e2e/package-lock.json') }}
- name: Install E2E NPM dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
working-directory: test/e2e
run: npm install
- name: Checkout terraform repo
uses: actions/checkout@v3
with:
repository: fabriziosestito/trento-e2e
path: terraform
- name: Use branch workspace
uses: dflook/terraform-new-workspace@v1
with:
path: terraform/deployments/aws
workspace: 'trentoe2e'
# workspace: ${{ github.head_ref }}
- name: Deploy test infrastructure
uses: dflook/terraform-apply@v1
continue-on-error: true
with:
path: terraform/deployments/aws
workspace: 'trentoe2e'
# workspace: ${{ github.head_ref }}
auto_approve: true
- name: Upload tfstate
uses: actions/upload-artifact@v3
if: ${{ !env.ACT }}
with:
name: terraform-state
path: terraform/deployments/aws/terraform.tfstate.d
- name: Get outputs
uses: dflook/terraform-output@v1
id: tf-outputs
with:
path: terraform/deployments/aws
workspace: 'trentoe2e'
# workspace: ${{ github.head_ref }}
- name: Checkout ansible repo
uses: actions/checkout@v3
with:
repository: CDimonaco/trento-ansible
path: ansible
- name: Add pipx_bin to path
if: ${{ env.ACT }}
run: echo '/opt/pipx_bin' >> $GITHUB_PATH
- name: Install galaxy deps
run: ansible-galaxy install -r ansible/requirements.yml
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
continue-on-error: true
with:
playbook: ansible/playbook.yml
key: ${{ secrets.SSH_PRIVATE_KEY }}
inventory: |
all:
vars:
ansible_user: ec2-user
children:
trento-server:
hosts:
server:
ansible_host: ${{ steps.tf-outputs.outputs.trento_server_public_ip }}
agents:
hosts:
hana01:
ansible_host: ${{ fromJson(steps.tf-outputs.outputs.hana_public_ip)[0] }}
hana02:
ansible_host: ${{ fromJson(steps.tf-outputs.outputs.hana_public_ip)[1] }}
options: |
--extra-vars "web_postgres_password='pass' \
wanda_postgres_password='wanda' \
rabbitmq_password='trento' \
grafana_api_url='http://localhost' \
prometheus_url='http://localhost' \
web_admin_password='adminpassword' \
enable_api_key='false' \
trento_server_name='trento' \
trento_server_url='http://${{ steps.tf-outputs.outputs.trento_server_ip }}' \
rabbitmq_host='${{ steps.tf-outputs.outputs.trento_server_ip }}:5672' \
api_key='api-key'"
- name: Cypress run
uses: cypress-io/github-action@v5
env:
CYPRESS_BASE_URL: http://${{ steps.tf-outputs.outputs.trento_server_public_ip }}
CYPRESS_REAL_CLUSTER_TESTS: true
continue-on-error: true
with:
working-directory: test/e2e
spec: cypress/e2e/hana_scale_up_checks.cy.js
headless: true
- name: Destroy
uses: dflook/terraform-destroy-workspace@v1
continue-on-error: true
with:
path: terraform/deployments/aws
workspace: 'trentoe2e'
- name: Install aws-delete-vpc
uses: jaxxstorm/[email protected]
with:
repo: isovalent/aws-delete-vpc
cache: enable
- name: Destroy VPC
env:
AWS_REGION: 'eu-central-1'
AWS_SECRET_ACCESS_KEY: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
AWS_ACCESS_KEY_ID: '${{ secrets.AWS_ACCESS_KEY_ID }}'
run: aws-delete-vpc --vpc-id ${{ steps.tf-outputs.outputs.vpc_id }}

0 comments on commit 36beb6a

Please sign in to comment.