From 57b5943a1646b7881c0ac26851afe0b9fb4d5467 Mon Sep 17 00:00:00 2001 From: nils m Date: Thu, 19 Dec 2024 14:03:10 -0800 Subject: [PATCH] Check fib and calculator generated files in CI --- .github/actions/bazelisk/action.yml | 20 +++++++++++++++ .github/workflows/main.yml | 39 ++++++++++++++++++----------- zirgen/bootstrap/src/main.rs | 15 ++++++++--- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/.github/actions/bazelisk/action.yml b/.github/actions/bazelisk/action.yml index 9fc07088..53aea55e 100644 --- a/.github/actions/bazelisk/action.yml +++ b/.github/actions/bazelisk/action.yml @@ -1,8 +1,28 @@ name: bazelisk installer description: Install bazelisk +inputs: + cache-key: + required: true runs: using: composite steps: + # Cache bazel build on linux. (MacOS uses the local cache on the runner.) + - name: Get Date + id: get-date + run: | + echo "date=$(/bin/date -u "+%Y-%m-%d")" >> $GITHUB_OUTPUT + shell: bash + - if: matrix.os == 'Linux' + uses: actions/cache@v4 + env: + cache-name: bazel-build + with: + path: "~/.cache/bazel" + # Generate a new build cache once a day, reusing the previous day's if available + key: "bazel-${{ matrix.os }}-${{ inputs.cache-key }}-${{ steps.get-date.outputs.date }}" + restore-keys: | + "bazel-${{ matrix.os }}-${{ inputs.cache-key }}-" + "bazel-${{ matrix.os }}-" - if: runner.os == 'Linux' run: | echo "BAZELISK_OS=linux" >> $GITHUB_ENV diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf0054bf..be2e1e2a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,6 +42,27 @@ jobs: python-version: "3.10" - run: python license-check.py + check-generated-zirgen: + runs-on: [self-hosted, prod, Linux, cpu] + strategy: + fail-fast: false + matrix: + os: [Linux] + env: + RUST_BACKTRACE: full + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/bazelisk + with: + cache-key: bootstrap + - uses: risc0/risc0/.github/actions/rustup@4ab1f0bba1b0515819221bebc59f95aad0a6a3a9 + - uses: risc0/risc0/.github/actions/sccache@1a373c71585766e4f6985b96c48389daaf69d528 + with: + key: ${{ matrix.os }}-bootstrap + - name: ${{ matrix.circuit }} generated files up to date + run: cargo bootstrap -- --check fib + run: cargo bootstrap -- --check calculator + bazel: runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}"] strategy: @@ -52,23 +73,10 @@ jobs: - os: Linux config: --config=ci steps: - - name: Get Date - id: get-date - run: | - echo "date=$(/bin/date -u "+%Y-%m-%d")" >> $GITHUB_OUTPUT - shell: bash - uses: actions/checkout@v3 - # Cache bazel build on linux. (MacOS uses the local cache on the runner.) - - if: matrix.os == 'Linux' - uses: actions/cache@v4 - env: - cache-name: bazel-build - with: - path: "~/.cache/bazel" - # Generate a new build cache once a day, reusing the previous day's if available - key: "bazel-${{ matrix.os }}-${{ steps.get-date.outputs.date }}" - restore-keys: "bazel-${{ matrix.os }}-" - uses: ./.github/actions/bazelisk + with: + cache-key: build - name: Build & test env: CONFIG: ${{ matrix.config }} @@ -139,6 +147,7 @@ jobs: - bazel - test - doc + - check-generated-zirgen runs-on: ubuntu-latest steps: - name: Check all job status diff --git a/zirgen/bootstrap/src/main.rs b/zirgen/bootstrap/src/main.rs index 73949ea6..beccc1ff 100644 --- a/zirgen/bootstrap/src/main.rs +++ b/zirgen/bootstrap/src/main.rs @@ -450,12 +450,19 @@ impl Bootstrap { let bazel_args = ["build", "--config", bazel_config(), build_target]; - let mut child = Command::new("bazelisk") + let mut command = Command::new("bazelisk"); + command .args(bazel_args) .stdout(Stdio::inherit()) - .stderr(Stdio::piped()) - .spawn() - .expect("Unable to run bazelisk"); + .stderr(Stdio::piped()); + + if std::env::var("CC").is_ok_and(|cc| cc.contains(" ")) { + // HACK: Rust in CI gives us a CC of "sccache clang", which bazel can't handle. + // TODO: find a better way of handling this. + command.env_remove("CC"); + } + + let mut child = command.spawn().expect("Unable to run bazelisk"); let child_out = BufReader::new(child.stderr.take().unwrap()); let mut rules_used: Vec = Vec::new();