name: ci
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
changes:
name: changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 with:
fetch-depth: 0
- id: filter
env:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
if [ -z "$BASE" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
echo "not a pull request; everything runs"
exit 0
fi
# Named as what cannot affect a build rather than what can, so a new
# kind of file is treated as code until someone says otherwise. Both
# jobs below assert on the dependency tree, so Cargo.toml and
# Cargo.lock matter here as much as any .rs file does.
if git diff --name-only "$BASE"...HEAD \
| grep -qvE '^(README\.md|DESIGN\.md)$'; then
echo "code=true" >> "$GITHUB_OUTPUT"
else
echo "code=false" >> "$GITHUB_OUTPUT"
echo "only the top-level prose changed; the cargo jobs are skipped"
fi
library:
name: library (default features)
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.code == 'true'
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 - run: cargo build --locked --no-default-features
- name: no dependencies without default features
run: |
set -euo pipefail
# `grep -vc` with `|| true`: under pipefail a grep that matches
# nothing exits 1, which is the success case here and would
# otherwise fail the step for having no dependencies.
deps=$(cargo tree --locked --no-default-features --prefix none | sort -u | grep -vc '^beamte ' || true)
if [ "$deps" -ne 0 ]; then
cargo tree --locked --no-default-features
echo "::error::expected no dependencies, found $deps"
exit 1
fi
echo "no dependencies without default features"
- name: the default library links no engine
run: |
set -euo pipefail
tree=$(cargo tree --locked --prefix none)
heavy=$(echo "$tree" | grep -Eic 'wasmtime|wasmer|cranelift|ureq|tree-sitter' || true)
if [ "$heavy" -ne 0 ]; then
echo "$tree" | grep -Ei 'wasmtime|wasmer|cranelift|ureq|tree-sitter'
echo "::error::the default library pulled in an engine or a parser"
exit 1
fi
echo "no engine, no parser, no HTTP stack in the default tree"
- run: cargo build --locked
- run: cargo test --locked
- run: cargo clippy --locked --all-targets -- -D warnings
rules:
name: rules (dev harness)
runs-on: ubuntu-latest
timeout-minutes: 30
needs: changes
if: needs.changes.outputs.code == 'true'
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 - run: cargo fmt --all --check
- run: cargo test --workspace --locked
- run: cargo clippy --workspace --locked --all-targets -- -D warnings