1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: CI
on:
push:
branches:
pull_request:
branches:
jobs:
generate-matrix:
name: Generate Feature Matrix
runs-on: ubuntu-latest
outputs:
features: ${{ steps.set-matrix.outputs.features }}
steps:
- name: Checkout sources
uses: actions/checkout@main
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Generate feature combinations
id: set-matrix
run: |
# Get list of cargo test commands from cargo hack
COMMANDS=$(cargo hack test --feature-powerset --print-command-list)
# Extract the arguments after "cargo test --manifest-path Cargo.toml " and format as JSON array
JSON=$(echo "$COMMANDS" | sed 's/cargo test --manifest-path Cargo.toml //g' | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "features=$JSON" >> $GITHUB_OUTPUT
test:
name: Test (${{ matrix.features }})
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features: ${{ fromJson(needs.generate-matrix.outputs.features) }}
steps:
- name: Checkout sources
uses: actions/checkout@main
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run cargo test
run: cargo test ${{ matrix.features }}