Skip to content

5.16.0

5.16.0 #3045

Workflow file for this run

name: CI Regression
on:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
pr_labels: ${{ steps.pr.outputs.labels }}
# If there is no label then steps.run_regression.outputs.value will be "false" which
# being a string is actually considered true, so fromJSON is needed to turn `"false"` into `false`.
# If we are on the 'master' branch then run the regression tests regardless of the PR label
run_regression: ${{ fromJSON(steps.run_regression.outputs.value) || github.ref_name == 'master' }}
permissions:
pull-requests: read
steps:
- name: Get PR labels
id: pr
# the github.event.pull_request.labels is not available when a build
# is triggered by a push. So we use the `gh` CLI to get info about the PR for the
# current branch.
# - If the branch doesn't have a PR yet, then the `gh pr view` command fails with
# the message: no pull requests found for branch "pr-label-test"
# - If the same branch is part of multiple PRs, it isn't clear what will
# happen, but that should be very unusual.
run: echo "labels=$(gh pr view ${{ github.ref_name }} --json labels -q '.labels' || echo "[]")" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# set repository so we don't have to check out all of the code
GH_REPO: ${{github.repository}}
- name: Print PR labels
run: echo "PR labels ${{ steps.pr.outputs.labels }}"
- name: Get run_regression
id: run_regression
run: echo "value=${{ contains(fromJSON(steps.pr.outputs.labels).*.name, 'run regression') }}" >> $GITHUB_OUTPUT
regression:
needs: ['prepare']
# only run the regression tests if the PR is labeled.
if: fromJSON(needs.prepare.outputs.run_regression)
runs-on: ubuntu-latest
timeout-minutes: 60
# If we run out cypress test runs then we temporarily expand the timeout to 4hrs until cypress cloud is available
# again
# timeout-minutes: 240
container:
image: cypress/browsers:node-20.11.0-chrome-121.0.6167.184-1-ff-123.0-edge-121.0.2277.128-1
# This is needed so the commit info can be recorded by cypress
options: --user 1001
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
container: [1, 2, 3, 4, 5]
# If we run out cypress test runs then we temporarily use only 1 worker because without cypress cloude
# there is no parallelization
# containers: [1]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install CMS Dependencies
working-directory: ./cms
run: npm ci
- uses: cypress-io/github-action@v4
with:
start: npm start
wait-on: 'http://localhost:8080'
# wait 10 minutes to start the addition of the CMS required this increase
wait-on-timeout: 600
# only record the results to dashboard.cypress.io if CYPRESS_RECORD_KEY is set
record: ${{ !!secrets.CYPRESS_RECORD_KEY }}
# only do parallel if we have a record key
parallel: ${{ !!secrets.CYPRESS_RECORD_KEY }}
browser: chrome
spec: cypress/e2e/functional/**
group: 'Regression tests'
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# turn on code coverage when running npm start
# so far we've been using a webpack coverage-istanbul-loader for this
# but there has been work on using the code coverage support in the browser directly,
# which should be much faster
CODE_COVERAGE: true
# Also turn on the code coverage tasks in cypress itself, these are disabled
# by default.
CYPRESS_coverage: true
# Increase memory allocation
NODE_OPTIONS: "--max_old_space_size=4096"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
flags: cypress-regression
token: ${{ secrets.CODECOV_TOKEN }}
notify-slack:
if: ${{ failure() && github.ref_name == 'master' }}
needs: [regression]
runs-on: ubuntu-latest
steps:
- name: Notify Slack the tests failed
id: slack
uses: slackapi/[email protected]
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"ref_name": "${{ github.ref_name }}",
"workflow": "${{ github.workflow }}",
"run_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}