Skip to content

refactor(anvil): adopt cargo-each for scoped checks #1171

refactor(anvil): adopt cargo-each for scoped checks

refactor(anvil): adopt cargo-each for scoped checks #1171

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# Verifies that the in-tree state of cargo-anvil's emitted artifacts
# matches what the binary built from this PR would render. The job:
#
# 1. Builds cargo-anvil from the PR branch.
# 2. Runs `cargo anvil --dry-run` against the repo root.
# 3. Fails iff the binary would change generated content or `.anvil.lock`.
#
# This is the primary dogfooding mechanism described in
# crates/cargo-anvil/docs/verification.md.
#
# Adopters (the maintainers running `cargo anvil` after a
# catalog change) are responsible for landing the regenerated files
# alongside the catalog change in the same PR.
name: regenerate-check
on:
pull_request: {}
merge_group: {}
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: regenerate-check-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
regenerate-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
lfs: true
- name: Build cargo-anvil
run: cargo build --locked -p cargo-anvil
- name: Verify in-tree state matches templates
run: |
# Add target/debug to PATH so cargo finds the freshly built binary
# as a cargo subcommand.
export PATH="$PWD/target/debug:$PATH"
if ! cargo anvil --dry-run ; then
echo "::error::Repository anvil state is out of date." \
"Run 'cargo run -p cargo-anvil -- anvil'" \
"and commit the diff."
exit 1
fi