-
Notifications
You must be signed in to change notification settings - Fork 57
Add React Doctor CI Buildkite job #2659
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
Open
sejas
wants to merge
11
commits into
trunk
Choose a base branch
from
stu-1307-add-react-doctor-ci
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−519
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5aacb0
Add React Doctor CI step to catch React code health regressions
sejas 2a356e2
Add no-op comment to trigger react-doctor CI step
sejas 60d8156
Fix formatting in index.ts
sejas a362f40
Fix react-doctor score parsing by stripping ANSI codes first
sejas a119488
Undo unrelated formatting changes to buildkite pipeline.yml
sejas a7af3cf
Remove no-op change that was used to trigger React Doctor CI
sejas 5af0472
Merge branch 'trunk' of github.com:Automattic/studio into stu-1307-ad…
sejas 563710b
Add react doctor rules
sejas 91ca65e
Reduce SCORE_THRESHOLD to 90
sejas d5030d6
Reduce threshold to 87
sejas d59f6e0
Remove unused files and test function
sejas 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,74 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if .buildkite/commands/should-skip-job.sh --job-type validation; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo '--- :package: Install deps' | ||
| bash .buildkite/commands/install-node-dependencies.sh | ||
|
|
||
| echo '--- :react: React Doctor' | ||
|
|
||
| SCORE_THRESHOLD=87 | ||
| DOCTOR_EXIT=0 | ||
|
|
||
| # Run react-doctor and capture output | ||
| # Don't use --offline so score gets calculated | ||
| # Use --fail-on error to catch error-level issues | ||
| OUTPUT=$(npx -y react-doctor --no-ami --yes --fail-on error 2>&1) || DOCTOR_EXIT=$? | ||
|
|
||
| echo "$OUTPUT" | ||
|
|
||
| # Strip ANSI escape codes for score parsing and annotation | ||
| CLEAN_OUTPUT=$(echo "$OUTPUT" | sed $'s/\x1b\\[[0-9;]*m//g') | ||
|
|
||
| # Parse score from clean output (format: "XX / 100") | ||
| SCORE=$(echo "$CLEAN_OUTPUT" | grep -oE '[0-9]+ / 100' | head -1 | grep -oE '^[0-9]+') || true | ||
|
|
||
| # Post annotation to Buildkite UI | ||
| if command -v buildkite-agent &> /dev/null; then | ||
|
|
||
| if [ -n "$SCORE" ]; then | ||
| if [ "$SCORE" -lt "$SCORE_THRESHOLD" ]; then | ||
| STYLE="error" | ||
| HEADER="React Doctor Score: ${SCORE}/100 (below threshold of ${SCORE_THRESHOLD})" | ||
| else | ||
| STYLE="success" | ||
| HEADER="React Doctor Score: ${SCORE}/100" | ||
| fi | ||
| else | ||
| STYLE="warning" | ||
| HEADER="React Doctor (score not available)" | ||
| fi | ||
|
|
||
| cat <<EOF | buildkite-agent annotate --style "$STYLE" --context "react-doctor" | ||
| ### :react: ${HEADER} | ||
|
|
||
| <details> | ||
| <summary>Full diagnostics</summary> | ||
|
|
||
| \`\`\` | ||
| ${CLEAN_OUTPUT} | ||
| \`\`\` | ||
|
|
||
| </details> | ||
| EOF | ||
| fi | ||
|
|
||
| # Fail if react-doctor itself failed (--fail-on error) | ||
| if [ "$DOCTOR_EXIT" -ne 0 ]; then | ||
| echo "^^^ +++" | ||
| echo "React Doctor found error-level issues (exit code: ${DOCTOR_EXIT})" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fail if score is below threshold | ||
| if [ -n "$SCORE" ] && [ "$SCORE" -lt "$SCORE_THRESHOLD" ]; then | ||
| echo "^^^ +++" | ||
| echo "React Doctor score ${SCORE}/100 is below the threshold of ${SCORE_THRESHOLD}/100" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "React Doctor score: ${SCORE:-unknown}/100 (threshold: ${SCORE_THRESHOLD}/100)" | ||
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
| { | ||
| "ignore": { | ||
| "rules": [ "jsx-a11y/no-autofocus" ], | ||
| "files": [ | ||
| "electron.vite.config.ts", | ||
| "forge.config.ts", | ||
| "bin/studio-cli-launcher.js", | ||
| "src/additional-phrases.ts", | ||
| "src/preload.ts" | ||
| ] | ||
| } | ||
| } |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this always runs the latest version, right? I am wondering if we should use specific version instead? The main reason why I am thinking that is if the latest version has some breaking changes, the CI build could potentially break. But it is not a strong opinion, mostly something to consider in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! it uses the latest version. I had a similar concern where the CI fails because new rules are added or the score algorithm is updated, but in that case we could change the threshold if necessary. Running the latest version allows us to benefit from new best practices and bugfixes.