mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 20:14:31 +01:00
- scripts/ci-workspace-tests.sh holds every Workspace test step. When the selection reaches a replay-audit crate, the Linux leg builds once in gate.yml's build job, writes three nextest archives (every selected test, the audit's UI crates, the default-feature crates), runs the doctests, and three shard legs run the archives in parallel. Any other selection, and every macOS and Windows leg, builds and runs in one leg as before. - .config/cargo-dev.toml is the dev-profile tuning tools/cl passes locally (dependencies at opt-level 2, craft-theme/behavior/proof at 1, lto off); every CI test build passes it too, with .config/cargo-ci.toml adding the numeric crates at opt-level 1. The Workspace legs' cache entries are named after a hash of both files. Cargo.toml's profiles are unchanged. - nightly.yml builds through the same script and also starts the full tests on next.
264 lines
13 KiB
YAML
264 lines
13 KiB
YAML
name: Workspace
|
|
|
|
on:
|
|
push:
|
|
branches: [main, next]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
# A full run on main every 6 hours that is never cancelled, so the caches are saved while pushes
|
|
# to main cancel each other. The midnight run builds the Linux leg from source (`native`).
|
|
schedule:
|
|
- cron: "17 0 * * *"
|
|
- cron: "17 6,12,18 * * *"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
# A pull request, main and next each have one group, so a newer push cancels the run it
|
|
# supersedes; the newest push's run still tests everything before it. Every other run (a release
|
|
# tag, a manual run, the scheduled run, nightly.yml's run on next) gets a group of its own and is
|
|
# neither cancelled nor replaced while queued: a release run always finishes, the scheduled run
|
|
# saves the caches, and next gets one complete macOS and Windows run a day.
|
|
group: workspace-${{ (github.event_name == 'pull_request' || github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'push' && github.ref == 'refs/heads/next') && github.ref || github.run_id }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'push' && github.ref == 'refs/heads/next' }}
|
|
|
|
jobs:
|
|
# Whether this run needs the macOS and Windows legs, and which tests every leg runs
|
|
# (craft-common-actions' select-platforms). A pull request runs the Linux legs only, unless it
|
|
# has the full-ci label (see native-platforms); every other event runs the macOS and Windows legs
|
|
# too. The tests are those of the crates a change reaches: the crates that own a changed file,
|
|
# the crates whose Cargo.toml declares a read of it
|
|
# (`[package.metadata.craft] reads`, which this job checks is complete), and every crate that
|
|
# depends on those. The build setup, a crate's own Cargo.toml or a file outside the crates other
|
|
# than documentation runs every test; documentation alone runs none. The full-ci label runs
|
|
# everything from the next push or manual run; every other event runs everything.
|
|
platforms:
|
|
name: select platforms
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
platform: ${{ steps.select.outputs.platform }}
|
|
tests: ${{ steps.select.outputs.tests }}
|
|
filter: ${{ steps.select.outputs.filter }}
|
|
audit: ${{ steps.audit.outputs.audit }}
|
|
profile: ${{ steps.audit.outputs.profile }}
|
|
steps:
|
|
- name: Harden runner
|
|
uses: step-security/harden-runner@v2.22.4
|
|
with:
|
|
egress-policy: audit
|
|
# The merge commit and its first parent.
|
|
- uses: actions/checkout@v7.0.1
|
|
if: github.event_name == 'pull_request'
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 2
|
|
- id: select
|
|
uses: storytold/craft-common-actions/actions/select-platforms@0bef64f155fcea81edbd9542381777358bfbdcf4
|
|
with:
|
|
os: '["ubuntu-latest","windows-latest","macos-latest"]'
|
|
select-os: '["windows-latest","macos-latest"]'
|
|
select-tests: true
|
|
label: full-ci
|
|
# Whether the selection reaches a replay-audit crate, which runs the Linux leg as a build job
|
|
# and three test shards (see `native`), and the hash of the profile overrides every test build
|
|
# passes (scripts/ci-workspace-tests.sh), which names the Workspace legs' cache entries:
|
|
# rust-cache's key does not hash these files, and an entry built with other overrides would be
|
|
# rebuilt in full on every run. Other events than a pull request check out only these files.
|
|
- uses: actions/checkout@v7.0.1
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
persist-credentials: false
|
|
sparse-checkout: |
|
|
scripts/ci-workspace-tests.sh
|
|
.config/cargo-*.toml
|
|
sparse-checkout-cone-mode: false
|
|
- id: audit
|
|
env:
|
|
CRAFT_TESTS: ${{ steps.select.outputs.tests }}
|
|
CRAFT_TEST_FILTER: ${{ steps.select.outputs.filter }}
|
|
CRAFT_TEST_SKIP: ${{ steps.select.outputs.skip }}
|
|
run: |
|
|
echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT"
|
|
echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT"
|
|
|
|
# The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each
|
|
# main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo
|
|
# rebuilds only the crates a change reaches. `cache-prune` keeps the newest entry. The midnight
|
|
# scheduled run builds from source (`cold-build`) and starts the entry afresh. next has an entry
|
|
# of its own, since main's is built from different code and lockfile and a pull request into next
|
|
# rebuilt nearly everything from it (15.5 minutes): nightly.yml's daily manual run on next builds
|
|
# from source and saves it (`cache-save-on-dispatch`), and pull requests into next restore it
|
|
# before main's. The macOS and Windows legs keep a dependency-only entry: their workspace crates
|
|
# would not fit the 10 GB cache budget beside Linux's. The lint legs keep no cache
|
|
# (`lint-cache: false`) for the same reason; a cold lint leg is still shorter than its gate leg.
|
|
native:
|
|
name: Workspace
|
|
needs: platforms
|
|
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
|
with:
|
|
os: '["ubuntu-latest"]'
|
|
cache-workspace-crates: true
|
|
cache-save-on-dispatch: true
|
|
cache-version: &cache-version v2-${{ needs.platforms.outputs.profile }}
|
|
cold-build: ${{ github.event.schedule == '17 0 * * *' || github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/next' }}
|
|
lint-cache: false
|
|
# The vendored crates are on the workspace `exclude` list, so unreached-rs has no module tree for them.
|
|
unreached-rs-allow: |
|
|
**/fixtures/**
|
|
vendor/**
|
|
timeout-minutes: &timeout 120
|
|
# Every leg runs its tests with nextest, and its doctests with cargo test (.config/nextest.toml).
|
|
tools: &tools cargo-nextest@0.9.150
|
|
packages: mesa-vulkan-drivers libvulkan1
|
|
craft-fonts-ref: &craft-fonts b076417b5880bd4154bd22f00695b1d28c6bea83
|
|
linux-env: WGPU_BACKEND=vulkan
|
|
# Test binaries without debug info or symbols: about a third of the size, and a panic still
|
|
# names its file and line.
|
|
dev-strip: true
|
|
# The fuzz-style tests run a fraction of their cases here: every hostile-input hammer and
|
|
# sweep 1/8 (craft-testkit's CRAFT_HOSTILE_DIVISOR), every proptest without its own case
|
|
# count 64 cases instead of 256. nightly.yml runs them all in full.
|
|
# CRAFT_TESTS and CRAFT_TEST_FILTER are the `platforms` job's test selection.
|
|
env: &env |
|
|
CRAFT_PRINT_REQUIRE_QUEUE=0
|
|
CRAFT_HOSTILE_DIVISOR=8
|
|
PROPTEST_CASES=64
|
|
CRAFT_TESTS=${{ needs.platforms.outputs.tests }}
|
|
CRAFT_TEST_FILTER=${{ needs.platforms.outputs.filter }}
|
|
setup-command: &setup bash scripts/ci-test-inputs.sh
|
|
# The PhotoCraft corpora, keyed on the script that pins them: a hit skips the PhotoCraft
|
|
# checkout and its xtask build (1:51 on Windows).
|
|
cache-paths: &cache-paths .test-inputs/photocraft/corpus
|
|
cache-key: &cache-key photocraft-corpus
|
|
cache-key-files: &cache-key-files scripts/ci-test-inputs.sh
|
|
# A `lint (<os>)` leg beside each `gate (<os>)` leg, so clippy is off the tests' critical path.
|
|
lint-command: &lint |
|
|
if [ "$RUNNER_OS" = Linux ]; then
|
|
python3 scripts/test-workspace-concurrency.py
|
|
python3 scripts/test-workspace-tests.py
|
|
fi
|
|
# One rustfmt call gets every source root of the workspace, which is longer than
|
|
# Windows allows for a command line (os error 206). rustfmt's result is the same on
|
|
# every system, so the Linux and macOS legs check it.
|
|
if [ "$RUNNER_OS" != Windows ]; then
|
|
cargo fmt --check
|
|
fi
|
|
cargo clippy --workspace --all-targets --locked -- -D warnings
|
|
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
|
# A selection that reaches a replay-audit crate builds once in a `build` job, which writes
|
|
# three nextest archives and then runs the doctests; three shard legs run them in parallel:
|
|
# every selected test, the replay audit, and the default-feature crates. Any other selection
|
|
# (and every macOS and Windows leg) builds and runs in one leg. scripts/ci-workspace-tests.sh
|
|
# holds every step.
|
|
test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}
|
|
shard-archives: ${{ needs.platforms.outputs.audit == 'true' }}
|
|
archive-command: ${{ needs.platforms.outputs.audit == 'true' && 'bash scripts/ci-workspace-tests.sh archive' || '' }}
|
|
after-archive-command: bash scripts/ci-workspace-tests.sh doctest
|
|
shard-command: bash scripts/ci-workspace-tests.sh shard
|
|
command: &command bash scripts/ci-workspace-tests.sh run
|
|
|
|
# The macOS and Windows legs, with the Linux leg's inputs. They take 1.5-2 hours against the Linux
|
|
# leg's 15-40 minutes, so a pull request does not wait for them: they run after the merge, on
|
|
# every push to main and next, on main's scheduled runs and on nightly.yml's daily run on next.
|
|
# A pull request that needs them before it merges gets the full-ci label.
|
|
native-platforms:
|
|
name: Workspace
|
|
needs: platforms
|
|
if: needs.platforms.outputs.platform == 'true' && (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci'))
|
|
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
|
with:
|
|
os: '["windows-latest","macos-latest"]'
|
|
lint-cache: false
|
|
cache-version: *cache-version
|
|
timeout-minutes: *timeout
|
|
tools: *tools
|
|
craft-fonts-ref: *craft-fonts
|
|
dev-strip: true
|
|
# No debuginfo on Windows: writing PDBs for every test binary is a large part of its link
|
|
# time. A panic still names its file and line; only backtrace frames lose theirs, and the
|
|
# Linux and macOS legs keep line tables.
|
|
windows-env: |
|
|
CRAFT_PRINT_REQUIRE_QUEUE=1
|
|
CARGO_PROFILE_DEV_DEBUG=0
|
|
env: *env
|
|
setup-command: *setup
|
|
cache-paths: *cache-paths
|
|
cache-key: *cache-key
|
|
cache-key-files: *cache-key-files
|
|
lint-command: *lint
|
|
command: *command
|
|
|
|
# Each main run's Linux leg saves a rolling cache entry of its own (`cache-workspace-crates`), as
|
|
# does the daily manual run on next, and every run restores only the newest. This deletes the
|
|
# older ones of the run's branch as soon as the Linux leg is done, instead of leaving them to the
|
|
# 10 GB budget's eviction, which would evict other entries too. The only job with
|
|
# `actions: write`; it checks out and runs nothing from the repository.
|
|
cache-prune:
|
|
name: cache prune
|
|
needs: native
|
|
if: ${{ !cancelled() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next') }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
actions: write
|
|
steps:
|
|
- name: Harden runner
|
|
uses: step-security/harden-runner@v2.22.4
|
|
with:
|
|
egress-policy: audit
|
|
- name: Delete all but the newest rolling entry of each job and runner
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
REPO: ${{ github.repository }}
|
|
REF: ${{ github.ref }}
|
|
run: |
|
|
set -euo pipefail
|
|
# `<version>-rust-<profile>-<job>-crates-<os>-<arch>-<run>-<attempt>-...`, newest first.
|
|
gh cache list --repo "$REPO" --ref "$REF" --limit 100 --sort created_at --order desc --json id,key \
|
|
--jq '.[] | "\(.id) \(.key)"' > "$RUNNER_TEMP/caches"
|
|
declare -A kept
|
|
while read -r id key; do
|
|
[[ "$key" =~ ^.+-rust-[0-9a-f]{64}-(.+-crates-[A-Za-z_]+-[a-z0-9]+)-[0-9]+-[0-9]+- ]] || continue
|
|
entry=${BASH_REMATCH[1]}
|
|
if [ -n "${kept[$entry]:-}" ]; then
|
|
echo "delete $key"
|
|
gh cache delete "$id" --repo "$REPO"
|
|
else
|
|
kept[$entry]=1
|
|
echo "keep $key"
|
|
fi
|
|
done < "$RUNNER_TEMP/caches"
|
|
|
|
msrv:
|
|
name: Rust 1.95
|
|
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
|
with:
|
|
# Its own dependency-cache entry: the calls in this file share one job id, so without a name
|
|
# they would write the same key.
|
|
cache-name: msrv
|
|
os: '["ubuntu-latest"]'
|
|
toolchain: 1.95.0
|
|
targets: ""
|
|
tools: ""
|
|
craft-fonts-ref: ""
|
|
require-craft-fonts: false
|
|
timeout-minutes: 15
|
|
dev-debug: ""
|
|
command: cargo check --workspace --lib --all-features --locked
|
|
|
|
wasm:
|
|
name: UI and settings WASM
|
|
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
|
with:
|
|
cache-name: wasm
|
|
os: '["ubuntu-latest"]'
|
|
targets: wasm32-unknown-unknown
|
|
tools: ""
|
|
craft-fonts-ref: ""
|
|
require-craft-fonts: false
|
|
timeout-minutes: 15
|
|
command: cargo check -p craft-ui -p craft-settings --all-features --locked --target wasm32-unknown-unknown
|