-
Notifications
You must be signed in to change notification settings - Fork 3
fix: ci - run Jest on every PR and fail only on new failures #3487
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
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b18c516
Clear workflow shellcheck debt and fix consumption examples (#3478)
eleshar 154a49f
Activate organisation reusable workflows (#3480)
eleshar 4acec5e
Read FEEDBACK_RESPONSE.md through the base repository (#3480)
eleshar bfdcf3d
Only trusted authors can advance phases from PRs (#3480)
eleshar b9cc8b1
Run Jest on every PR, failing only on new failures (#3479)
eleshar d6e26a6
Keep the test comparison summary when new failures are found (#3479)
eleshar a925eb3
Make the collection-duration test deterministic (#3479)
eleshar 370a493
Use inclusive jitter bounds in the backoff test (#3479)
eleshar 4a23711
fix(ci): fail artifact pruning on errors and order by filename (#3478)
eleshar afb6a4b
Merge branch 'develop' into chore/ci-hygiene-3478
eleshar b747990
Merge branch 'develop' into chore/ci-hygiene-3478
eleshar 7ad1e8d
Merge branch 'chore/ci-hygiene-3478' into feat/reusable-workflows-3480
eleshar 4700880
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar 3f59e8f
fix(automation): add phase labels before removing the old ones (#3480)
eleshar 17fac70
docs(examples): make the scaffold CI examples runnable on a clean rep…
eleshar 9dc6239
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar a682d0c
Merge remote-tracking branch 'origin/chore/ci-hygiene-3478' into feat…
eleshar 7da80b7
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar 488cc86
Merge branch 'develop' into chore/ci-hygiene-3478
eleshar c42e3a7
Merge branch 'chore/ci-hygiene-3478' into feat/reusable-workflows-3480
eleshar 615b7ac
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar 26d754f
Merge branch 'develop' into chore/ci-hygiene-3478
eleshar 321e25f
Merge branch 'chore/ci-hygiene-3478' into feat/reusable-workflows-3480
eleshar 9d71363
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar d09fee8
Merge branch 'develop' into chore/ci-hygiene-3478
eleshar e809096
Merge branch 'chore/ci-hygiene-3478' into feat/reusable-workflows-3480
eleshar ccc4187
Merge branch 'feat/reusable-workflows-3480' into fix/jest-ci-3479
eleshar 9c143a3
chore(changelog): resolve develop merge for #3487
eleshar ac5abe1
fix(ci): harden Jest pull request gate
eleshar 7069941
fix(ci): keep tested Markdown in Jest
eleshar d718da1
fix(changelog): shorten Jest gate entry
eleshar f5cbf08
merge: update Jest branch after #3459
eleshar 0e02962
Merge remote-tracking branch 'origin/develop' into fix/jest-ci-3479
eleshar 1234885
fix: apply CodeRabbit auto-fixes
eleshar 5ece886
fix: reject testless Jest reports
eleshar a0f623e
test: remove flaky timer lower bound
eleshar b5fa91c
Merge branch 'develop' into fix/jest-ci-3479
mergify[bot] 20a8189
test: stop two 100ms-boundary timing assertions flaking under load
eleshar d8f4936
Merge remote-tracking branch 'origin/develop' into fix/jest-ci-3479
eleshar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,184 @@ | ||
| name: Tests | ||
|
|
||
| # Runs the Jest suite on every PR and fails only on failures the PR | ||
| # introduces: develop still carries known failures (#3472), so the head and | ||
| # base are tested in parallel and compared. Once #3472 clears the baseline, | ||
| # this can gate on zero failures instead (#3479). | ||
|
|
||
| on: | ||
| # No paths filter: this backs a status check, and a filtered-out run | ||
| # never reports. | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: tests-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| scope: | ||
| name: Detect test scope | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| outputs: | ||
| docs_only: ${{ steps.scope.outputs.docs_only }} | ||
| steps: | ||
| - name: Checkout changed files | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Detect documentation-only changes | ||
| id: scope | ||
| env: | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
| run: | | ||
| docs_only=false | ||
| if [ "$EVENT_NAME" = "pull_request" ]; then | ||
| changed_files="$RUNNER_TEMP/tests-changed-files" | ||
| git diff --name-only --no-renames -z "$BASE_SHA" HEAD > "$changed_files" | ||
| if [ -s "$changed_files" ]; then | ||
| docs_only=true | ||
| while IFS= read -r -d '' file; do | ||
| case "$file" in | ||
| docs/LABEL_STRATEGY.md | docs/LABELING.md) | ||
| docs_only=false | ||
| break | ||
| ;; | ||
| docs/*.md) ;; | ||
| *) | ||
| docs_only=false | ||
| break | ||
| ;; | ||
| esac | ||
| done < "$changed_files" | ||
| fi | ||
| fi | ||
| echo "docs_only=$docs_only" >> "$GITHUB_OUTPUT" | ||
|
|
||
| jest: | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| name: Jest (${{ matrix.target }}) | ||
| needs: scope | ||
| if: needs.scope.outputs.docs_only != 'true' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| target: [head, base] | ||
| exclude: | ||
| # No base to compare against outside a pull request. | ||
| - target: ${{ github.event_name != 'pull_request' && 'base' || 'none' }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 1 | ||
| # head: the PR merge commit (default); base: the PR base commit. | ||
| ref: ${{ matrix.target == 'base' && github.event.pull_request.base.sha || '' }} | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --ignore-scripts --prefer-offline --no-audit --no-fund | ||
|
|
||
| - name: Run Jest | ||
| env: | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| run: | | ||
| # Failing tests are expected on develop; the compare job decides. | ||
| # A missing or invalid report fails closed there. | ||
| jest_status=0 | ||
| npx jest --config .jest.config.cjs --ci --coverage=false \ | ||
| --json --outputFile=jest-report.json || jest_status=$? | ||
| jq -r '"suites=\(.numTotalTestSuites) failed_suites=\(.numFailedTestSuites) tests=\(.numTotalTests) failed=\(.numFailedTests)"' \ | ||
| jest-report.json 2>/dev/null || echo "::warning::No Jest report was written" | ||
| if [ "$EVENT_NAME" = "workflow_dispatch" ] \ | ||
| && { [ "$jest_status" -ne 0 ] || [ ! -s jest-report.json ]; }; then | ||
| exit 1 | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| - name: Check the suite left the working tree clean | ||
| run: | | ||
| # Tests must not write into the repository (#3482). Warning only | ||
| # until that is fixed. | ||
| dirty=$(git status --porcelain -- . ':!jest-report.json') | ||
| if [ -n "$dirty" ]; then | ||
| echo "::warning::Jest modified the working tree (#3482):" | ||
| printf '%s\n' "$dirty" | ||
| fi | ||
|
|
||
| - name: Upload report | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: jest-report-${{ matrix.target }} | ||
| path: jest-report.json | ||
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
|
|
||
| compare: | ||
| name: No new test failures | ||
| needs: [scope, jest] | ||
| if: always() && github.event_name == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Report documentation-only skip | ||
| if: needs.scope.outputs.docs_only == 'true' | ||
| run: | | ||
| echo "Documentation-only pull request; Jest comparison skipped." >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Checkout comparison script | ||
| if: needs.scope.outputs.docs_only != 'true' | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 1 | ||
| sparse-checkout: scripts/validation | ||
|
|
||
| - name: Download reports | ||
| if: needs.scope.outputs.docs_only != 'true' | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: jest-report-* | ||
| path: reports | ||
|
|
||
| - name: Compare head with base | ||
| if: needs.scope.outputs.docs_only != 'true' | ||
| run: | | ||
| set -o pipefail | ||
| for target in head base; do | ||
| if ! jq -e '.testResults | type == "array"' "reports/jest-report-$target/jest-report.json" >/dev/null 2>&1; then | ||
| echo "::error::Missing or invalid Jest report for $target; failing closed." | ||
| exit 1 | ||
| fi | ||
| done | ||
| # Both jobs check out to the same workspace path, so one root | ||
| # makes their test paths comparable. The default shell is | ||
| # bash -e: suspend errexit so a non-zero result still reaches the | ||
| # summary below. | ||
| set +e | ||
| node scripts/validation/compare-jest-failures.cjs \ | ||
| --head reports/jest-report-head/jest-report.json --head-root "$GITHUB_WORKSPACE" \ | ||
| --base reports/jest-report-base/jest-report.json --base-root "$GITHUB_WORKSPACE" \ | ||
| | tee comparison.txt | ||
| status=${PIPESTATUS[0]} | ||
| set -e | ||
| { | ||
| echo "## Test comparison (head vs base)" | ||
| echo | ||
| echo '```' | ||
| cat comparison.txt | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| exit "$status" | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.