Skip to content

Sync with base repo

Sync with base repo #2

Workflow file for this run

name: run-examples
on: [push, pull_request, merge_group]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
run-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install minimal stable
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
cache: false
# See build.yml top-level comment for why save-if is restricted to main.
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
- name: Run all examples
run: |
set -e # Exit immediately if any command fails
cd kernel/examples
# Find all example directories that have a src/main.rs file
for example_dir in */; do
example_dir=${example_dir%/} # Remove trailing slash
# Skip the common directory (it's a library, not an example)
if [ "$example_dir" = "common" ]; then
continue
fi
# Check if this directory has a src/main.rs file
if [ -f "$example_dir/src/main.rs" ]; then
echo "========================================"
echo "Running example: $example_dir"
echo "========================================"
# Special case for write-table: it needs a temp directory
if [ "$example_dir" = "write-table" ]; then
tmp_dir=$(mktemp -d)
cargo run --locked --manifest-path "$example_dir/Cargo.toml" --release -- "$tmp_dir"
rm -r "$tmp_dir"
# Special case for inspect-table: it needs an operation/subcommand, run each one
elif [ "$example_dir" = "inspect-table" ]; then
for operation in table-version metadata schema scan-metadata actions; do
echo " Running inspect-table with operation: $operation"
cargo run --locked --manifest-path "$example_dir/Cargo.toml" --release -- ../tests/data/table-without-dv-small $operation
done
# Special case for read-table-changes: skip running it in CI as it needs a specific CDF-enabled table
# but still verify it compiles
# TODO: Add a suitable test table for CDF
elif [ "$example_dir" = "read-table-changes" ]; then
echo "Building read-table-changes (skipping run - requires CDF-enabled table)"
cargo build --locked --manifest-path "$example_dir/Cargo.toml" --release
else
# All other examples run with the test table path
cargo run --locked --manifest-path "$example_dir/Cargo.toml" --release -- ../tests/data/table-without-dv-small
fi
echo ""
fi
done