Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .buildkite/commands/run-react-doctor.sh
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=$?
Copy link
Contributor

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.

Copy link
Member Author

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.


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)"
10 changes: 10 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ steps:
- github_commit_status:
context: Lint

- label: ':react: React Doctor'
agents:
queue: mac
key: react_doctor
command: bash .buildkite/commands/run-react-doctor.sh
plugins: [$CI_TOOLKIT_PLUGIN, $NVM_PLUGIN]
notify:
- github_commit_status:
context: React Doctor

- label: Unit Tests on {{matrix}}
key: unit_tests
command: bash .buildkite/commands/run-unit-tests.sh "{{matrix}}"
Expand Down
56 changes: 0 additions & 56 deletions apps/studio/e2e/page-objects/user-settings-modal.ts

This file was deleted.

12 changes: 12 additions & 0 deletions apps/studio/react-doctor.config.json
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"
]
}
}
11 changes: 0 additions & 11 deletions apps/studio/src/lib/test-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { configureStore } from '@reduxjs/toolkit';
import { render } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import { rootReducer } from 'src/stores';
import { appVersionApi } from 'src/stores/app-version-api';
import { certificateTrustApi } from 'src/stores/certificate-trust-api';
Expand Down Expand Up @@ -43,11 +40,3 @@ export function createTestStore( options: TestStoreOptions = {} ) {

return store;
}

export function renderWithProvider( ui: React.ReactElement, options: TestStoreOptions = {} ) {
const store = createTestStore( options );
return {
...render( <Provider store={ store }>{ ui }</Provider> ),
store,
};
}
Loading