Skip to content

Commit c39652e

Browse files
committed
WIP: CI run clippy for all target triplets
1 parent 2399735 commit c39652e

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,24 @@ env:
2020
# - Cargo.toml
2121
# - README.md
2222
rust_minver: 1.63.0
23+
ci_targets: "['', 'x86_64-apple-ios', 'x86_64-unknown-freebsd', 'x86_64-unknown-illumos', 'aarch64-linux-android']"
2324

2425
defaults:
2526
run:
2627
shell: bash
2728

2829
jobs:
30+
matrix:
31+
strategy:
32+
fail-fast: false
33+
runs-on: ubuntu-latest
34+
outputs:
35+
ci_targets: ${{ steps.generate.outputs.ci_targets }}
36+
steps:
37+
- name: Generate matrix
38+
id: generate
39+
run: echo "ci_targets=${{ env.ci_targets }}" >> $GITHUB_OUTPUT
40+
2941
format:
3042
strategy:
3143
fail-fast: false
@@ -78,48 +90,56 @@ jobs:
7890
done
7991
8092
clippy:
93+
needs: [matrix]
8194
strategy:
8295
fail-fast: false
8396
matrix:
8497
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
98+
target: ${{ fromJSON(needs.matrix.outputs.ci_targets) }}
8599
runs-on: ${{ matrix.os }}
86100
steps:
87101
- name: Checkout repository
88102
uses: actions/checkout@v4
89103
- name: Install dependencies
90104
if: matrix.os == 'ubuntu-latest'
91105
run: sudo bash ./.github/workflows/install-deps.sh
106+
- name: Install Rust target
107+
if: matrix.target != ''
108+
run: |
109+
rustup target add ${{ matrix.target }}
110+
echo 'cargo_target_arg="--target ${{ matrix.target }}' >> $GITHUB_ENV
92111
- name: Install Rust nightly
93112
run: |
94113
rustup toolchain install nightly
95114
rustup component add clippy --toolchain nightly
96115
- name: Restore cargo caches
97116
uses: Swatinem/rust-cache@v2
98117
- name: Run clippy
99-
run: cargo clippy --all-features --tests --examples -- -D warnings
118+
run: cargo clippy --all-features --tests --examples ${{ env.cargo_target_arg }} -- -D warnings
100119
- name: Run clippy nightly
101120
run: |
102-
cargo +nightly clippy --all-features --tests --examples
121+
cargo +nightly clippy --all-features --tests --examples ${{ env.cargo_target_arg }}
103122
104-
WARNS=$(cargo +nightly clippy --all-features --tests --examples --message-format=json | jq -s '[.[] | select(.reason == "compiler-message")] | length')
123+
WARNS=$(cargo +nightly clippy --all-features --tests --examples --message-format=json ${{ env.cargo_target_arg }} | jq -s '[.[] | select(.reason == "compiler-message")] | length')
105124
if [[ $WARNS -ne 0 ]]; then
106125
echo "::warning title=nightly clippy::Detected $WARNS warnings"
107126
fi
108127
- name: Run clippy nightly for benches
109128
run: |
110-
cargo +nightly clippy --all-features --benches -- -A clippy::incompatible_msrv
129+
cargo +nightly clippy --all-features --benches ${{ env.cargo_target_arg }} -- -A clippy::incompatible_msrv
111130
112-
WARNS=$(cargo +nightly clippy --all-features --benches --message-format=json -- -A clippy::incompatible_msrv | jq -s '[.[] | select(.reason == "compiler-message")] | length')
131+
WARNS=$(cargo +nightly clippy --all-features --benches --message-format=json ${{ env.cargo_target_arg }} -- -A clippy::incompatible_msrv | jq -s '[.[] | select(.reason == "compiler-message")] | length')
113132
if [[ $WARNS -ne 0 ]]; then
114133
echo "::warning title=nightly clippy::Detected $WARNS warnings"
115134
fi
116135
117136
check:
137+
needs: [matrix]
118138
strategy:
119139
fail-fast: false
120140
matrix:
121141
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
122-
target: ['', 'x86_64-apple-ios', 'x86_64-unknown-freebsd', 'x86_64-unknown-illumos', 'aarch64-linux-android']
142+
target: ${{ fromJSON(needs.matrix.outputs.ci_targets) }}
123143
runs-on: ${{ matrix.os }}
124144
steps:
125145
- name: Checkout repository

0 commit comments

Comments
 (0)