55#
66# 1. Deterministic history — flaky-history-analysis.ts counts how often each
77# modified test file failed on main over the last 30 days of completed
8- # ci.yml runs, bucketed into 7d/30d windows.
8+ # ci.yml runs, bucketed into 7d/15d/ 30d windows.
99# → writes .ai-pr-analyzer/flaky-history.json
1010#
1111# 2. AI analyzer — MetaMask/ai-analyzer's flaky-unit-test-analysis mode
6969 command : cd .github/scripts && yarn --immutable
7070
7171 # Stage 1: deterministic historical analysis. Identifies modified unit
72- # test files and counts their failures on main over the last 365 days of
73- # completed ci.yml runs, bucketed into 7d/30d/90d/365d windows
72+ # test files and counts their failures on main over the last 30 days of
73+ # completed ci.yml runs, bucketed into 7d/15d/30d windows
7474 # (failure+success runs only; cancelled/timed_out are excluded from the
7575 # denominator). When no modified test file changed since its last-analyzed
7676 # SHA (stored in the sticky comment), the step emits should_analyze=false
@@ -95,12 +95,19 @@ jobs:
9595 # The synced SKILL.md is then copied into .ai-pr-analyzer/skills/ so the
9696 # analyzer's load_skill tool can find it (single source of truth — no
9797 # hand-duplicated pattern content in this repo).
98+ # Pinned to a reviewed commit SHA rather than `main`: this bootstrap runs
99+ # in the same workspace as later token-bearing steps, so executing code
100+ # from a moving branch would let an unreviewed upstream change affect
101+ # this PR's CI run. Bump the SHA deliberately when the skill needs
102+ # updating.
98103 - name : Sync flaky-test-detection skill
99104 if : >-
100105 steps.detect-history.outputs.should_analyze == 'true' &&
101106 !github.event.pull_request.head.repo.fork
107+ env :
108+ SKILLS_BOOTSTRAP_SHA : fad21fb8f6158a8f939e8b30bf8f8af755ce67cd
102109 run : |
103- curl -fsSL https://raw.githubusercontent.com/MetaMask/skills/main /tools/bootstrap \
110+ curl -fsSL " https://raw.githubusercontent.com/MetaMask/skills/${SKILLS_BOOTSTRAP_SHA} /tools/bootstrap" \
104111 | bash -s -- --repo metamask-mobile --domain coding
105112 mkdir -p .ai-pr-analyzer/skills
106113 cp .agents/skills/mms-flaky-test-detection/SKILL.md \
@@ -134,6 +141,10 @@ jobs:
134141 # test files — the composite action always analyzes the full PR diff.
135142 # This also means the analyzer never has a chance to post its own PR
136143 # comment; Stage 3 below is the only PR-visible output.
144+ # --skip-scope bypasses the analyzer's default minimum-changed-lines
145+ # gate: Stage 1 already narrowed the input to modified unit test files,
146+ # so a 1-2 line edit that introduces a flaky pattern must still be
147+ # analyzed instead of being skipped for being "too small".
137148 - name : Run flaky unit test AI analysis
138149 if : >-
139150 steps.detect-history.outputs.should_analyze == 'true' &&
@@ -149,14 +160,20 @@ jobs:
149160 --config .ai-pr-analyzer \
150161 --mode flaky-unit-test-analysis \
151162 --base-branch "origin/${{ github.base_ref }}" \
152- --changed-files "${{ steps.detect-history.outputs.files_to_analyze }}"
163+ --changed-files "${{ steps.detect-history.outputs.files_to_analyze }}" \
164+ --skip-scope
153165
154166 # Stage 3: unified sticky PR comment combining Stage 1 + Stage 2
155- # output. Runs only when should_analyze is true — if Stage 1 determined
156- # no modified test file changed since last analysis, the existing comment
157- # is left untouched and Stage 3 is skipped entirely. Never blocks the PR.
167+ # output. Runs when should_analyze is true, or when the PR no longer
168+ # modifies any unit test file — the latter lets the 4-state matrix flip
169+ # a stale sticky comment to "all fixed" when test changes are removed.
170+ # If Stage 1 determined no modified test file changed since last
171+ # analysis (should_analyze=false but has_test_files=true), the existing
172+ # comment is left untouched and Stage 3 is skipped. Never blocks the PR.
158173 - name : Post unified sticky comment
159- if : steps.detect-history.outputs.should_analyze == 'true'
174+ if : >-
175+ steps.detect-history.outputs.should_analyze == 'true' ||
176+ steps.detect-history.outputs.has_test_files == 'false'
160177 continue-on-error : true
161178 working-directory : .github/scripts
162179 env :
0 commit comments