Skip to content

address PR comments #460

address PR comments

address PR comments #460

Workflow file for this run

# If this name is changed we also need to change it in run-regression-label.yml
name: CI v3 Regression
on:
push:
paths: # only run this workflow if it contains v3 files
- 'v3/**' # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-including-paths
- '.github/workflows/v3-regression.yml'
- '.github/workflows/v3.yml'
- '.github/workflows/run-regression-label.yml'
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 'main' branch then run the regression tests regardless of the PR label
run_regression: ${{ fromJSON(steps.run_regression.outputs.value) || github.ref_name == 'main' }}
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
cypress:
needs: ['prepare']
# only run the regression tests if the PR is labeled.
if: fromJSON(needs.prepare.outputs.run_regression)
runs-on: ubuntu-latest
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:
# run multiple copies of the current job in parallel [1, ..., n]
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
- name: Checkout
uses: actions/checkout@v4
- name: Restore Webpack Cache
# Don't save the webpack cache because the same cache wil be saved
# by the cypress job in `v3.yml`
uses: actions/cache/restore@v4
with:
path: v3/.cache/webpack/
key: webpack-dev-build-${{ hashFiles('v3/webpack.config.js') }}
- uses: cypress-io/github-action@v6
with:
working-directory: v3
start: npm start
wait-on: 'http://localhost:8080'
# add timeout of 5 minutes to start
wait-on-timeout: 300
# 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
# TODO: this currently will re-run the smoke test, once we have a dedicated smoke
# test that should be excluded
# spec: cypress/e2e/**
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
# Have webpack skip eslint checking, that was already done by the build step
SKIP_ESLINT: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: cypress
notify-slack:
if: ${{ failure() && github.ref_name == 'main' }}
needs: [cypress]
runs-on: ubuntu-latest
steps:
- name: Notify Slack the tests failed
id: slack
uses: slackapi/slack-github-action@v1.25.0
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 }}