mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-08-17 21:15:41 +02:00
[CI] Check required-features of examples in parallel
This commit is contained in:
+78
-19
@@ -64,8 +64,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Set up the Rust toolchain.
|
||||
#
|
||||
# Disable the cache since it's not relevant for formatting.
|
||||
- name: Set up Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
@@ -100,6 +98,30 @@ jobs:
|
||||
msrv=`cargo metadata --no-deps --format-version 1 | jq -r '.packages[]|select(.name=="domain")|.rust_version'`
|
||||
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Determine Examples
|
||||
# ------------------
|
||||
#
|
||||
# Checks need to be run for every example, and they are generated into a
|
||||
# strategy matrix so that they can run in parallel.
|
||||
determine-examples:
|
||||
name: Determine Examples
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
examples: ${{ steps.determine-examples.outputs.examples }}
|
||||
steps:
|
||||
|
||||
# Load the repository.
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Determine the examples.
|
||||
- name: Determine examples
|
||||
id: determine-examples
|
||||
run: |
|
||||
examples=`cargo metadata --no-deps --format-version 1 \
|
||||
| jq -c '[.packages[].targets[]|select(.kind|any(.=="example"))|{example:.name,features:(.["required-features"]|join(","))}]'`
|
||||
echo "examples=$examples" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Check Feature Flags
|
||||
# -------------------
|
||||
#
|
||||
@@ -109,6 +131,15 @@ jobs:
|
||||
check-feature-flags:
|
||||
name: Check feature flags
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
features:
|
||||
- ""
|
||||
- "unstable-crypto-sign"
|
||||
- "ring"
|
||||
- "openssl"
|
||||
- "unstable-crypto-sign,ring"
|
||||
- "unstable-crypto-sign,openssl"
|
||||
steps:
|
||||
|
||||
# Load the repository.
|
||||
@@ -135,24 +166,52 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ steps.setup-rust.outputs.cachekey }}
|
||||
|
||||
# Do the actual feature flag checks.
|
||||
#
|
||||
# NOTE: This does not benefit from the 'target' folder cached by a 'cargo
|
||||
# check --all-features --all-targets' execution. Due to the minimal
|
||||
# dependency set, it still runs fairly quickly.
|
||||
- name: Check empty feature set
|
||||
run: cargo check --all-targets --no-default-features
|
||||
- name: Check features "${{ matrix.features }}"
|
||||
run: cargo check --all-targets --no-default-features --features=${{ matrix.features }}
|
||||
|
||||
# Check the required feature flags for every example.
|
||||
- name: Check required features of examples
|
||||
run: |
|
||||
# Scrape crate metadata and construct the right 'check' commands.
|
||||
# Cargo deosn't have an option to select the right features for us.
|
||||
# See: https://github.com/rust-lang/cargo/issues/4663
|
||||
cargo metadata --no-deps --format-version 1 \
|
||||
| jq -r '.packages[].targets[]|select(.kind|any(.=="example"))|{name,features:(.["required-features"]|join(","))}|"\(.name) \(.features)"' \
|
||||
| while read -r name features; do
|
||||
cargo check --example=$name --no-default-features --features=$features
|
||||
done
|
||||
# Check Examples
|
||||
# --------------
|
||||
#
|
||||
# While other jobs are already checking that examples compile with the full
|
||||
# feature set, this will check that the 'required-features' specified for
|
||||
# every example is also correct.
|
||||
check-examples:
|
||||
name: Check examples
|
||||
runs-on: ubuntu-latest
|
||||
needs: determine-examples
|
||||
strategy:
|
||||
matrix:
|
||||
example: []
|
||||
features: []
|
||||
include: ${{ fromJSON(needs.determine-examples.outputs.examples) }}
|
||||
steps:
|
||||
|
||||
# Load the repository.
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Set up the Rust toolchain.
|
||||
- name: Set up Rust
|
||||
id: setup-rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
cache: false
|
||||
|
||||
# Restore a cache of dependencies and 'target'.
|
||||
- name: Restore a dependency cache
|
||||
id: cache-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo
|
||||
target/
|
||||
# Cache by OS and Rust version.
|
||||
key: ${{ runner.os }}-${{ steps.setup-rust.outputs.cachekey }}
|
||||
|
||||
# Check examples against their minimal feature flags.
|
||||
- name: Check example "${{ matrix.example }}"
|
||||
run: cargo check --example=${{ matrix.example }} --no-default-features --features=${{ matrix.features }}
|
||||
|
||||
# Check Minimal Versions
|
||||
# ----------------------
|
||||
|
||||
Reference in New Issue
Block a user