From c3f6d0c83f9a4799883e765605b8ded28d929b0f Mon Sep 17 00:00:00 2001 From: jamesrwarren Date: Tue, 22 Oct 2024 14:11:39 +0100 Subject: [PATCH] DDLS-376 add very basic smoke test --- .github/workflows/_smoke.yml | 27 +++++++++++++++++++ .github/workflows/workflow_path_to_live.yml | 13 +++++++-- .../workflows/workflow_pull_request_path.yml | 13 ++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/_smoke.yml diff --git a/.github/workflows/_smoke.yml b/.github/workflows/_smoke.yml new file mode 100644 index 0000000..ce37d63 --- /dev/null +++ b/.github/workflows/_smoke.yml @@ -0,0 +1,27 @@ +name: "[Smoke] Check Web Site Is Functional" + +defaults: + run: + shell: bash + +on: + workflow_call: + inputs: + url: + description: "URL to run the smoke test against" + required: true + type: string + +jobs: + smoke: + runs-on: ubuntu-latest + steps: + - name: check site availability + id: smoke + env: + URL: ${{ inputs.url }} + run: | + curl -o /dev/null -s -w "%{http_code}" ${URL} | grep -q 200 || exit 1 + + + diff --git a/.github/workflows/workflow_path_to_live.yml b/.github/workflows/workflow_path_to_live.yml index 2f7181d..6a73c58 100644 --- a/.github/workflows/workflow_path_to_live.yml +++ b/.github/workflows/workflow_path_to_live.yml @@ -51,7 +51,6 @@ jobs: branch_name: ${{ needs.workflow_variables.outputs.parsed_branch }} deploy_to_production_environment: - if: ${{ github.actor != 'dependabot[bot]' }} name: Deploy to Production Environment needs: [ workflow_variables, @@ -64,10 +63,20 @@ jobs: account_name: production apply: true + smoke_test: + name: Check Website Availability + needs: [ + workflow_variables, + deploy_to_production_environment + ] + uses: ./.github/workflows/_smoke.yml + with: + url: https://incident.opg.service.justice.gov.uk/ht/ + end_of_pr_workflow: name: End of PR Workflow runs-on: ubuntu-latest - needs: [workflow_variables,deploy_to_production_environment] + needs: [workflow_variables,smoke_test] steps: - name: End of PR Workflow run: echo "${{ needs.workflow_variables.outputs.version_tag }} tested, built and deployed to Production" diff --git a/.github/workflows/workflow_pull_request_path.yml b/.github/workflows/workflow_pull_request_path.yml index dfec94c..3952576 100644 --- a/.github/workflows/workflow_pull_request_path.yml +++ b/.github/workflows/workflow_pull_request_path.yml @@ -68,10 +68,21 @@ jobs: account_name: development apply: true + smoke_test: + if: ${{ github.actor != 'dependabot[bot]' }} + name: Check Website Availability + needs: [ + workflow_variables, + deploy_to_development_environment + ] + uses: ./.github/workflows/_smoke.yml + with: + url: https://dev.incident.opg.service.justice.gov.uk/ht/ + end_of_pr_workflow: name: End of PR Workflow runs-on: ubuntu-latest - needs: [workflow_variables,deploy_to_development_environment] + needs: [workflow_variables,smoke_test] steps: - name: End of PR Workflow run: echo "${{ needs.workflow_variables.outputs.version_tag }} tested, built and deployed to Development"