From 28134e7a015a5a94fb2c4a50a87013ffc69c9283 Mon Sep 17 00:00:00 2001 From: Sean Fern Date: Fri, 30 Aug 2024 22:52:55 -0400 Subject: [PATCH] Add environment input to e2e-test workflow --- .github/workflows/e2e-test.yml | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 285e476cd..53fccee85 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -1,13 +1,30 @@ name: end-to-end tests on: - pull_request: workflow_call: + inputs: + environment: + required: true + type: choice + options: + - dev + - test + - sbx + default: test workflow_dispatch: # Allow manual trigger + inputs: + environment: + required: true + type: choice + options: + - dev + - test + - sbx + default: test -# Ensure we have only one e2e test running at a time +# Ensure we have only one e2e test running at a time in each environment concurrency: - group: e2e-test + group: ${{ inputs.environment }}-e2e-test jobs: test: @@ -39,7 +56,7 @@ jobs: sudo rm -rf /opt/maven sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven - - name: Set env vars from AWS params in management account + - name: Set env vars from AWS params in BCDA management account uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main env: AWS_REGION: ${{ vars.AWS_REGION }} @@ -49,13 +66,13 @@ jobs: ARTIFACTORY_USER=/artifactory/user ARTIFACTORY_PASSWORD=/artifactory/password - - name: Assume role in AB2D impl account + - name: Assume role in AB2D account for this environment uses: aws-actions/configure-aws-credentials@v3 with: aws-region: ${{ vars.AWS_REGION }} - role-to-assume: arn:aws:iam::${{ secrets.IMPL_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions + role-to-assume: arn:aws:iam::${{ secrets[format('{0}_ACCOUNT_ID', inputs.environment)] }}:role/delegatedadmin/developer/ab2d-${{ inputs.environment }}-github-actions - - name: Set env vars from AWS params in impl account + - name: Set env vars from AWS params in AB2D account uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main env: AWS_REGION: ${{ vars.AWS_REGION }} @@ -70,7 +87,8 @@ jobs: - name: Create opt/ab2d directory and download keystore run: | mkdir -p opt/ab2d - aws s3 cp s3://ab2d-east-impl-main/ab2d_imp_keystore $AB2D_BFD_KEYSTORE_LOCATION + KEYSTORE_FILE_NAME="ab2d_${{ inputs.environment == "test" && "imp" || inputs.environment }}_keystore" + aws s3 cp s3://${{ vars[format('{0}_DEPLOYMENT_ENV', inputs.environment)] }}-main/$KEYSTORE_FILE_NAME $AB2D_BFD_KEYSTORE_LOCATION test -f $AB2D_BFD_KEYSTORE_LOCATION && echo "created keystore file" - name: Run e2e-bfd-test @@ -79,6 +97,6 @@ jobs: - name: Run e2e-test env: - E2E_ENVIRONMENT: 'IMPL' + E2E_ENVIRONMENT: ${{ fromJson('{ "dev": "DEV", "test": "IMPL", "prod": "PROD" }')[inputs.environment] }} run: | mvn test -s settings.xml -pl e2e-test -am -Dtest=TestRunner -DfailIfNoTests=false -Dusername=$ARTIFACTORY_USER -Dpassword=$ARTIFACTORY_PASSWORD -Drepository_url=$ARTIFACTORY_URL --no-transfer-progress