-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup github actions for run regression label
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Regression Label | ||
|
||
on: | ||
pull_request: | ||
types: [ labeled ] | ||
jobs: | ||
re_run: | ||
# only conintue if a push or PR labeled with 'run regression' | ||
if: github.event.label.name == 'run regression' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
steps: | ||
- name: Re Run last push | ||
# get the last regression run triggered by a pull, and get this run's id | ||
# then rerun the run | ||
# if the run id can't be found the rerun command will fail which should | ||
# fail the job | ||
# When the run hasn't finished yet, we try to cancel the run | ||
# and wait 30s for it to fnish canceling before trying to re-run it. | ||
# If the run isn't complete the rerun command prints this message: | ||
# returned: run 6410886572 cannot be rerun; its workflow file may be broken | ||
run: | | ||
run_id=$(gh run list -e push -b ${{github.head_ref}} -w 'CI v3 Regression' -L 1 --json databaseId -q '.[0].databaseId') | ||
run_status=$(gh run view $run_id --json status -q '.status') | ||
if [[ "$run_status" != "completed" ]] | ||
then | ||
echo "run $run_id is $run_status, trying to cancel" | ||
gh run cancel $run_id | ||
count=0 | ||
until [[ "$run_status" == "completed" || $count -gt 15 ]] | ||
do | ||
sleep 2 | ||
count=$((count+1)) | ||
run_status=$(gh run view $run_id --json status -q '.status') | ||
echo "run: $run_id, status: $run_status, try: $count" | ||
done | ||
fi | ||
echo "rerunning $run_id" | ||
gh run rerun $run_id | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# set repository so we don't have to check out all of the code | ||
GH_REPO: ${{github.repository}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# 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.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] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: v3/node_modules/.cache/webpack/ | ||
key: ${{ github.head_ref || github.ref_name }}-webpack-build | ||
restore-keys: | | ||
main-webpack-build | ||
- 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 | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
flags: cypress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters