Skip to content

Build and test in a matrix #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
37 changes: 0 additions & 37 deletions .github/actions/ci_script/action.yml

This file was deleted.

106 changes: 81 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ jobs:
- name: Check formatting
run: cargo fmt --all -- --check

lints:
name: Check lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo clippy --all-targets -- -D clippy::all -D clippy::cargo

docs:
name: Check documentation
runs-on: ubuntu-latest
Expand All @@ -29,17 +37,78 @@ jobs:
- name: Check documentation
run: RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items --no-deps

build:
name: Execute CI script
check:
name: Check for errors
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabi
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabi
- aarch64-unknown-linux-gnu
- i686-unknown-linux-gnu
- loongarch64-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-unknown-freebsd
- riscv64gc-unknown-linux-gnu
toolchain:
- stable
- "1.66.0" # MSRV
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Check source
run: cargo check --target ${{ matrix.target }} --workspace --all-targets
- name: Check all features source
run: cargo check --target ${{ matrix.target }} --all-features --workspace --all-targets

tests-softhsm:
name: Run tests against SoftHSM
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
toolchain:
- stable
- "1.66.0" # MSRV
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: "Installs SoftHSM and execute tests"
uses: ./.github/actions/ci_script
toolchain: ${{ matrix.toolchain }}
- name: Install SoftHSM
run: |
sudo apt-get update -y -qq &&
sudo apt-get install -y -qq libsofthsm2 &&
mkdir /tmp/tokens
echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Check
run: cargo check --target ${{ matrix.target }} --workspace --all-targets
- name: Test script
env:
TEST_PKCS11_MODULE: /usr/lib/softhsm/libsofthsm2.so
SOFTHSM2_CONF: /tmp/softhsm2.conf
TARGET: ${{ matrix.target }}
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
run: ./ci.sh

tests-kryoptic:
name: Run tests against Kryoptic
Expand All @@ -58,27 +127,14 @@ jobs:
RUST_BACKTRACE=1 cargo build --all-features &&
RUST_BACKTRACE=1 cargo test


build-msrv:
name: MSRV - Execute CI script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain on MSRV
uses: actions-rs/toolchain@v1
with:
toolchain: 1.66.0
- name: "Installs SoftHSM and execute tests"
uses: ./.github/actions/ci_script

links:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Link Checker
uses: peter-evans/link-checker@v1
with:
args: -v -r *.md
- name: Fail if there were link errors
run: exit ${{ steps.lc.outputs.exit_code }}
- uses: actions/checkout@v4
- name: Link Checker
uses: peter-evans/link-checker@v1
with:
args: -v -r *.md
- name: Fail if there were link errors
run: exit ${{ steps.lc.outputs.exit_code }}
32 changes: 3 additions & 29 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,10 @@

# Continuous Integration test script

set -euf -o pipefail
set -euxf -o pipefail

pushd cryptoki-sys
RUST_BACKTRACE=1 cargo build --features generate-bindings
cargo build --features generate-bindings
popd

# check formatting before going through all the builds
if cargo fmt --version; then
cargo fmt --all -- --check
fi
if cargo clippy --version; then
cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
fi

RUST_BACKTRACE=1 cargo build

RUST_BACKTRACE=1 cargo build --all-features

RUST_BACKTRACE=1 cargo build --target arm-unknown-linux-gnueabi
RUST_BACKTRACE=1 cargo build --target armv7-unknown-linux-gnueabi
RUST_BACKTRACE=1 cargo build --target armv7-unknown-linux-gnueabihf
RUST_BACKTRACE=1 cargo build --target aarch64-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target i686-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target loongarch64-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target powerpc64-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target powerpc64le-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target riscv64gc-unknown-linux-gnu
RUST_BACKTRACE=1 cargo build --target x86_64-pc-windows-msvc
RUST_BACKTRACE=1 cargo build --target x86_64-apple-darwin
RUST_BACKTRACE=1 cargo build --target aarch64-apple-darwin
RUST_BACKTRACE=1 cargo build --target x86_64-unknown-freebsd

RUST_BACKTRACE=1 cargo test
cargo test --target "$TARGET"
Loading
Loading