Skip to content

Commit fe9ee0f

Browse files
committed
der: expand CI coverage
Adopts some additional testing and changes inspired by configs in other git repos we maintain: - `build-no-std`: only test build on `thumbv7em-none-eabi` because we now actually run tests on WASM - `test`: checks AArch64 Linux/macOS targets (more OS coverage is good because `der` has `std`-based features that interact with e.g. filesystems), and x86_64 Windows targets - `test-careful`: because we have some `unsafe` code - `test-cross`: test on 32-bit and big endian architectures - `test-miri`: because we have some `unsafe` code - `test-wasm`: we can actually test directly on WASM using wasmtime, rather than just ensuring our code compiles
1 parent 65ae3d7 commit fe9ee0f

File tree

5 files changed

+115
-43
lines changed

5 files changed

+115
-43
lines changed

.github/workflows/der.yml

Lines changed: 109 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,16 @@ concurrency:
2525
cancel-in-progress: true
2626

2727
jobs:
28-
build:
28+
build-no-std:
2929
runs-on: ubuntu-latest
30-
strategy:
31-
matrix:
32-
rust:
33-
- 1.85.0 # MSRV
34-
- stable
35-
target:
36-
- thumbv7em-none-eabi
37-
- wasm32-unknown-unknown
3830
steps:
3931
- uses: actions/checkout@v6
4032
- uses: dtolnay/rust-toolchain@master
4133
with:
42-
toolchain: ${{ matrix.rust }}
43-
targets: ${{ matrix.target }}
34+
toolchain: stable
35+
targets: thumbv7em-none-eabi
4436
- uses: RustCrypto/actions/cargo-hack-install@master
45-
- run: cargo hack build --target ${{ matrix.target }} --feature-powerset --exclude-features arbitrary,std,heapless
37+
- run: cargo hack build --target thumbv7em-none-eabi --feature-powerset --exclude-features arbitrary,std
4638

4739
minimal-versions:
4840
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
@@ -53,56 +45,88 @@ jobs:
5345
strategy:
5446
matrix:
5547
include:
56-
# 32-bit Linux
57-
- targets: i686-unknown-linux-gnu
58-
platform: ubuntu-latest
48+
# `aarch64` Linux
49+
- target: aarch64-unknown-linux-gnu
50+
rust: 1.85.0
51+
runner: ubuntu-24.04-arm
52+
- target: aarch64-unknown-linux-gnu
53+
rust: stable
54+
runner: ubuntu-24.04-arm
55+
56+
# `aarch64` macOS
57+
- target: aarch64-apple-darwin
58+
rust: 1.85.0
59+
runner: macos-latest
60+
- target: aarch64-apple-darwin
61+
rust: stable
62+
runner: macos-latest
63+
64+
# `x86` Linux (32-bit)
65+
- target: i686-unknown-linux-gnu
5966
rust: 1.85.0 # MSRV
6067
deps: sudo apt update && sudo apt install gcc-multilib
61-
- targets: i686-unknown-linux-gnu
62-
platform: ubuntu-latest
68+
- target: i686-unknown-linux-gnu
6369
rust: stable
6470
deps: sudo apt update && sudo apt install gcc-multilib
6571

66-
# 64-bit Linux
67-
- targets: x86_64-unknown-linux-gnu
68-
platform: ubuntu-latest
72+
# `x86_64` Linux
73+
- target: x86_64-unknown-linux-gnu
6974
rust: 1.85.0 # MSRV
70-
- targets: x86_64-unknown-linux-gnu
71-
platform: ubuntu-latest
75+
- target: x86_64-unknown-linux-gnu
7276
rust: stable
7377

74-
# temporary disable, since cargo-hack installation does not work yet
75-
# 64-bit Windows
76-
#- targets: x86_64-pc-windows-msvc
77-
# platform: windows-latest
78-
# rust: 1.85.0 # MSRV
79-
#- targets: x86_64-pc-windows-msvc
80-
# platform: windows-latest
81-
# rust: stable
82-
runs-on: ${{ matrix.platform }}
78+
# `x86_64` Windows
79+
- target: x86_64-pc-windows-msvc
80+
rust: 1.85.0
81+
runner: windows-latest
82+
- target: x86_64-pc-windows-msvc
83+
rust: stable
84+
runner: windows-latest
85+
runs-on: ${{ matrix.runner != '' && matrix.runner || 'ubuntu-latest' }}
8386
steps:
8487
- uses: actions/checkout@v6
8588
- uses: dtolnay/rust-toolchain@master
8689
with:
8790
toolchain: ${{ matrix.rust }}
8891
targets: ${{ matrix.target }}
8992
- run: ${{ matrix.deps }}
90-
- uses: RustCrypto/actions/cargo-hack-install@master
91-
- run: cargo hack test --feature-powerset --exclude-features arbitrary,std,heapless
92-
- run: cargo test --features arbitrary
93-
- run: cargo test --features std
93+
- uses: taiki-e/install-action@cargo-hack
94+
- run: cargo hack test --target ${{ matrix.target }} --feature-powerset --exclude-features arbitrary,std,heapless
95+
- run: cargo test --target ${{ matrix.target }} --features arbitrary
96+
- run: cargo test --target ${{ matrix.target }} --features std
97+
- run: cargo test --target ${{ matrix.target }} --features arbitrary,ber,bytes,derive,oid,pem,real,std --release
9498

95-
# Test `heapless` feature (requires MSRV 1.87)
96-
test-heapless:
99+
# Test using `cargo careful`
100+
test-careful:
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v6
104+
- uses: dtolnay/rust-toolchain@nightly
105+
- run: cargo install cargo-careful
106+
- run: cargo careful test --all-features
107+
108+
# Test on foreign architectures using `cross test`
109+
test-cross:
110+
strategy:
111+
matrix:
112+
include:
113+
- target: armv7-unknown-linux-gnueabi # ARM32
114+
- target: powerpc-unknown-linux-gnu # PPC32 (big endian)
97115
runs-on: ubuntu-latest
98116
steps:
99117
- uses: actions/checkout@v6
100118
- uses: dtolnay/rust-toolchain@master
101119
with:
102-
toolchain: 1.87
103-
- run: cargo test --features heapless
120+
toolchain: stable
121+
targets: ${{ matrix.target }}
122+
- run: cargo install cross
123+
- run: cross test --target ${{ matrix.target }} --no-default-features
124+
- run: cross test --target ${{ matrix.target }}
125+
- run: cross test --target ${{ matrix.target }} --all-features
126+
- run: cross test --target ${{ matrix.target }} --all-features --release
104127

105-
derive:
128+
# Test `der_derive`
129+
test-derive:
106130
runs-on: ubuntu-latest
107131
strategy:
108132
matrix:
@@ -117,3 +141,48 @@ jobs:
117141
- uses: RustCrypto/actions/cargo-hack-install@master
118142
- run: cargo hack test --feature-powerset
119143
working-directory: der_derive
144+
145+
# Test `heapless` feature (requires MSRV 1.87)
146+
test-heapless:
147+
runs-on: ubuntu-latest
148+
steps:
149+
- uses: actions/checkout@v6
150+
- uses: dtolnay/rust-toolchain@master
151+
with:
152+
toolchain: 1.87
153+
- run: cargo test --features heapless
154+
155+
# Test using `cargo miri`
156+
test-miri:
157+
runs-on: ubuntu-latest
158+
env:
159+
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-strict-provenance"
160+
strategy:
161+
matrix:
162+
target:
163+
- x86_64-unknown-linux-gnu
164+
- s390x-unknown-linux-gnu
165+
steps:
166+
- uses: actions/checkout@v6
167+
- uses: dtolnay/rust-toolchain@stable
168+
with:
169+
toolchain: nightly-2026-02-11 # pinned due to rust-lang/miri#4855
170+
- run: rustup component add miri && cargo miri setup
171+
- run: cargo miri test --target ${{ matrix.target }} --no-default-features --lib
172+
173+
# Test WASM using `wasmtime`
174+
test-wasm:
175+
runs-on: ubuntu-latest
176+
env:
177+
CARGO_TARGET_WASM32_WASIP1_RUNNER: "wasmtime"
178+
steps:
179+
- uses: actions/checkout@v6
180+
- uses: bytecodealliance/actions/wasmtime/setup@v1
181+
- uses: dtolnay/rust-toolchain@master
182+
with:
183+
toolchain: stable
184+
targets: wasm32-wasip1
185+
- run: cargo test --target wasm32-wasip1 --no-default-features
186+
- run: cargo test --target wasm32-wasip1
187+
- run: cargo test --target wasm32-wasip1 --all-features
188+
- run: cargo test --target wasm32-wasip1 --all-features --release

der/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ zeroize = { version = "1.8", optional = true, default-features = false }
2929

3030
[dev-dependencies]
3131
hex-literal = "1"
32-
proptest = "1"
32+
[target.'cfg(any(unix, windows))'.dev-dependencies]
33+
proptest = "1.10"
3334

3435
[features]
3536
alloc = ["zeroize?/alloc"]

der/tests/datetime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for the [`DateTime`] type.
22
3+
#![cfg(any(unix, windows))]
4+
35
use der::{DateTime, Decode, Encode, asn1::UtcTime};
46
use proptest::prelude::*;
57

der/tests/pem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn from_pem() {
6262
#[test]
6363
fn to_pem() {
6464
let spki = SpkiBorrowed::from_der(SPKI_DER).unwrap();
65-
let pem = spki.to_pem(LineEnding::LF).unwrap();
65+
let pem = spki.to_pem(LineEnding::default()).unwrap();
6666
assert_eq!(&pem, SPKI_PEM);
6767
}
6868

der/tests/set_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! `SetOf` tests.
22
3-
#![cfg(all(feature = "alloc", feature = "heapless"))]
3+
#![cfg(all(any(unix, windows), feature = "alloc", feature = "heapless"))]
44

55
use der::{DerOrd, asn1::SetOfVec};
66
use proptest::{prelude::*, string::*};

0 commit comments

Comments
 (0)