Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: setup rust
description: Setup rust toolchain and caches.

inputs:
toolchain-version:
description: Rust toolchain version to use.
required: true

builder-triple:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is "builder-triple" (vs "target-triple") inspired by nixos-rebuild's --build-host vs --target-host, or a Canadian cross-compiler setup? Definitely like it, just curious where the terminology came from!

Copy link
Copy Markdown
Collaborator Author

@npry npry Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wanted to clearly separate the builder's target-triple from the target-machine target-triple — just in case we add cross-compilation (edit: or moreover, I specifically wanted the target-triple for the installed toolchain on the builder, since that's what should define what cache key to use, even if there are other targets installed on that toolchain)

description: Target-triple of builder system.
required: true

targets:
description: Comma-separated list of additional targets to install.
default: ""

components:
description: Comma-separated list of components installed with the toolchain.
default: ""
required: true

cache-key:
description: Cache-busting key. If you set this to anything other than its default, it will bust all caches and prevent sharing caches with other workflows.
required: true
default: init

outputs:
toolchain_cache_hit:
description: Did the toolchain cache hit?
value: ${{ steps.cache-rust-toolchain.outputs.cache-hit }}

target_cache_hit:
description: Did the target cache hit?
value: ${{ steps.cache-rust-target.outputs.cache-hit }}

runs:
using: composite

steps:
- name: Cache Rust toolchain
id: cache-rust-toolchain
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
key: rust-toolchain-${{ inputs.cache-key }}-${{ inputs.builder-triple }}-${{ inputs.toolchain-version }}-targets=${{ env.targets }}-components=${{ case(inputs.components == '', 'none', inputs.components) }}
restore-keys:
rust-toolchain-${{ inputs.cache-key }}-${{ inputs.builder-triple }}-${{ inputs.toolchain-version }}-targets=${{ env.targets }}-components=
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL these are prefix-matched, not required to be absolute.

rust-toolchain-${{ inputs.cache-key }}-${{ inputs.builder-triple }}-${{ inputs.toolchain-version }}-targets=

- name: Install Rust toolchain
id: install-toolchain
if: steps.cache-rust-toolchain.outputs.cache-hit != 'true' || inputs.builder-triple == 'nightly' || inputs.builder-triple == 'beta' || inputs.builder-triple == 'stable'
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master 4/22/2026
with:
toolchain: ${{ inputs.toolchain-version }}
components: ${{ inputs.components }}
targets: ${{ env.targets }}

- name: Cache target/
id: cache-rust-target
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
target/
key: rust-target-${{ inputs.cache-key }}-${{ inputs.builder-triple }}-${{ inputs.toolchain-version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys:
rust-target-${{ inputs.cache-key }}-${{ inputs.builder-triple }}-${{ inputs.toolchain-version }}-
34 changes: 8 additions & 26 deletions .github/workflows/c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@ on:
permissions:
contents: read

env:
# cache-busting key -- change it if the build changes in a way that invalidates old
# cached state
cache_key: init

jobs:
build_test:
name: build (rust ${{ matrix.rust_toolchain.label }}, ${{ matrix.target.runner }})
runs-on: ${{ matrix.target.runner }}
name: build (rust ${{ matrix.rust_toolchain.label }}, ${{ matrix.build.runner }})
runs-on: ${{ matrix.build.runner }}

strategy:
matrix:
rust_toolchain:
- version: 1.94.0
label: latest

target:
build:
- triple: x86_64-unknown-linux-gnu
runner: linux-x86_64-16cpu
- triple: aarch64-unknown-linux-gnu
Expand All @@ -44,25 +39,12 @@ jobs:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Cache Rust
id: cache-rust-c
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
key: ${{ matrix.target.triple }}-rs-c-${{ env.cache_key }}-${{ matrix.rust_toolchain.version }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install Rust toolchain
id: install-toolchain
if: steps.cache-rust-c.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master 4/22/2026
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.rust_toolchain.version }}
toolchain-version: ${{ matrix.rust_toolchain.version }}
builder-triple: ${{ matrix.build.triple }}

- name: Build examples
run: make -C examples
74 changes: 33 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up cache
id: cache-cargo
uses: actions/cache@v5
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
# the 'cargo+$SUFFIX' below is a cache-busting key -- change it if the build changes in a way that
# invalidates old cached state.
key: ${{ matrix.target.runner }}-cargo+machete-${{ matrix.toolchain.version }}-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
id: install-toolchain
if: steps.cache-cargo.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain.version }}
toolchain-version: ${{ matrix.toolchain.version }}
builder-triple: ${{ matrix.target.triple }}
components: clippy
- name: Install nightly Rust toolchain
id: install-nightly-toolchain
if: steps.cache-cargo.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- name: binstall
uses: cargo-bins/cargo-binstall@main
- name: Install cargo-deny
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: cargo binstall --no-confirm cargo-deny
- name: Check for unused dependencies (cargo machete)
uses: bnjbvr/cargo-machete@main
with:
args: "--with-metadata"
- name: Dependency audit (cargo deny)
run: cargo deny --workspace --all-features check all
- name: Check formatting (cargo fmt)
run: cargo +nightly fmt --check
- name: Custom workspace checks
run: cargo +${{ matrix.toolchain.version }} run -p checks
- name: Lint lib targets (cargo clippy)
run: |-
cargo +${{ matrix.toolchain.version }} clippy \
Expand All @@ -113,3 +77,31 @@ jobs:
run: cargo +${{ matrix.toolchain.version }} build --all-features --workspace --release --verbose --all-targets --target ${{ matrix.target.triple }}
- name: Docs (cargo doc)
run: cargo +${{ matrix.toolchain.version }} doc --workspace --no-deps --all-features --target ${{ matrix.target.triple }}

arch_independent:
name: arch-independent checks
runs-on: linux-x86_64-16cpu
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain-version: nightly
builder-triple: x86_64-unknown-linux-gnu
components: rustfmt
- name: binstall
uses: cargo-bins/cargo-binstall@main
- name: Install cargo-deny
run: command -v cargo-deny || cargo binstall --no-confirm cargo-deny
- name: Check for unused dependencies (cargo machete)
uses: bnjbvr/cargo-machete@main
with:
args: "--with-metadata"
- name: Dependency audit (cargo deny)
run: cargo deny --workspace --all-features check all
- name: Check formatting (cargo fmt)
run: cargo +nightly fmt --check
- name: Custom workspace checks
run: cargo run -p checks
48 changes: 11 additions & 37 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,19 @@ jobs:
ts_elixir/deps/
key: ${{ runner.os }}-mix-${{ env.cache_key }}-elixir-${{ matrix.elixir.version }}-otp-${{ matrix.otp.version }}-${{ hashFiles('**/mix.lock') }}

- name: Cache Rust
id: cache-rust-elixir
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
key: ${{ runner.os }}-elixir-rs-${{ env.cache_key }}-${{ matrix.rust_toolchain.version }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install elixir
id: install-elixir
uses: erlef/setup-beam@v1.24.0
with:
otp-version: ${{ matrix.otp.version }}
elixir-version: ${{ matrix.elixir.version }}

- name: Install Rust toolchain
id: install-rust-toolchain
if: steps.cache-rust-elixir.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ matrix.rust_toolchain.version }}
toolchain-version: ${{ matrix.rust_toolchain.version }}
builder-triple: x86_64-linux-unknown-gnu

- name: Install dependencies
run: mix deps.get
Expand Down Expand Up @@ -166,7 +153,7 @@ jobs:
name: publish
runs-on: linux-x86_64-16cpu
needs: build_test
if: ${{ startsWith(github.ref, 'refs/tags/*') || github.event_name == 'workflow_dispatch' }}
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}

environment: *hex_environment

Expand All @@ -190,32 +177,19 @@ jobs:
ts_elixir/deps/
key: ${{ runner.os }}-mix-${{ env.cache_key }}-elixir-${{ env.latest_elixir }}-otp-${{ env.latest_otp }}-${{ hashFiles('**/mix.lock') }}

- name: Cache Rust
id: cache-rust-elixir
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
key: ${{ runner.os }}-elixir-rs-${{ env.cache_key }}-${{ env.latest_rust }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install elixir
id: install-elixir
uses: erlef/setup-beam@v1.24.0
with:
otp-version: ${{ env.latest_otp }}
elixir-version: ${{ env.latest_elixir }}

- name: Install Rust toolchain
id: install-rust-toolchain
if: steps.cache-rust-elixir.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ env.latest_rust }}
toolchain-version: ${{ matrix.rust_toolchain.version }}
builder-triple: x86_64-linux-unknown-gnu

- name: Install dependencies
run: mix deps.get
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,25 @@ jobs:
- os: linux
runner: linux-arm64-16cpu
target: aarch64
triple: aarch64-unknown-linux-gnu
- os: linux
runner: linux-x86_64-16cpu
target: x86_64
triple: x86_64-unknown-linux-gnu
- os: macOS
runner: macos-26
target: aarch64
triple: aarch64-apple-darwin

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Rust cache
id: cache-cargo
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
key: ${{ matrix.platform.os }}-python-${{ env.cache_key }}-${{ env.rust_toolchain }}-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}
toolchain-version: ${{ env.rust_toolchain }}
builder-triple: ${{ matrix.platform.triple }}
- name: Install python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
Expand Down