Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,29 @@ jobs:
for dir in $SCOPE_BUILD_DIRS; do
( cd "packages/$dir" && bun run build ) || { echo "❌ build failed for packages/$dir"; exit 1; }
done
# #656: the inventory guards verify THIS declared build set instead
# of demanding every workspace (tests/helpers/build-scope.ts).
echo "SVFORGE_BUILD_WORKSPACES=$SCOPE_BUILD_DIRS" >> "$GITHUB_ENV"
exit 0
fi
bun run --filter '*' build
echo "SVFORGE_BUILD_WORKSPACES=all" >> "$GITHUB_ENV"

- name: Run tests
env:
SCOPE_TESTS: ${{ steps.scope.outputs.tests || 'all' }}
SCOPE_TEST_FILES: ${{ steps.scope.outputs.test_files }}
SCOPE_DEFERRED: ${{ steps.scope.outputs.deferred_test_files }}
SCOPE_REASON: ${{ steps.scope.outputs.reason }}
run: |
if [ -n "$SCOPE_DEFERRED" ]; then
# #656: cross-cutting guards that cannot be proven safe under a scoped
# build are NOT skipped — they are deferred to full validation (push
# to the default branch, ci:full, release), and listed here so the
# trade-off is auditable on every targeted run.
echo "Deferring $(echo "$SCOPE_DEFERRED" | wc -w) cross-cutting test file(s) to full validation:" | tee -a "$GITHUB_STEP_SUMMARY"
for file in $SCOPE_DEFERRED; do echo " - $file" | tee -a "$GITHUB_STEP_SUMMARY"; done
fi
if [ "$SCOPE_TESTS" = "none" ]; then
echo "Skipping tests — ${SCOPE_REASON:-no test suite selected}" | tee -a "$GITHUB_STEP_SUMMARY"
exit 0
Expand Down
36 changes: 36 additions & 0 deletions docs/ci-affected-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ unresolvable helpers, and a bounded source-only chain that stays scoped.
6. **Escalation never skips work**: the plan only ever moves from `selected` to `all` builds; the test selection is untouched.
7. Resolution stays pure and testable: `distRequirementsForSource()`, `distRequirementsForFile()`, `distInventory()` and `planBuildSet()` are exported from `scripts/affected-scope.mjs`; `scripts/ci/affected-step.mjs` only translates the plan into CI outputs.

## Scope-aware inventory guards (#656)

The formerly global guards no longer demand every workspace's `dist`; they
verify the run's **declared build set**:

- `tests/helpers/build-scope.ts` reads `SVFORGE_BUILD_WORKSPACES` (exported by
the CI build step for a scoped build; absent or `all` → every workspace, which
is also the local/full behaviour). It throws on an unknown or empty set, so a
typo fails loudly instead of shrinking the guard.
- `structure`, `modules`, `build` and `cli-create` verify each built workspace
(add-on entry, `dist/index.js`, option registry) and keep their source-level
contracts for every package. `cli-create` still asserts that EVERY module
declares its add-on options; only the dist comparison is scoped.
- The resolver recognises these files (`helpers/build-scope`) as *scope-aware*
and stops treating them as unbounded; guards that genuinely need all artifacts
or spawn packaging/CLI processes (`addon-packaging`, `user-journey`, `real-bin`,
`changesets`, `package-entry`, the canaries) keep escalating to a full build.

## Fail-closed gating (#656 review B-01)

A reduced build is allowed **only when every selected test can run against it**.

- `partitionBuildSet()` reports what is *runnable* under the scoped order and
what is not; `planCiSteps()` uses that only as a gate. Any selected test with
an unbounded/uncertain requirement, or one outside the scoped order, escalates
the **whole run** back to a full build + full tests.
- The `deferred_test_files` output therefore stays empty on a passing required
check: no scoped build may be green while selected tests have not run. The
earlier "defer to full validation" behaviour was removed — running missing
tests after merge or at release cannot catch a regression before merge.
- Consequence, measured and documented below: with the repository's current test
shape (almost every test is owned by `svforge`, and ~37 meta-tests need every
workspace's `dist`), an isolated add-on change is **always** escalated to a
full build. The 3-workspace experiment from the previous revision remains a
performance upper bound, not a gated validation.

## Scenarios that still require a full build

- Any change to root config, workflows, `scripts/`, lockfile, release metadata or an unknown path (resolver-level full scope).
Expand Down
Loading
Loading