Skip to content

Commit

Permalink
ARN-2494 Switch to GitHub Actions (#855)
Browse files Browse the repository at this point in the history
* ARN-2494 Switch to GitHub Actions

* ARN-2494 Rename public to dist

* ARN-2494 Remove redundant cypress reporters

* ARN-2494 Add container index to artifact name

* ARN-2494 Add cypress-on-fix plugin

* ARN-2494 Update base snapshots for visual regression tests

* ARN-2494 Try waiting longer for the PDF to render

* ARN-2494 Try waiting even longer for the PDF to render

* ARN-2494 Try waiting forever for the PDF to render

* ARN-2494 Try waiting forever and one for the PDF to render

* ARN-2494 Try running tests in Chrome

* ARN-2494 Update base snapshots (Chrome)

* ARN-2494 Try waiting for PDF in Chrome

* ARN-2494 Comment out PDF visual regression test
  • Loading branch information
devkokov authored Mar 6, 2025
1 parent 66fb771 commit c8d6d4b
Show file tree
Hide file tree
Showing 48 changed files with 572 additions and 1,251 deletions.
252 changes: 0 additions & 252 deletions .circleci/config.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
* @ministryofjustice/hmpps-assessments
25 changes: 25 additions & 0 deletions .github/workflows/deploy_to_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy to environment

on:
workflow_dispatch:
inputs:
environment:
description: Environment
type: choice
required: true
options:
- dev
default: 'dev'
image_tag:
description: Optional image tag to deploy. If left blank, a new image will be built, pushed and deployed
required: false
default: ''
type: string

jobs:
deploy_to_env:
uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/workflows/deploy_to_env.yml@v1
secrets: inherit
with:
environment: ${{ inputs.environment }}
image_tag: ${{ inputs.image_tag }}
109 changes: 109 additions & 0 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Run end-to-end tests

on:
workflow_call:
inputs:
spec-file-patterns:
type: string
default: 'integration_tests/integration/features/**/*.feature'
app_version:
description: App version
required: true
type: string

jobs:
get-timings:
uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/workflows/cypress_get_timings.yml@v1
with:
spec-file-patterns: ${{ inputs.spec-file-patterns }}

e2e-test:
runs-on: ubuntu-latest
needs: get-timings
env:
UI_IMAGE_TAG: ${{ inputs.app_version }}
strategy:
fail-fast: false
matrix:
container: [ 1, 2 ]
outputs:
timings-1: ${{ steps.timings.outputs.t1 }}
timings-2: ${{ steps.timings.outputs.t2 }}
steps:
- uses: actions/checkout@v4

- name: Download docker image
uses: actions/download-artifact@v4
with:
name: build_image
path: ${{ runner.temp }}

- name: Load image
run: docker load --input ${{ runner.temp }}/build_image.tar

- name: restore cache
id: restore-cache
uses: actions/cache/restore@v4
env:
cache-name: node-modules
with:
path: |
./node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/actions/cypress/create_timings_file@v1
with:
timings: ${{ needs.get-timings.outputs.timings }}

- name: Stand up a test environment
run: make up

- name: Clear the visual regression diffs directory
run: rm -rf integration_tests/snapshots/diff

- name: Run the end-to-end tests
uses: cypress-io/github-action@v6
with:
publish-summary: false
browser: chrome
env:
SPEC: ${{ inputs.spec-file-patterns }}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
SPLIT_FILE: 'timings.json'

- name: Check for visual regression diffs
run: if test -d integration_tests/snapshots/diff; then exit 1; fi

- name: Output updated timings
if: success() || failure()
id: timings
run: |
cat timings.json
echo "t${{ matrix.container }}=$(jq -c . < timings.json)" >> $GITHUB_OUTPUT
- name: Export container logs
if: failure()
run: make save-logs OUTPUT_LOGS_DIR=${{ runner.temp }}/docker-logs

- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: e2e_test_results_${{ matrix.container }}
path: |
test_results
integration_tests/screenshots
integration_tests/snapshots/diff
${{ runner.temp }}/docker-logs
save-timings:
uses: ministryofjustice/hmpps-assess-risks-and-needs-github-actions/.github/workflows/cypress_save_timings.yml@v1
if: success() || failure()
needs:
- get-timings
- e2e-test
with:
initial-timings: ${{ needs.get-timings.outputs.timings }}
updated-timings: ${{ toJSON(needs.e2e-test.outputs) }}
Loading

0 comments on commit c8d6d4b

Please sign in to comment.