ci: run affected suites and guide meaningful test coverage (#14) · github/replica@bae981d · GitHub
Skip to content

Commit bae981d

Browse files
ci: run affected suites and guide meaningful test coverage (#14)
<!-- Use a conventional commit-style title, such as "fix(hub): retain prototype history". --> ## Why <!-- Explain the problem and why this change matters in a short, plain-English paragraph. Link the issue when applicable. --> Hub and build-action checks currently run for unrelated pull requests. Some existing assertions also repeat coverage or freeze visual implementation details rather than protect behavior. ## What changes <!-- Describe what becomes different for a first-time reader. Explain necessary terms. Include accurate Mermaid diagrams when they clarify the proposal, using before/after diagrams when helpful. Add screenshots for meaningful UI changes. --> <!-- Omit validation sections, checklists, and routine test/CI summaries such as "CI is green" or "tests passed". Mention only known verification gaps that affect the change, not disclaimers about drafting this description. --> Pull requests select whole Hub and build-action suites from their changed paths, including shared dependencies. Unknown paths run both suites, and pushes to main retain both complete suites. Existing required check names remain available, and the final checks reject failed selection or missing results. Dependency-age checks and the Starter and Learning workflows remain unchanged. A shared test-writing skill asks agents to justify distinct regression coverage and use an independent test writer for substantial behavior changes and nontrivial fixes. The change also removes exact SVG-count assertions and repeated starter-content validation while retaining behavioral and copy checks. Actual GitHub skipping and required-check reporting remain unverified. This PR should run both full suites because it changes workflows; a separate docs-only PR based on this branch is needed to exercise the skipped-suite path. --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9dd112c2-7eb9-443c-bc31-37cb9c3a663e
1 parent fdf9d04 commit bae981d

12 files changed

Lines changed: 646 additions & 17 deletions

File tree

Lines changed: 36 additions & 0 deletions

‎.github/workflows/actions-ci.yml‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ permissions:
99
contents: read
1010

1111
jobs:
12+
changes:
13+
uses: ./.github/workflows/ci-changes.yml
14+
1215
test:
13-
name: Replica action tests
16+
name: Build action suite
17+
needs: changes
18+
if: ${{ needs.changes.outputs.build_action == 'true' }}
1419
runs-on: ubuntu-latest
1520
steps:
1621
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -28,3 +33,22 @@ jobs:
2833
- name: Prepare composite action fixture
2934
run: cp actions/build/test/fixture/package.json actions/build/test/fixture/package-lock.json actions/build/test/fixture/fixture-build.mjs .
3035
- uses: ./actions/build
36+
37+
result:
38+
name: Replica action tests
39+
needs: [changes, test]
40+
if: ${{ always() }}
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Require the selected build-action suite to pass
44+
env:
45+
SELECTION_RESULT: ${{ needs.changes.result }}
46+
SELECTED: ${{ needs.changes.outputs.build_action }}
47+
TEST_RESULT: ${{ needs.test.result }}
48+
run: |
49+
test "$SELECTION_RESULT" = success
50+
case "$SELECTED" in
51+
true) test "$TEST_RESULT" = success ;;
52+
false) test "$TEST_RESULT" = skipped ;;
53+
*) echo "Invalid build-action suite selection" >&2; exit 1 ;;
54+
esac

‎.github/workflows/ci-changes.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI selection
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
hub:
7+
description: Run the complete Hub suite
8+
value: ${{ jobs.changes.outputs.hub }}
9+
build_action:
10+
description: Run the build-action suite
11+
value: ${{ jobs.changes.outputs.build_action }}
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
changes:
18+
name: Select affected suites
19+
runs-on: ubuntu-latest
20+
outputs:
21+
hub: ${{ steps.select.outputs.hub }}
22+
build_action: ${{ steps.select.outputs.build_action }}
23+
steps:
24+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
fetch-depth: 0
27+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
28+
with:
29+
node-version: 24
30+
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
31+
with:
32+
working-directory: hub
33+
- run: node --test scripts/select-ci-suites.test.mjs
34+
- run: ruby scripts/check-ci-workflows.rb
35+
- id: select
36+
run: node scripts/select-ci-suites.mjs
37+
env:
38+
CI_EVENT_NAME: ${{ github.event_name }}
39+
CI_BASE_SHA: ${{ github.event.pull_request.base.sha }}
40+
CI_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

‎.github/workflows/hub-ci.yml‎

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ defaults:
1313
working-directory: hub
1414

1515
jobs:
16+
changes:
17+
uses: ./.github/workflows/ci-changes.yml
18+
1619
rails_test:
1720
name: Rails tests
21+
needs: changes
22+
if: ${{ needs.changes.outputs.hub == 'true' }}
1823
runs-on: ubuntu-latest
1924
steps:
2025
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -45,6 +50,8 @@ jobs:
4550

4651
development_queue:
4752
name: Development queue
53+
needs: changes
54+
if: ${{ needs.changes.outputs.hub == 'true' }}
4855
runs-on: ubuntu-latest
4956
steps:
5057
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -57,6 +64,8 @@ jobs:
5764

5865
ruby_lint:
5966
name: Ruby lint
67+
needs: changes
68+
if: ${{ needs.changes.outputs.hub == 'true' }}
6069
runs-on: ubuntu-latest
6170
env:
6271
RUBOCOP_CACHE_ROOT: tmp/rubocop
@@ -70,6 +79,8 @@ jobs:
7079

7180
zeitwerk:
7281
name: Zeitwerk
82+
needs: changes
83+
if: ${{ needs.changes.outputs.hub == 'true' }}
7384
runs-on: ubuntu-latest
7485
steps:
7586
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -82,6 +93,8 @@ jobs:
8293

8394
annotations:
8495
name: Annotations
96+
needs: changes
97+
if: ${{ needs.changes.outputs.hub == 'true' }}
8598
runs-on: ubuntu-latest
8699
steps:
87100
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -94,6 +107,8 @@ jobs:
94107

95108
bundler_audit:
96109
name: Bundler audit
110+
needs: changes
111+
if: ${{ needs.changes.outputs.hub == 'true' }}
97112
runs-on: ubuntu-latest
98113
steps:
99114
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -105,6 +120,8 @@ jobs:
105120

106121
typecheck:
107122
name: TypeScript types
123+
needs: changes
124+
if: ${{ needs.changes.outputs.hub == 'true' }}
108125
runs-on: ubuntu-latest
109126
steps:
110127
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -118,6 +135,8 @@ jobs:
118135

119136
frontend_lint:
120137
name: Frontend lint
138+
needs: changes
139+
if: ${{ needs.changes.outputs.hub == 'true' }}
121140
runs-on: ubuntu-latest
122141
steps:
123142
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -131,23 +150,42 @@ jobs:
131150

132151
frontend_test_shard:
133152
name: Frontend tests shard ${{ matrix.shard }}/4
153+
needs: changes
154+
if: ${{ always() }}
134155
runs-on: ubuntu-latest
135156
strategy:
136157
fail-fast: false
137158
matrix:
138159
shard: [1, 2, 3, 4]
139160
steps:
161+
- name: Require valid suite selection
162+
working-directory: .
163+
env:
164+
SELECTION_RESULT: ${{ needs.changes.result }}
165+
SELECTED: ${{ needs.changes.outputs.hub }}
166+
run: |
167+
test "$SELECTION_RESULT" = success
168+
case "$SELECTED" in
169+
true|false) ;;
170+
*) echo "Invalid Hub suite selection" >&2; exit 1 ;;
171+
esac
140172
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
173+
if: ${{ needs.changes.outputs.hub == 'true' }}
141174
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
175+
if: ${{ needs.changes.outputs.hub == 'true' }}
142176
with:
143177
node-version-file: hub/package.json
144178
cache: npm
145179
cache-dependency-path: hub/package-lock.json
146180
- run: npm ci
181+
if: ${{ needs.changes.outputs.hub == 'true' }}
147182
- run: npm test -- --shard=${{ matrix.shard }}/4
183+
if: ${{ needs.changes.outputs.hub == 'true' }}
148184

149185
frontend_integration_test:
150186
name: Controls and extension tests
187+
needs: changes
188+
if: ${{ needs.changes.outputs.hub == 'true' }}
151189
runs-on: ubuntu-latest
152190
steps:
153191
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -169,19 +207,29 @@ jobs:
169207
170208
frontend_test:
171209
name: Frontend tests
172-
needs: [frontend_test_shard, frontend_integration_test]
210+
needs: [changes, frontend_test_shard, frontend_integration_test]
173211
if: ${{ always() }}
174212
runs-on: ubuntu-latest
175213
steps:
176214
- name: Require all frontend suites to pass
177215
working-directory: .
178216
env:
217+
SELECTION_RESULT: ${{ needs.changes.result }}
218+
SELECTED: ${{ needs.changes.outputs.hub }}
179219
SHARD_RESULT: ${{ needs.frontend_test_shard.result }}
180220
INTEGRATION_RESULT: ${{ needs.frontend_integration_test.result }}
181-
run: test "$SHARD_RESULT" = success && test "$INTEGRATION_RESULT" = success
221+
run: |
222+
test "$SELECTION_RESULT" = success
223+
case "$SELECTED" in
224+
true) test "$SHARD_RESULT" = success && test "$INTEGRATION_RESULT" = success ;;
225+
false) test "$SHARD_RESULT" = success && test "$INTEGRATION_RESULT" = skipped ;;
226+
*) echo "Invalid Hub suite selection" >&2; exit 1 ;;
227+
esac
182228
183229
frontend_build:
184230
name: Frontend build
231+
needs: changes
232+
if: ${{ needs.changes.outputs.hub == 'true' }}
185233
runs-on: ubuntu-latest
186234
steps:
187235
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -197,6 +245,8 @@ jobs:
197245

198246
storybook_build:
199247
name: Storybook build
248+
needs: changes
249+
if: ${{ needs.changes.outputs.hub == 'true' }}
200250
runs-on: ubuntu-latest
201251
steps:
202252
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -210,6 +260,8 @@ jobs:
210260

211261
production_database:
212262
name: Production database
263+
needs: changes
264+
if: ${{ needs.changes.outputs.hub == 'true' }}
213265
runs-on: ubuntu-latest
214266
steps:
215267
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -224,6 +276,8 @@ jobs:
224276

225277
production_image:
226278
name: Production image
279+
needs: changes
280+
if: ${{ needs.changes.outputs.hub == 'true' }}
227281
runs-on: ubuntu-latest
228282
steps:
229283
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Read [Contributing](CONTRIBUTING.md) and the [shared documentation index](docs/R
99
- [Coding conventions](docs/coding-conventions.md) apply to complete changes, tests, and comments.
1010
- [Documentation conventions](docs/documentation-conventions.md) apply to discussions, prose, labels, and errors.
1111
- [Testing and review](docs/testing-and-review.md) explains how to choose checks and review a change.
12+
- Use the [test-writing skill](.github/skills/write-tests/SKILL.md) when adding or changing automated tests.
1213

1314
Keep shared rules in root guides and project-specific rules in the affected project. Do not apply Hub's Rails, Primer, or devcontainer requirements to the starter, build action, or shared packages. The starter's copied instructions must remain usable without this monorepo.
1415

‎docs/testing-and-review.md‎

Lines changed: 42 additions & 0 deletions

0 commit comments

Comments
 (0)