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
6 changes: 4 additions & 2 deletions .github/workflows/feature-unification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ on:
- "**/Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- "scripts/feature-unification-scope.ts"
- "scripts/feature-unification-scope/scope.ts"
- "scripts/feature-unification-scope/package.json"
- "scripts/feature-unification-scope/package-lock.json"
- ".github/workflows/feature-unification.yml"

# no top level default permissions for security reasons
Expand Down Expand Up @@ -68,7 +70,7 @@ jobs:
git show HEAD^1:Cargo.lock > .scope/base-lock.txt 2>/dev/null || : > .scope/base-lock.txt
git diff HEAD^1 HEAD -- Cargo.toml > .scope/toml-diff.txt 2>/dev/null || : > .scope/toml-diff.txt

# scripts/feature-unification-scope.ts attributes the diff to crates
# scripts/feature-unification-scope/scope.ts attributes the diff to crates
# in-container and skips the cargo-hack check when nothing is affected.
- name: Run feature unification check
if: steps.guard.outputs.hit != 'true'
Expand Down
15 changes: 8 additions & 7 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
IF [ "$GENERATE_TEST_TXS" = "true" ]
COPY ledger/test-data/simple-merkle-tree.compact /tmp/simple-merkle-tree.compact
WORKDIR /toolkit-js
RUN npx run-compactc /tmp/simple-merkle-tree.compact /test-static/simple-merkle-tree

Check failure on line 234 in Earthfile

View workflow job for this annotation

GitHub Actions / Check Genesis Rebuild

Error

The command RUN npx run-compactc /tmp/simple-merkle-tree.compact /test-static/simple-merkle-tree did not complete successfully. Exit code 1
WORKDIR /
END

Expand Down Expand Up @@ -859,8 +859,8 @@
# The partner-chains demo crates are excluded: they are upstream examples, not
# shipped artifacts, and cost ~5min of the serial check.
#
# Scope is computed in-container by scripts/feature-unification-scope.ts (the
# reverse-dependency closure of the crates the PR diff touches). It reads three
# Scope is computed in-container by scripts/feature-unification-scope/scope.ts
# (the reverse-dependency closure of the crates the PR diff touches). It reads three
# git-derived files from .scope/, which must exist before the build -- git
# history only lives on the host, and `--ci` (strict) forbids LOCALLY. The CI
# workflow writes them; for a local run, from the repo root:
Expand All @@ -874,14 +874,15 @@
CACHE --sharing shared --id cargo-git /usr/local/cargo/git
CACHE --sharing shared --id cargo-reg /usr/local/cargo/registry
# Scope tooling deps (smol-toml) in their own layer so workspace edits don't
# reinstall. node + npm are pinned in the CI base image.
COPY scripts/package.json scripts/package-lock.json scripts/
RUN cd scripts && npm ci --no-audit --no-fund
# reinstall. node + npm are pinned in the CI base image. --omit=dev skips
# @types/node (LSP-only, not needed at runtime).
COPY scripts/feature-unification-scope/package.json scripts/feature-unification-scope/package-lock.json scripts/feature-unification-scope/
RUN cd scripts/feature-unification-scope && npm ci --no-audit --no-fund --omit=dev
COPY --keep-ts --dir \
Cargo.lock Cargo.toml .config .sqlx deny.toml docs \
ledger LICENSE node pallets primitives README.md res runtime \
metadata rustfmt.toml util tests relay partner-chains COMPACTC_VERSION .
COPY scripts/feature-unification-scope.ts scripts/feature-unification-scope.ts
COPY scripts/feature-unification-scope/scope.ts scripts/feature-unification-scope/scope.ts
# git-derived scope inputs, produced on the host before the build (see above)
COPY .scope/changed.txt .scope/base-lock.txt .scope/toml-diff.txt .scope/

Expand All @@ -894,7 +895,7 @@
RUN cargo binstall --no-confirm --locked cargo-hack@${CARGO_HACK_VERSION}
# node is pinned in the CI base image; the scoper reads the git-derived
# inputs and emits the `-p` selection (empty => nothing to check).
RUN PACKAGES="$(node scripts/feature-unification-scope.ts \
RUN PACKAGES="$(node scripts/feature-unification-scope/scope.ts \
.scope/changed.txt .scope/base-lock.txt .scope/toml-diff.txt)" && \
if [ -z "$PACKAGES" ]; then \
echo "feature-unification: nothing affected — skipping"; exit 0; \
Expand Down Expand Up @@ -1367,7 +1368,7 @@
COPY ${DIRECTORY} ${DIRECTORY}
WORKDIR ${DIRECTORY}
RUN mkdir -p /scan_reports
RUN --no-cache npm audit --audit-level high --json > npm-audit-${REPORT_NAME}.json \

Check failure on line 1371 in Earthfile

View workflow job for this annotation

GitHub Actions / audit job npm

Error

The command RUN --no-cache npm audit --audit-level high --json > npm-audit-${REPORT_NAME}.json && npx npm-audit-sarif -o /scan_reports/npm-audit-${REPORT_NAME}.sarif npm-audit-${REPORT_NAME}.json did not complete successfully. Exit code 1
&& npx npm-audit-sarif -o /scan_reports/npm-audit-${REPORT_NAME}.sarif npm-audit-${REPORT_NAME}.json
SAVE ARTIFACT /scan_reports/npm-audit-${REPORT_NAME}.sarif AS LOCAL scan_reports/npm-audit-${REPORT_NAME}.sarif

Expand Down
273 changes: 0 additions & 273 deletions scripts/feature-unification-scope.ts

This file was deleted.

41 changes: 41 additions & 0 deletions scripts/feature-unification-scope/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# feature-unification-scope

Computes the `cargo hack check --no-dev-deps` package selection for the
[Feature Unification](../../.github/workflows/feature-unification.yml) CI check:
the reverse-dependency closure of the crates a PR diff touches, so the (serial,
slow) check only runs over what could actually have regressed.

`scope.ts` is a single TypeScript file run directly via Node's native
type-stripping (Node >= 22.18) — there is no build step. See the header comment
in `scope.ts` for the full algorithm and the three output shapes.

## Layout

- `scope.ts` — the scoper. `computeScope()` is the pure decision (no I/O);
`main()` is the thin shell that reads argv / `cargo metadata` / `Cargo.lock`.
- `scope.test.ts` — behaviour tests driving `computeScope()` end-to-end plus
unit tests for the helpers.
- `package.json` / `package-lock.json` — the one runtime dep (`smol-toml`) and
`@types/node` (dev-only, for editor/LSP type-checking).
- `tsconfig.json` — tuned so the LSP enforces exactly what Node's type-stripping
allows.

## Develop

```sh
npm ci # install smol-toml + @types/node
npm test # node --test *.test.ts
```

## Run locally

From the repo root (git access is only needed to produce the three inputs):

```sh
mkdir -p .scope
git diff --name-only HEAD^1 HEAD > .scope/changed.txt
git show HEAD^1:Cargo.lock > .scope/base-lock.txt
git diff HEAD^1 HEAD -- Cargo.toml > .scope/toml-diff.txt
node scripts/feature-unification-scope/scope.ts \
.scope/changed.txt .scope/base-lock.txt .scope/toml-diff.txt
```
Loading
Loading