From bc0d6bd32f8e5c75535052bc58bf624a5a86cb96 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro <39738771+bernardobridge@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:10:46 +0000 Subject: [PATCH] ci: add tests on deploy to prod and pr (#2) * ci: add tests on deploy to prod and pr * fix: remove mask preventing service_url from showing * fix: trailing space in service url --- .github/workflows/deploy-prod.yaml | 19 ++++++++++++++++--- .github/workflows/pull_request.yaml | 19 +++++++++++++++++-- .github/workflows/serverless-deploy.yaml | 3 +-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index d5712f6..92eb357 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -3,8 +3,8 @@ name: Deploy to prod on: workflow_dispatch: schedule: - # every monday at 6:00 AM UTC - - cron: '0 6 * * 1' + # every 2 hours + - cron: '0 */2 * * *' jobs: deploy-prod: @@ -16,4 +16,17 @@ jobs: AWS_DEPLOYER_ROLE: ${{ secrets.AWS_DEPLOYER_ROLE }} DD_API_KEY: ${{ secrets.DD_API_KEY }} with: - ENVIRONMENT: prod \ No newline at end of file + ENVIRONMENT: prod + + run-perf-smoke: + uses: ./.github/workflows/run-performance-test.yaml + permissions: + id-token: write + contents: read + secrets: + DD_API_KEY: ${{ secrets.DD_API_KEY }} + ARTILLERY_CLOUD_API_KEY: ${{ secrets.ARTILLERY_CLOUD_API_KEY }} + with: + ENVIRONMENT: prod + TEST_TYPE: smoke + VERSION: ${{ github.sha }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 878e0df..f4a86ec 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -26,7 +26,7 @@ jobs: AWS_DEPLOYER_ROLE: ${{ secrets.AWS_DEPLOYER_ROLE }} DD_API_KEY: ${{ secrets.DD_API_KEY }} with: - ENVIRONMENT: ${{ github.actor }}-${{ github.event.pull_request.number }} + ENVIRONMENT: ${{ github.actor }}-${{ github.event.pull_request.number || github.run_id }} SHOULD_SEED_DB: true run-functional-tests: @@ -37,10 +37,25 @@ jobs: run: echo "Running functional tests against ${{ needs.deploy-ephemeral.outputs.SERVICE_URL }}" env: SERVICE_URL: ${{ needs.deploy-ephemeral.outputs.SERVICE_URL }} + + run-perf-regression: + uses: ./.github/workflows/run-performance-test.yaml + needs: [deploy-ephemeral, run-functional-tests] + permissions: + id-token: write + contents: read + secrets: + DD_API_KEY: ${{ secrets.DD_API_KEY }} + ARTILLERY_CLOUD_API_KEY: ${{ secrets.ARTILLERY_CLOUD_API_KEY }} + with: + ENVIRONMENT: custom + TEST_TYPE: regression + VERSION: ${{ github.sha }} + SERVICE_URL: ${{ needs.deploy-ephemeral.outputs.SERVICE_URL }} teardown-ephemeral-env: uses: ./.github/workflows/stack-delete.yaml - needs: run-functional-tests + needs: run-perf-regression permissions: id-token: write contents: read diff --git a/.github/workflows/serverless-deploy.yaml b/.github/workflows/serverless-deploy.yaml index be7e864..10e2f56 100644 --- a/.github/workflows/serverless-deploy.yaml +++ b/.github/workflows/serverless-deploy.yaml @@ -73,8 +73,7 @@ jobs: - id: set_service_url name: Generate, mask, and output a secret run: | - SERVICE_URL="$(npx serverless info --stage ${{ inputs.ENVIRONMENT }} --verbose | grep ServiceEndpoint | sed s/ServiceEndpoint\:\ //g)" - echo "::add-mask::$SERVICE_URL" + SERVICE_URL="$(npx serverless info --stage ${{ inputs.ENVIRONMENT }} --verbose 2>&1 | grep -i 'ServiceEndpoint:' | sed -e 's/[[:space:]]*ServiceEndpoint:[[:space:]]*//I' | head -n 1)" echo "SERVICE_URL=$SERVICE_URL" >> "$GITHUB_OUTPUT" - name: Send Datadog Deployment Event if: success()