mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-05-18 15:09:51 +00:00
Move IDL files to artifacts/ and add a convention-based CI check that discovers all programs via */methods/guest/src/bin/*.rs and fails if any program is missing its IDL or has one that is out of date.
164 lines
4.2 KiB
YAML
164 lines
4.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
fmt-rs:
|
|
name: Rust Format
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install nightly toolchain for rustfmt
|
|
run: rustup install nightly --profile minimal --component rustfmt
|
|
|
|
- name: Check Rust files are formatted
|
|
run: cargo +nightly fmt --all -- --check
|
|
|
|
fmt-toml:
|
|
name: TOML Format
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install taplo-cli
|
|
run: cargo install --locked taplo-cli
|
|
|
|
- name: Check TOML files are formatted
|
|
run: taplo fmt --check .
|
|
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install-risc0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: "1.94.0"
|
|
components: clippy
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Clippy
|
|
run: RISC0_SKIP_BUILD=1 cargo clippy --workspace --all-targets -- -D warnings
|
|
|
|
unit-tests:
|
|
name: Unit Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install-risc0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: "1.94.0"
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Unit tests
|
|
run: cargo test --workspace --exclude integration_tests
|
|
env:
|
|
RISC0_DEV_MODE: 1
|
|
|
|
integration-tests:
|
|
name: Integration Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install-risc0
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: "1.94.0"
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Integration tests
|
|
run: cargo test -p integration_tests
|
|
env:
|
|
RISC0_DEV_MODE: 1
|
|
|
|
check-idl:
|
|
name: Check IDL
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: "1.94.0"
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Build idl-gen
|
|
run: cargo build -p idl-gen --release
|
|
|
|
- name: Check IDL files are present and up to date
|
|
run: |
|
|
set -e
|
|
failed=0
|
|
for src in $(find . -path '*/methods/guest/src/bin/*.rs' | sort); do
|
|
program=$(basename "$src" .rs)
|
|
idl="artifacts/${program}-idl.json"
|
|
if [ ! -f "$idl" ]; then
|
|
echo "Missing IDL for '${program}' — generate with: cargo run -p idl-gen -- ${src#./} > ${idl}"
|
|
failed=1
|
|
continue
|
|
fi
|
|
./target/release/idl-gen "$src" > /tmp/${program}-idl.json
|
|
if ! diff "$idl" /tmp/${program}-idl.json > /dev/null 2>&1; then
|
|
echo "IDL for '${program}' is out of date — regenerate with: cargo run -p idl-gen -- ${src#./} > ${idl}"
|
|
failed=1
|
|
fi
|
|
done
|
|
exit $failed
|