From 6f67df1a38d25286e322d939c723c88e6e38ae21 Mon Sep 17 00:00:00 2001 From: RMcVelia Date: Mon, 30 Oct 2023 12:03:25 +0000 Subject: [PATCH 1/2] Fix production_aks healthcheck url --- .github/workflows/actions/deploy_v2/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/actions/deploy_v2/action.yml b/.github/workflows/actions/deploy_v2/action.yml index 68e8943fab..6b60231c9f 100644 --- a/.github/workflows/actions/deploy_v2/action.yml +++ b/.github/workflows/actions/deploy_v2/action.yml @@ -53,6 +53,8 @@ runs: pr_name="${{env.REVIEW_APPLICATION}}-${{inputs.pr}}" echo "pr_name=${pr_name}" >> $GITHUB_OUTPUT echo "healthcheck=${pr_name}${cluster_domain}" >> $GITHUB_OUTPUT + elif [ "${{inputs.environment }}" == "production_aks" ] + echo "healthcheck=${{env.AKS_APPLICATION_NAME}}-${appenv}" >> $GITHUB_OUTPUT else echo "healthcheck=${{env.AKS_APPLICATION_NAME}}-${appenv}${cluster_domain}" >> $GITHUB_OUTPUT fi From 7dbafb2d504f890ddf477811b742ec4c71524fb0 Mon Sep 17 00:00:00 2001 From: RMcVelia Date: Mon, 30 Oct 2023 12:04:20 +0000 Subject: [PATCH 2/2] Migrate test env to aks --- .../workflows/actions/deploy_v2/action.yml | 15 ++- .github/workflows/build.yml | 119 ++---------------- config/environments/test.rb | 2 +- 3 files changed, 20 insertions(+), 116 deletions(-) diff --git a/.github/workflows/actions/deploy_v2/action.yml b/.github/workflows/actions/deploy_v2/action.yml index 6b60231c9f..51ab068540 100644 --- a/.github/workflows/actions/deploy_v2/action.yml +++ b/.github/workflows/actions/deploy_v2/action.yml @@ -48,16 +48,19 @@ runs: cluster_domain=".${cluster}" echo "TERRAFORM_VERSION=$terraform_version" >> $GITHUB_ENV - if [ "${{inputs.environment }}" == "review_aks" ] - then + case ${{ inputs.environment }} in + review_aks) pr_name="${{env.REVIEW_APPLICATION}}-${{inputs.pr}}" echo "pr_name=${pr_name}" >> $GITHUB_OUTPUT echo "healthcheck=${pr_name}${cluster_domain}" >> $GITHUB_OUTPUT - elif [ "${{inputs.environment }}" == "production_aks" ] - echo "healthcheck=${{env.AKS_APPLICATION_NAME}}-${appenv}" >> $GITHUB_OUTPUT - else + ;; + production_aks) + echo "healthcheck=${{env.AKS_APPLICATION_NAME}}-${appenv}" >> $GITHUB_OUTPUT + ;; + *) echo "healthcheck=${{env.AKS_APPLICATION_NAME}}-${appenv}${cluster_domain}" >> $GITHUB_OUTPUT - fi + ;; + esac - name: Fetch secrets from key vault uses: azure/CLI@v1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e98f51edc..a282a89dbf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -601,57 +601,11 @@ jobs: ARM_ACCESS_KEY: ${{ secrets.ARM_ACCESS_KEY }} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - qa: - name: Quality Assurance Deployment - needs: [ feature_tests, javascript_tests, build_release ] - if: github.ref == 'refs/heads/master' - concurrency: QA - runs-on: ubuntu-latest - environment: - name: Test - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: set-up-environment - uses: DFE-Digital/github-actions/set-up-environment@master - - - uses: Azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - uses: DfE-Digital/keyvault-yaml-secret@v1 - id: keyvault-yaml-secret - with: - keyvault: ${{ secrets.KEY_VAULT}} - secret: INFRA-KEYS - key: SLACK-WEBHOOK - - - name: Deploy to Test - uses: ./.github/workflows/actions/deploy - id: deploy - with: - environment: Test - sha: ${{ github.sha }} - AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} - KEY_VAULT: ${{ secrets.KEY_VAULT }} - ARM_ACCESS_KEY: ${{ secrets.ARM_ACCESS_KEY }} - - - name: Slack Notification - if: failure() - uses: rtCamp/action-slack-notify@master - env: - SLACK_COLOR: ${{env.SLACK_ERROR}} - SLACK_TITLE: Failure in Post-Development Deploy - SLACK_MESSAGE: Failure with initialising QA deployment for ${{env.APPLICATION}} - SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK-WEBHOOK }} - test_aks: name: Test AKS Deployment needs: [ feature_tests, javascript_tests, build_release ] if: github.ref == 'refs/heads/master' concurrency: test_aks - continue-on-error: true runs-on: ubuntu-latest environment: name: test_aks @@ -696,57 +650,6 @@ jobs: SLACK_MESSAGE: Failure with initialising AKS Test deployment for ${{env.APPLICATION}} SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK-WEBHOOK }} - integration: - name: Run Integration Tests on QA - runs-on: ubuntu-latest - needs: [ build_base, qa ] - services: - postgres: - image: postgres:13.10 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - env: - DOCKER_IMAGE_TEST: ${{needs.build_base.outputs.DOCKER_IMAGE_TEST}} - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: set-up-environment - uses: DFE-Digital/github-actions/set-up-environment@master - - - uses: Azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - uses: DfE-Digital/keyvault-yaml-secret@v1 - id: keyvault-yaml-secret - with: - keyvault: ${{ secrets.KEY_VAULT}} - secret: INFRA-KEYS - key: HTTP-USERNAME, HTTP-PASSWORD, MAILSAC-API-KEY - - - name: Prepare DB - run: |- - docker run --net=host -t --rm -e RAILS_ENV=test -e DATABASE_URL="postgresql://postgres:postgres@localhost" ${{ env.DOCKER_IMAGE_TEST }} \ - bundle exec rails db:prepare - - - name: Run Integration Tests - run: |- - docker run --net=host -t --rm -e RAILS_ENV=test -e NODE_ENV=test -e CI=true -e HTTP_USERNAME -e HTTP_PASSWORD -e MAILSAC_API_KEY -e DATABASE_URL="postgresql://postgres:postgres@localhost" \ - ${{env.DOCKER_IMAGE_TEST}} bundle exec rspec --tag integration - env: - HTTP_USERNAME: ${{ steps.keyvault-yaml-secret.outputs.HTTP-USERNAME }} - HTTP_PASSWORD: ${{ steps.keyvault-yaml-secret.outputs.HTTP-PASSWORD }} - MAILSAC_API_KEY: ${{ steps.keyvault-yaml-secret.outputs.MAILSAC-API-KEY }} - integration_aks: name: Run Integration Tests on AKS test runs-on: ubuntu-latest @@ -801,21 +704,19 @@ jobs: docker run --net=host -t --rm -e RAILS_ENV=test -e DATABASE_URL="postgresql://postgres:postgres@localhost" ${{ env.DOCKER_IMAGE_TEST }} \ bundle exec rails db:prepare - # Uncomment this step when test is migrated to AKS - # as need to update config.x.integration_host in config/environments/test.rb - # - name: Run Integration Tests - # run: |- - # docker run --net=host -t --rm -e RAILS_ENV=test -e NODE_ENV=test -e CI=true -e HTTP_USERNAME -e HTTP_PASSWORD -e MAILSAC_API_KEY -e DATABASE_URL="postgresql://postgres:postgres@localhost" \ - # ${{env.DOCKER_IMAGE_TEST}} bundle exec rspec --tag integration - # env: - # HTTP_USERNAME: ${{ steps.keyvault-yaml-secret.outputs.HTTP_USERNAME }} - # HTTP_PASSWORD: ${{ steps.keyvault-yaml-secret.outputs.HTTP_PASSWORD }} - # MAILSAC_API_KEY: ${{ steps.keyvault-yaml-secret.outputs.MAILSAC_API_KEY }} + - name: Run Integration Tests + run: |- + docker run --net=host -t --rm -e RAILS_ENV=test -e NODE_ENV=test -e CI=true -e HTTP_USERNAME -e HTTP_PASSWORD -e MAILSAC_API_KEY -e DATABASE_URL="postgresql://postgres:postgres@localhost" \ + ${{env.DOCKER_IMAGE_TEST}} bundle exec rspec --tag integration + env: + HTTP_USERNAME: ${{ steps.keyvault-yaml-secret.outputs.HTTP_USERNAME }} + HTTP_PASSWORD: ${{ steps.keyvault-yaml-secret.outputs.HTTP_PASSWORD }} + MAILSAC_API_KEY: ${{ steps.keyvault-yaml-secret.outputs.MAILSAC_API_KEY }} production: name: Production Deployment runs-on: ubuntu-latest - needs: [ integration, development_aks ] + needs: [ integration_aks, development_aks ] concurrency: Production environment: name: Production @@ -884,7 +785,7 @@ jobs: production_aks: name: Production AKS Deployment runs-on: ubuntu-latest - needs: [ integration, development_aks ] + needs: [ integration_aks, development_aks ] concurrency: production_aks continue-on-error: true environment: diff --git a/config/environments/test.rb b/config/environments/test.rb index 4c96b9a213..e76cea1cf6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -51,7 +51,7 @@ "beta-getintoteaching.education.gov.uk" => "getintoteaching.education.gov.uk", } - config.x.integration_host = "get-into-teaching-app-test.london.cloudapps.digital" + config.x.integration_host = "get-into-teaching-app-test.test.teacherservices.cloud" config.x.integration_credentials = { username: ENV["HTTP_USERNAME"], password: ENV["HTTP_PASSWORD"] } config.x.mailsac_api_key = ENV["MAILSAC_API_KEY"] config.x.dfe_analytics = true