| 1 |
on: |
| 2 |
push: |
| 3 |
branches: ['main', 'ci/*'] |
| 4 |
pull_request: |
| 5 |
merge_group: |
| 6 |
schedule: |
| 7 |
- cron: '0 18 * * *' |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
name: CI |
| 11 |
permissions: |
| 12 |
contents: read |
| 13 |
|
| 14 |
env: |
| 15 |
RUSTFLAGS: -D warnings |
| 16 |
|
| 17 |
jobs: |
| 18 |
clippy-build-std: |
| 19 |
name: Clippy (-Zbuild-std) |
| 20 |
runs-on: macos-latest |
| 21 |
steps: |
| 22 |
- uses: actions/checkout@v4 |
| 23 |
with: |
| 24 |
persist-credentials: false |
| 25 |
|
| 26 |
- uses: dtolnay/rust-toolchain@nightly |
| 27 |
with: |
| 28 |
components: clippy |
| 29 |
|
| 30 |
- name: Clippy (tvOS) |
| 31 |
run: | |
| 32 |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin |
| 33 |
cargo +nightly clippy -Zbuild-std --target aarch64-apple-tvos |
| 34 |
|
| 35 |
- name: Clippy (watchOS) |
| 36 |
run: | |
| 37 |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin |
| 38 |
cargo +nightly clippy -Zbuild-std --target aarch64-apple-watchos |
| 39 |
|
| 40 |
- name: Clippy (visionOS) |
| 41 |
run: | |
| 42 |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin |
| 43 |
cargo +nightly clippy -Zbuild-std --target aarch64-apple-visionos |
| 44 |
|
| 45 |
clippy: |
| 46 |
name: Clippy (stable) |
| 47 |
runs-on: ${{ matrix.os }} |
| 48 |
strategy: |
| 49 |
matrix: |
| 50 |
os: |
| 51 |
- ubuntu-latest |
| 52 |
- macos-latest |
| 53 |
- windows-latest |
| 54 |
steps: |
| 55 |
- uses: actions/checkout@v4 |
| 56 |
with: |
| 57 |
persist-credentials: false |
| 58 |
|
| 59 |
- uses: dtolnay/rust-toolchain@stable |
| 60 |
with: |
| 61 |
components: clippy |
| 62 |
|
| 63 |
- name: Clippy (${{ matrix.os }}) |
| 64 |
run: cargo clippy-ci |
| 65 |
|
| 66 |
- name: Clippy (Android) |
| 67 |
if: matrix.os == 'ubuntu-latest' |
| 68 |
run: | |
| 69 |
rustup target add aarch64-linux-android |
| 70 |
cargo install cargo-ndk |
| 71 |
cargo ndk -t arm64-v8a clippy-ci |
| 72 |
|
| 73 |
- name: Clippy (iOS) |
| 74 |
if: matrix.os == 'macos-latest' |
| 75 |
run: | |
| 76 |
rustup target add x86_64-apple-ios |
| 77 |
cargo clippy-ci --target x86_64-apple-ios |
| 78 |
|
| 79 |
- name: Clippy (WASM) |
| 80 |
if: matrix.os == 'ubuntu-latest' |
| 81 |
run: | |
| 82 |
rustup target add wasm32-wasip1 |
| 83 |
cargo clippy-ci --target wasm32-wasip1 |
| 84 |
|
| 85 |
# Update any flexible dependencies that may have SemVer applicable changes |
| 86 |
# to ensure the project keeps building with the whole version range. This is: |
| 87 |
# - windows-sys 0.52, which `rustls-platform-verifier` also should accept at 0.59. |
| 88 |
- name: Clippy (dependency version checks) |
| 89 |
run: | |
| 90 |
cargo update -p [email protected] |
| 91 |
cargo clippy-ci |
| 92 |
|
| 93 |
clippy-msrv: |
| 94 |
name: Clippy (MSRV) |
| 95 |
runs-on: ${{ matrix.os }} |
| 96 |
strategy: |
| 97 |
matrix: |
| 98 |
os: |
| 99 |
- ubuntu-latest |
| 100 |
- macos-latest |
| 101 |
- windows-latest |
| 102 |
steps: |
| 103 |
- uses: actions/checkout@v4 |
| 104 |
with: |
| 105 |
persist-credentials: false |
| 106 |
|
| 107 |
- uses: dtolnay/rust-toolchain@master |
| 108 |
with: |
| 109 |
toolchain: "1.71.0" # MSRV |
| 110 |
components: clippy |
| 111 |
|
| 112 |
- name: Install cargo-ndk. |
| 113 |
run: | |
| 114 |
cargo install cargo-ndk --locked --version 2.12.7 |
| 115 |
rustup target add aarch64-linux-android |
| 116 |
|
| 117 |
- name: Clippy (${{ matrix.os }}) |
| 118 |
run: cargo clippy-msrv-ci |
| 119 |
|
| 120 |
- name: Clippy (Android) |
| 121 |
if: matrix.os == 'ubuntu-latest' |
| 122 |
run: | |
| 123 |
cargo ndk -t arm64-v8a clippy-msrv-ci |
| 124 |
|
| 125 |
- name: Clippy (iOS) |
| 126 |
if: matrix.os == 'macos-latest' |
| 127 |
run: | |
| 128 |
rustup target add aarch64-apple-ios |
| 129 |
cargo clippy-msrv-ci --target aarch64-apple-ios |
| 130 |
|
| 131 |
# TODO: Consider WASM. See note on "clippy" job. |
| 132 |
|
| 133 |
test: |
| 134 |
name: Test |
| 135 |
runs-on: ${{ matrix.os }} |
| 136 |
strategy: |
| 137 |
matrix: |
| 138 |
os: |
| 139 |
- ubuntu-latest |
| 140 |
- macos-latest |
| 141 |
- windows-latest |
| 142 |
steps: |
| 143 |
- uses: actions/checkout@v4 |
| 144 |
with: |
| 145 |
persist-credentials: false |
| 146 |
|
| 147 |
- uses: dtolnay/rust-toolchain@stable |
| 148 |
|
| 149 |
- name: Test (${{ matrix.os }}) |
| 150 |
run: cargo test |
| 151 |
|
| 152 |
test_android: |
| 153 |
name: "Test (Android)" |
| 154 |
runs-on: ubuntu-latest |
| 155 |
steps: |
| 156 |
- uses: actions/checkout@v4 |
| 157 |
with: |
| 158 |
persist-credentials: false |
| 159 |
|
| 160 |
# Turn on Linux KVM features/support for faster Android emulation. |
| 161 |
# References: |
| 162 |
# - https://github.com/DeterminateSystems/nix-installer-action/blob/de22e16c4711fca50c816cc9081563429d1cf563/src/main.ts#L756 |
| 163 |
# - https://github.com/ReactiveCircus/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners |
| 164 |
- name: Enable KVM |
| 165 |
run: | |
| 166 |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 167 |
sudo udevadm control --reload-rules |
| 168 |
sudo udevadm trigger --name-match=kvm |
| 169 |
|
| 170 |
- name: Setup Java |
| 171 |
uses: actions/setup-java@v4 |
| 172 |
with: |
| 173 |
distribution: 'temurin' |
| 174 |
java-version: '17' |
| 175 |
|
| 176 |
- name: Run Android tests |
| 177 |
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # 2.33.0 |
| 178 |
with: |
| 179 |
api-level: 28 # Android 9, Pie. |
| 180 |
arch: x86_64 |
| 181 |
profile: pixel |
| 182 |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 183 |
disable-animations: true |
| 184 |
working-directory: ./android |
| 185 |
script: | |
| 186 |
rustup target add x86_64-linux-android |
| 187 |
cargo install cargo-ndk |
| 188 |
env | grep '^JAVA' |
| 189 |
touch emulator.log |
| 190 |
chmod 770 emulator.log |
| 191 |
adb logcat --clear |
| 192 |
adb logcat | grep 'rustls' | tee emulator.log & |
| 193 |
./gradlew connectedDebugAndroidTest |
| 194 |
|
| 195 |
- name: Upload Android test results |
| 196 |
uses: actions/upload-artifact@v4 |
| 197 |
# Upload test results if they fail |
| 198 |
if: failure() |
| 199 |
with: |
| 200 |
name: android-test-results |
| 201 |
retention-days: 7 |
| 202 |
path: | |
| 203 |
./android/emulator.log |
| 204 |
/Users/runner/work/rustls-platform-verifier/rustls-platform-verifier/android/rustls-platform-verifier/build/outputs/androidTest-results/connected/test-result.pb |
| 205 |
|
| 206 |
test_ios: |
| 207 |
name: "Test iOS (Catalyst)" |
| 208 |
runs-on: macos-latest |
| 209 |
steps: |
| 210 |
- uses: actions/checkout@v4 |
| 211 |
with: |
| 212 |
persist-credentials: false |
| 213 |
- name: Run iOS tests |
| 214 |
run: | |
| 215 |
rustup target add aarch64-apple-ios-macabi |
| 216 |
cargo test --target aarch64-apple-ios-macabi |
| 217 |
|
| 218 |
test-freebsd: |
| 219 |
name: Test (FreeBSD) |
| 220 |
runs-on: ubuntu-latest |
| 221 |
steps: |
| 222 |
- uses: actions/checkout@v4 |
| 223 |
with: |
| 224 |
persist-credentials: false |
| 225 |
- name: test on freebsd |
| 226 |
uses: vmactions/freebsd-vm@v1 |
| 227 |
# Settings adopted from https://github.com/quinn-rs/quinn |
| 228 |
with: |
| 229 |
usesh: true |
| 230 |
mem: 4096 |
| 231 |
copyback: false |
| 232 |
prepare: | |
| 233 |
pkg install -y curl |
| 234 |
curl https://sh.rustup.rs -sSf --output rustup.sh |
| 235 |
sh rustup.sh -y --profile minimal --default-toolchain stable |
| 236 |
echo "~~~~ rustc --version ~~~~" |
| 237 |
$HOME/.cargo/bin/rustc --version |
| 238 |
echo "~~~~ freebsd-version ~~~~" |
| 239 |
freebsd-version |
| 240 |
run: $HOME/.cargo/bin/cargo test |
| 241 |
|
| 242 |
fmt: |
| 243 |
name: Rustfmt |
| 244 |
runs-on: ubuntu-latest |
| 245 |
steps: |
| 246 |
- uses: actions/checkout@v4 |
| 247 |
with: |
| 248 |
persist-credentials: false |
| 249 |
|
| 250 |
- uses: dtolnay/rust-toolchain@stable |
| 251 |
with: |
| 252 |
components: rustfmt |
| 253 |
|
| 254 |
- run: cargo fmt --all -- --check |
| 255 |
|
| 256 |
android_fmt: |
| 257 |
name: Ktlint |
| 258 |
runs-on: ubuntu-latest |
| 259 |
steps: |
| 260 |
- uses: actions/checkout@v4 |
| 261 |
with: |
| 262 |
persist-credentials: false |
| 263 |
|
| 264 |
- name: Ktlint |
| 265 |
run: | |
| 266 |
cd ./android |
| 267 |
./gradlew ktlint |
| 268 |
|
| 269 |
verify_android: |
| 270 |
name: Verify Android artifacts |
| 271 |
runs-on: ubuntu-latest |
| 272 |
steps: |
| 273 |
- uses: actions/checkout@v4 |
| 274 |
with: |
| 275 |
persist-credentials: false |
| 276 |
|
| 277 |
- name: Verify release artifact |
| 278 |
run: ./ci/verify_android_release.sh |
| 279 |
|
| 280 |
semver: |
| 281 |
name: Check semver compatibility |
| 282 |
runs-on: ubuntu-latest |
| 283 |
steps: |
| 284 |
- name: Checkout sources |
| 285 |
uses: actions/checkout@v4 |
| 286 |
with: |
| 287 |
persist-credentials: false |
| 288 |
|
| 289 |
- name: Check semver |
| 290 |
uses: obi1kenobi/cargo-semver-checks-action@v2 |
| 291 |
|
| 292 |
docs: |
| 293 |
name: Check for documentation errors |
| 294 |
runs-on: ubuntu-latest |
| 295 |
steps: |
| 296 |
- name: Checkout sources |
| 297 |
uses: actions/checkout@v4 |
| 298 |
with: |
| 299 |
persist-credentials: false |
| 300 |
|
| 301 |
- name: Install rust toolchain |
| 302 |
uses: dtolnay/rust-toolchain@nightly |
| 303 |
|
| 304 |
- name: Build documentation |
| 305 |
run: cargo doc --locked --all-features --no-deps --document-private-items |
| 306 |
env: |
| 307 |
RUSTDOCFLAGS: -Dwarnings --cfg=docsrs |