Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARN-2494 Switch to GitHub Actions #855

Merged
merged 14 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading