Skip to content

Commit c288c86

Browse files
committed
ci: diff public API only on features common to base and head
cargo public-api builds both revisions with the same feature set, so a feature introduced (or removed) by a PR broke the build of the other revision. Restrict the all-features diff to features present in both the base and head revisions.
1 parent 4dbf0b4 commit c288c86

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,32 @@ jobs:
170170
171171
- name: Check rmcp (all features except local)
172172
run: |
173-
FEATURES=$(cargo metadata --no-deps --format-version 1 \
174-
| jq -r '[.packages[] | select(.name == "rmcp") | .features | keys[]
175-
| select(startswith("__") | not)
176-
| select(. != "local")] | join(",")')
173+
BASE_SHA=${{ github.event.pull_request.base.sha }}
174+
# `cargo public-api diff` builds both revisions with the same feature
175+
# set, so a feature that exists on only one side (e.g. a feature added
176+
# or removed by this PR) would fail to build the other revision. Diff
177+
# only the features present in BOTH the base and the head; features
178+
# unique to one side are necessarily pure additions/removals, which the
179+
# release-type deny flags already govern.
180+
list_features() {
181+
cargo metadata --no-deps --format-version 1 --manifest-path "$1/Cargo.toml" \
182+
| jq -r '.packages[] | select(.name == "rmcp") | .features | keys[]
183+
| select(startswith("__") | not)
184+
| select(. != "local")'
185+
}
186+
list_features "." | sort -u > "$RUNNER_TEMP/head_features"
187+
git worktree add --detach "$RUNNER_TEMP/rmcp-base" "$BASE_SHA"
188+
list_features "$RUNNER_TEMP/rmcp-base" | sort -u > "$RUNNER_TEMP/base_features"
189+
git worktree remove --force "$RUNNER_TEMP/rmcp-base"
190+
FEATURES=$(comm -12 "$RUNNER_TEMP/head_features" "$RUNNER_TEMP/base_features" | paste -sd, -)
177191
cargo public-api \
178192
--package rmcp \
179193
--features "$FEATURES" \
180194
-ss \
181195
diff \
182196
$DENY \
183197
--force \
184-
${{ github.event.pull_request.base.sha }}..${{ github.sha }}
198+
"$BASE_SHA"..${{ github.sha }}
185199
186200
spelling:
187201
name: spell check with typos

0 commit comments

Comments
 (0)