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
247 changes: 190 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,224 @@
name: ci
# ======================================================
# Continuous Integration: making sure the codebase works
# ======================================================
#
# This workflow tests modifications to Cascade, ensuring that Cascade can be
# used by others successfully. It verifies certain aspects of the codebase,
# such as the formatting and feature flag combinations, and runs the full test
# suite. It runs on Ubuntu only.

name: CI

# When the worflow runs
# ---------------------
on:
push:
branches:
- main
# Execute when a pull request is (re-) opened or its head changes (e.g. new
# commits are added or the commit history is rewritten) ... but only if
# build-related files change.
pull_request:
paths:
- '**.rs'
- 'Cargo.{toml,lock}'
- '.github/workflows/ci.yml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'etc/*.toml'
pull_request:
- '.github/workflows/ci.yml'

# If a pull request is merged, at least one commit is added to the target
# branch. If the target is another pull request, it will be caught by the
# above event. We miss PRs that merge to a non-PR branch, except for the
# 'main' branch.

# Execute when a commit is pushed to 'main' (including merged PRs) or to a
# release tag ... but only if build-related files change.
push:
branches:
- main
- 'main'
- 'releases/**'
paths:
- '**.rs'
- 'Cargo.{toml,lock}'
- '.github/workflows/ci.yml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'etc/*.toml'
- '.github/workflows/ci.yml'

# Rebuild 'main' every week. This will account for changes to dependencies
# and to Rust, either of which can trigger new failures. Rust releases are
# every 6 weeks, on a Thursday; this event runs every Friday.
schedule:
- cron: '0 10 * * FRI'

defaults:
run:
shell: bash

# Jobs
# ----------------------------------------------------------------------------
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [1.84.0, stable, beta, nightly]

# Test with no features, default features ("") and all features.
# Ordered fewest features to most features.
args: ["--no-default-features", "", "--all-features"]
# Check Formatting
# ----------------
#
# NOTE: This job is run even if no '.rs' files have changed. Inserting such
# a check would require using a separate workflow file or using third-party
# actions. Most commits do change '.rs' files, and 'cargo-fmt' is pretty
# fast, so optimizing this is not necessary.
check-fmt:
name: Check formatting
runs-on: ubuntu-latest
steps:

# Load the repository.
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: hecrj/setup-rust-action@v2

# 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:
rust-version: ${{ matrix.rust }}
- run: cargo build --verbose ${{ matrix.args }}
toolchain: stable
components: rustfmt
cache: false

test:
name: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [1.84.0, stable, beta, nightly]
# Do the actual formatting check.
- name: Check formatting
run: cargo fmt --all -- --check

# Test with no features, default features ("") and all features.
# Ordered fewest features to most features.
args: ["--no-default-features", "", "--all-features"]
# Determine MSRV
# --------------
#
# The MSRV needs to be determined as we will test Cascade against the Rust
# compiler at that version.
determine-msrv:
name: Determine MSRV
runs-on: ubuntu-latest
outputs:
msrv: ${{ steps.determine-msrv.outputs.msrv }}
steps:

# Load the repository.
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: hecrj/setup-rust-action@v2

# Determine the MSRV.
- name: Determine MSRV
id: determine-msrv
run: |
msrv=`cargo metadata --no-deps --format-version 1 | jq -r '.packages[]|select(.name=="cascade")|.rust_version'`
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"

# TODO: Add feature flag checks, when we add feature flags.

# Check Minimal Versions
# ----------------------
#
# Ensure that Cascade compiles with the oldest compatible versions of all
# packages, even those Cascade depends upon indirectly.
check-minimal-versions:
name: Check minimal versions
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-D warnings"
steps:

# Load the repository.
- name: Checkout repository
uses: actions/checkout@v4

# Set up the Rust toolchain.
- name: Set up Rust nightly
id: setup-rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: ${{ matrix.rust }}
- run: cargo test --verbose ${{ matrix.args }}
toolchain: nightly, stable
cache: false

# TODO: Cache minimal-version dependencies?

# Lock all dependencies to their minimal versions.
- name: Lock dependencies to minimal versions
run: cargo +nightly update -Z minimal-versions

# Check that Cascade compiles.
#
# NOTE: This does not benefit from the 'target' folder cached by a 'cargo
# check --all-features --all-targets' execution. It may be worthwhile to
# cache this 'target' folder separately (TODO).
- name: Check
run: cargo check --all-targets --all-features --locked

# Clippy
# ------
#
# We run Clippy separately, and only on nightly Rust because it offers a
# superset of the lints.
#
# 'cargo clippy' and 'cargo build' can share some state for fast execution,
# but it's faster to execute them in parallel than to establish an ordering
# between them.
clippy:
name: clippy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable]
name: Clippy
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-D warnings"
steps:

# Load the repository.
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: hecrj/setup-rust-action@v2

# Set up the Rust toolchain.
- name: Set up Rust nightly
id: setup-rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: ${{ matrix.rust }}
- run: cargo clippy --all -- -D warnings
toolchain: nightly
components: clippy
cache: false

fmt:
name: fmt
runs-on: ${{ matrix.os }}
# TODO: Restore a cache of dependencies and 'target'.

# Do the actually Clippy run.
- name: Check Clippy
run: cargo +nightly clippy --all-targets --all-features

# Test
# ----
#
# Ensure that Cascade compiles and its test suite passes, on the span of
# supported operating systems and Rust versions.
test:
name: Test
needs: determine-msrv
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable]
rust: ["${{ needs.determine-msrv.outputs.msrv }}", stable, nightly]
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-D warnings"
steps:

# Load the repository.
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: hecrj/setup-rust-action@v2

# Set up the Rust toolchain.
- name: Set up Rust ${{ matrix.rust }}
id: setup-rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: ${{ matrix.rust }}
- run: cargo fmt --check
toolchain: ${{ matrix.rust }}
cache: false

# TODO: Restore a cache of dependencies and 'target'.

# Build and run the test suite.
- name: Test
run: cargo test --all-targets

# Test docs.
- name: Test docs
run: cargo test --doc

# TODO: Build a cache.
13 changes: 1 addition & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ repository = "https://github.com/NLnetLabs/cascade"
license = "BSD-3-Clause"

version = "0.1.0-alpha5"
rust-version = "1.84"
edition = "2021"
rust-version = "1.85"
edition = "2024"


[package]
Expand Down Expand Up @@ -47,7 +47,7 @@ panic = "abort"
#
# TODO: Maintenance?
[workspace.dependencies.camino]
version = "1.1.0"
version = "1.1.6"

# 'clap' is a command-line argument parsing library.
#
Expand Down Expand Up @@ -101,7 +101,6 @@ toml = "0.8"
axum = { version = "0.8.4", default-features = false, features = ["http2", "query", "original-uri", "json", "tokio"] }

# From Rotonda
async-trait = "0.1"
crossbeam-utils = "0.8"
serde_json = "1.0"
serde_with = "3"
Expand All @@ -122,6 +121,22 @@ tempfile = "3.21.0"
tracing.workspace = true
tracing-subscriber.workspace = true

# The 'lazy_static' library, which is pulled in by a subtle transitive
# dependency, is specified with a low minimal version. The oldest allowed
# versions cause compilation errors with recent Rust compilers. We manually
# increase the minimum version by registering it as a dependency, even though we
# don't use it ourselves.
#
# tracing-subscriber 0.3.20, feature "registry"
# depends on: sharded-slab ^0.1.4
# depends on: lazy_static ^1
#
# Ideally, this would be fixed in a new version of 'sharded-slab'. But
# as of 2025-12-09, sharded-slab appears to be unmaintained. See
# <https://github.com/tokio-rs/tracing/issues/3436> for its use in
# 'tracing-subscriber'.
lazy_static = { version = "1.5" }

# support-color checks various environment variables and terminal settings for
# whether ANSI escape codes should be emitted. It is also used by `anstream`
# (and therefore `clap`).
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt;
use std::net::SocketAddr;

use clap::builder::PossibleValue;
use clap::Parser;
use clap::builder::PossibleValue;
use tracing::level_filters::LevelFilter;

use super::client::CascadeApiClient;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use futures_util::TryFutureExt;

use crate::{
api::{self, ChangeLogging, ChangeLoggingResult, TraceTarget},
client::{format_http_error, CascadeApiClient},
client::{CascadeApiClient, format_http_error},
println,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/hsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
HsmServerAdd, HsmServerAddError, HsmServerAddResult, HsmServerGetResult,
HsmServerListResult, KmipServerState, PolicyInfo, PolicyInfoError, PolicyListResult,
},
client::{format_http_error, CascadeApiClient},
client::{CascadeApiClient, format_http_error},
println,
};

Expand Down
Loading