Skip to content

chore(ci): revisit millionco/react-doctor action now that we understand the failure #149

Description

@masch

Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

Problem Description

The millionco/react-doctor@v1.1.1 GitHub Action was failing in CI with sh: 1: react-doctor: not found, even though the action had previously worked. We replaced it with a direct bunx react-doctor invocation, but we should understand and document the root cause before closing the loop.

Investigation Summary

Action version: millionco/react-doctor@v1.1.1 with version: '0.2.16'

The action installs its own copy of react-doctor via npm into a cached toolchain directory. The flow is:

  1. actions/cache restores the toolchain from a previous run
  2. If $TOOLCHAIN_DIR/node_modules/.bin/react-doctor exists and is executable → skip install
  3. Run the cached binary

Hypothesized root cause: A stale/corrupt actions/cache entry. If a previous npm install was partial or the cached binary became invalid (runner image change, Node version mismatch, ABI incompatibility), the cache hit would restore a broken binary. The action's existence check ([ -x "$TOOLCHAIN_DIR/node_modules/.bin/react-doctor" ]) passes, but the binary fails at execution time.

Migration to bunx:
We replaced the action with a direct bun command that is simpler and more reliable:

- name: Fetch base branch for diff scan
  if: github.event_name == 'pull_request'
  run: git fetch --no-tags --depth=1 origin ${{ github.event.pull_request.base.ref }}
- name: React Doctor (diff scan)
  working-directory: apps/mobile
  run: |
    git switch --create ci-branch
    bunx react-doctor --verbose --diff --fail-on error
- name: React Doctor (full scan — informational)
  working-directory: apps/mobile
  run: bunx react-doctor --verbose || true

Key learnings about react-doctor CLI flags (v0.2.16):

Flag Supported Notes
--verbose
--diff Requires a feature branch (not detached HEAD) + origin/main available
--fail-on error Fails CI on errors only
--scope changed Action-only input, not a direct CLI flag in v0.2.16
--blocking error Action-only input, not a direct CLI flag in v0.2.16
--changed-files-from Possibly supported but not tested

PR merge ref issue:
CI checks out refs/pull/N/merge which creates a detached HEAD. React Doctor's --diff uses git rev-parse --abbrev-ref HEAD to detect the feature branch. On detached HEAD, it falls back to full scan. Fix: git switch --create ci-branch before running.

Proposed Solution

Revisit using the official action when:

  1. The action is updated to v2.x (v2.2.2 is latest)
  2. Confirm v2 fixes the stale cache issue (or the cache key has changed)
  3. Document if v2's CLI flags match what we currently use
  4. The action provides additional value we're missing: PR comments, inline review comments, commit status, changed-file detection

Affected Area

CI/Workflows

Alternatives Considered

Current approach with direct bunx works reliably. The action would add PR comment/status integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions