ci: check that jiff-cli generate doesn't produce diffs

This should help ensure that generated code doesn't get stale.

This is especially pertinent with the new `src/shared` module, which has
to be copied over to `crates/jiff-static/shared` any time a change is
made. Not all changes result in breakage (theoretical or otherwise), so
it's easy to forget to do.
This commit is contained in:
Andrew Gallant 2025-03-06 08:24:57 -05:00
parent d6959a2664
commit 2bf9eb6ebc

View file

@ -372,3 +372,50 @@ jobs:
- name: Check formatting
run: |
cargo fmt --all -- --check
# Check that some `jiff-cli generate` commands don't produce a diff.
#
# This is useful for ensuring that, e.g., changes to `src/shared` are
# propagated to `crates/jiff-static/shared`.
generated:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install jiff-cli
run: cargo install -f --path crates/jiff-cli
- name: Generate code shared between jiff and jiff-static
run: |
jiff-cli generate shared
if ! git diff --exit-code; then
echo 'Please run `jiff-cli generated shared`'
exit 1
fi
- name: Generate crc32 code
run: |
jiff-cli generate crc32
if ! git diff --exit-code; then
echo 'Please run `jiff-cli generated crc32`'
exit 1
fi
- name: Generate unit designator match expression
run: |
jiff-cli generate unit-designator-match
if ! git diff --exit-code; then
echo 'Please run `jiff-cli generated unit-designator-match`'
exit 1
fi
- name: Generate mapping from Windows zones to IANA time zone identifiers
run: |
curl -LO 'https://raw.githubusercontent.com/unicode-org/cldr/main/common/supplemental/windowsZones.xml'
jiff-cli generate windows-zones windowsZones.xml
if ! git diff --exit-code; then
echo 'In a separate PR, please download windowsZones.xml'
echo 'from github.com/unicode-org/cldr and run'
echo '`jiff-cli generated windows-zones`'
exit 1
fi