From a0703af0b93beb70662f687b25c2834d872ae444 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Mon, 29 May 2023 17:33:14 +0000 Subject: [PATCH] Run 'cargo xtask codegen' in CI and check that there are no diffs --- .github/workflows/checks.yml | 38 +++++++++++++++++++++++++++++- .github/workflows/publish-docs.yml | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 82fa3655e..44e409396 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,7 +56,7 @@ jobs: - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: - # if this changes, change it in cli/Cargo.toml and .github/workflows/publish-docs.yml as well + # if this changes, change it in .github/workflows/publish-docs.yml as well mdbook-version: '0.4.10' - run: mdbook test taskchampion/docs @@ -80,3 +80,39 @@ jobs: command: fmt args: --all -- --check + codegen: + runs-on: ubuntu-latest + name: "codegen" + steps: + - uses: actions/checkout@v3 + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v3 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - uses: actions-rs/toolchain@v1 + with: + # Same as the MSRV in rust-tests.yml + toolchain: "1.64" + override: true + + - uses: actions-rs/cargo@v1.0.3 + with: + command: run + args: --package xtask -- codegen + + - name: check for changes + run: | + if ! git diff; then + echo "Generated code not up-to-date; + run `cargo run --package xtask -- codegen` and commit the result"; + exit 1; + fi diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 6237248b0..58c22184c 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -18,7 +18,7 @@ jobs: - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: - # if this changes, change it in cli/Cargo.toml and .github/workflows/publish-docs.yml as well + # if this changes, change it in .github/workflows/publish-docs.yml as well mdbook-version: '0.4.10' - run: mdbook build taskchampion/docs