Skip to content

Commit

Permalink
Check fib and calculator generated files in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
shkoo committed Dec 19, 2024
1 parent bbc8543 commit 68ce664
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 19 deletions.
20 changes: 20 additions & 0 deletions .github/actions/bazelisk/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 25 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ 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: fib generated files up to date
run: cargo bootstrap -- --check fib
- name: calculator generated files up to date
run: cargo bootstrap -- --check calculator

bazel:
runs-on: [self-hosted, prod, cpu, "${{ matrix.os }}"]
strategy:
Expand All @@ -52,23 +74,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 }}
Expand Down Expand Up @@ -139,6 +148,7 @@ jobs:
- bazel
- test
- doc
- check-generated-zirgen
runs-on: ubuntu-latest
steps:
- name: Check all job status
Expand Down
15 changes: 11 additions & 4 deletions zirgen/bootstrap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> = Vec::new();
Expand Down

0 comments on commit 68ce664

Please sign in to comment.