Skip to content

Commit bf85b6f

Browse files
authored
Merge pull request #286 from wiktor-k/wiktor/add-matrix-tests
Build and test in a matrix
2 parents ef5aec2 + 1059ce9 commit bf85b6f

File tree

3 files changed

+96
-91
lines changed

3 files changed

+96
-91
lines changed

.github/actions/ci_script/action.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 93 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
- name: Check formatting
2222
run: cargo fmt --all -- --check
2323

24+
lints:
25+
name: Check lints
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Check formatting
30+
run: cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
31+
2432
docs:
2533
name: Check documentation
2634
runs-on: ubuntu-latest
@@ -29,17 +37,90 @@ jobs:
2937
- name: Check documentation
3038
run: RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items --no-deps
3139

32-
build:
33-
name: Execute CI script
40+
check:
41+
name: Check for errors
42+
runs-on: ubuntu-latest
43+
continue-on-error: true
44+
strategy:
45+
matrix:
46+
target:
47+
- x86_64-unknown-linux-gnu
48+
- armv7-unknown-linux-gnueabi
49+
- armv7-unknown-linux-gnueabihf
50+
- arm-unknown-linux-gnueabi
51+
- aarch64-unknown-linux-gnu
52+
- i686-unknown-linux-gnu
53+
- loongarch64-unknown-linux-gnu
54+
- powerpc64-unknown-linux-gnu
55+
- powerpc64le-unknown-linux-gnu
56+
- x86_64-pc-windows-msvc
57+
- x86_64-apple-darwin
58+
- aarch64-apple-darwin
59+
- x86_64-unknown-freebsd
60+
- riscv64gc-unknown-linux-gnu
61+
toolchain:
62+
- stable
63+
- "1.66.0" # MSRV
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Setup Rust toolchain
67+
uses: actions-rs/toolchain@v1
68+
with:
69+
toolchain: ${{ matrix.toolchain }}
70+
- name: Install Rust target
71+
run: rustup target add ${{ matrix.target }}
72+
- name: Check source
73+
run: cargo check --target ${{ matrix.target }} --workspace --all-targets
74+
- name: Check all features source
75+
run: cargo check --target ${{ matrix.target }} --all-features --workspace --all-targets
76+
77+
check-matrix:
78+
name: Check if all checks succeeded
79+
if: always()
80+
needs:
81+
- check
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Decide whether the needed jobs succeeded or failed
85+
uses: re-actors/alls-green@release/v1
86+
with:
87+
jobs: ${{ toJSON(needs) }}
88+
89+
tests-softhsm:
90+
name: Run tests against SoftHSM
3491
runs-on: ubuntu-latest
92+
continue-on-error: true
93+
strategy:
94+
matrix:
95+
target:
96+
- x86_64-unknown-linux-gnu
97+
toolchain:
98+
- stable
99+
- "1.66.0" # MSRV
35100
steps:
36101
- uses: actions/checkout@v4
37102
- name: Setup Rust toolchain
38103
uses: actions-rs/toolchain@v1
39104
with:
40-
toolchain: stable
41-
- name: "Installs SoftHSM and execute tests"
42-
uses: ./.github/actions/ci_script
105+
toolchain: ${{ matrix.toolchain }}
106+
- name: Install SoftHSM
107+
run: |
108+
sudo apt-get update -y -qq &&
109+
sudo apt-get install -y -qq libsofthsm2 &&
110+
mkdir /tmp/tokens
111+
echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf
112+
- name: Install Rust target
113+
run: rustup target add ${{ matrix.target }}
114+
- name: Check
115+
run: cargo check --target ${{ matrix.target }} --workspace --all-targets
116+
- name: Test script
117+
env:
118+
TEST_PKCS11_MODULE: /usr/lib/softhsm/libsofthsm2.so
119+
SOFTHSM2_CONF: /tmp/softhsm2.conf
120+
TARGET: ${{ matrix.target }}
121+
RUST_BACKTRACE: 1
122+
RUSTFLAGS: "-D warnings"
123+
run: ./ci.sh
43124

44125
build-windows:
45126
name: Build on Windows
@@ -65,27 +146,14 @@ jobs:
65146
RUST_BACKTRACE=1 cargo build --all-features &&
66147
RUST_BACKTRACE=1 cargo test
67148
68-
69-
build-msrv:
70-
name: MSRV - Execute CI script
71-
runs-on: ubuntu-latest
72-
steps:
73-
- uses: actions/checkout@v4
74-
- name: Setup Rust toolchain on MSRV
75-
uses: actions-rs/toolchain@v1
76-
with:
77-
toolchain: 1.66.0
78-
- name: "Installs SoftHSM and execute tests"
79-
uses: ./.github/actions/ci_script
80-
81149
links:
82150
name: Check links
83151
runs-on: ubuntu-latest
84152
steps:
85-
- uses: actions/checkout@v4
86-
- name: Link Checker
87-
uses: peter-evans/link-checker@v1
88-
with:
89-
args: -v -r *.md
90-
- name: Fail if there were link errors
91-
run: exit ${{ steps.lc.outputs.exit_code }}
153+
- uses: actions/checkout@v4
154+
- name: Link Checker
155+
uses: peter-evans/link-checker@v1
156+
with:
157+
args: -v -r *.md
158+
- name: Fail if there were link errors
159+
run: exit ${{ steps.lc.outputs.exit_code }}

ci.sh

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,10 @@
55

66
# Continuous Integration test script
77

8-
set -euf -o pipefail
8+
set -euxf -o pipefail
99

1010
pushd cryptoki-sys
11-
RUST_BACKTRACE=1 cargo build --features generate-bindings
11+
cargo build --features generate-bindings
1212
popd
1313

14-
# check formatting before going through all the builds
15-
if cargo fmt --version; then
16-
cargo fmt --all -- --check
17-
fi
18-
if cargo clippy --version; then
19-
cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
20-
fi
21-
22-
RUST_BACKTRACE=1 cargo build
23-
24-
RUST_BACKTRACE=1 cargo build --all-features
25-
26-
RUST_BACKTRACE=1 cargo build --target arm-unknown-linux-gnueabi
27-
RUST_BACKTRACE=1 cargo build --target armv7-unknown-linux-gnueabi
28-
RUST_BACKTRACE=1 cargo build --target armv7-unknown-linux-gnueabihf
29-
RUST_BACKTRACE=1 cargo build --target aarch64-unknown-linux-gnu
30-
RUST_BACKTRACE=1 cargo build --target i686-unknown-linux-gnu
31-
RUST_BACKTRACE=1 cargo build --target loongarch64-unknown-linux-gnu
32-
RUST_BACKTRACE=1 cargo build --target powerpc64-unknown-linux-gnu
33-
RUST_BACKTRACE=1 cargo build --target powerpc64le-unknown-linux-gnu
34-
RUST_BACKTRACE=1 cargo build --target riscv64gc-unknown-linux-gnu
35-
RUST_BACKTRACE=1 cargo build --target x86_64-pc-windows-msvc
36-
RUST_BACKTRACE=1 cargo build --target x86_64-apple-darwin
37-
RUST_BACKTRACE=1 cargo build --target aarch64-apple-darwin
38-
RUST_BACKTRACE=1 cargo build --target x86_64-unknown-freebsd
39-
40-
RUST_BACKTRACE=1 cargo test
14+
cargo test --target "$TARGET"

0 commit comments

Comments
 (0)