| 1 |
name: CI |
| 2 |
|
| 3 |
permissions: {} |
| 4 |
|
| 5 |
on: |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
pull_request: |
| 10 |
merge_group: |
| 11 |
branches: |
| 12 |
- main |
| 13 |
|
| 14 |
jobs: |
| 15 |
e2e-tests: |
| 16 |
runs-on: ubuntu-latest |
| 17 |
env: |
| 18 |
SUDO_UNDER_TEST: ours |
| 19 |
CI: true |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 22 |
with: |
| 23 |
persist-credentials: false |
| 24 |
|
| 25 |
- name: set up docker buildx |
| 26 |
run: docker buildx create --name builder --use |
| 27 |
|
| 28 |
- name: cache docker layers |
| 29 |
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae |
| 30 |
with: |
| 31 |
path: /tmp/.buildx-cache |
| 32 |
key: docker-buildx-rs-${{ github.sha }} |
| 33 |
restore-keys: docker-buildx-rs- |
| 34 |
|
| 35 |
- name: Rust Cache |
| 36 |
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 |
| 37 |
with: |
| 38 |
shared-key: "compliance-tests" |
| 39 |
workspaces: | |
| 40 |
test-framework |
| 41 |
|
| 42 |
- name: Register rust problem matcher |
| 43 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 44 |
|
| 45 |
- name: Run all E2E tests |
| 46 |
working-directory: test-framework |
| 47 |
run: cargo test -p e2e-tests --features apparmor |
| 48 |
|
| 49 |
- name: prevent the cache from growing too large |
| 50 |
run: | |
| 51 |
rm -rf /tmp/.buildx-cache |
| 52 |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
| 53 |
|
| 54 |
compliance-tests-detect-changes: |
| 55 |
runs-on: ubuntu-latest |
| 56 |
outputs: |
| 57 |
updated: ${{ steps.filter.outputs.test-framework }} |
| 58 |
steps: |
| 59 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 60 |
with: |
| 61 |
persist-credentials: false |
| 62 |
|
| 63 |
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d |
| 64 |
id: filter |
| 65 |
with: |
| 66 |
filters: | |
| 67 |
test-framework: |
| 68 |
- 'test-framework/**' |
| 69 |
|
| 70 |
compliance-tests-og: |
| 71 |
needs: compliance-tests-detect-changes |
| 72 |
if: ${{ needs.compliance-tests-detect-changes.outputs.updated != 'false' }} |
| 73 |
runs-on: ubuntu-latest |
| 74 |
env: |
| 75 |
CI: true |
| 76 |
steps: |
| 77 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 78 |
with: |
| 79 |
persist-credentials: false |
| 80 |
|
| 81 |
- name: set up docker buildx |
| 82 |
run: docker buildx create --name builder --use |
| 83 |
|
| 84 |
- name: Rust Cache |
| 85 |
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 |
| 86 |
with: |
| 87 |
shared-key: "compliance-tests" |
| 88 |
workspaces: | |
| 89 |
test-framework |
| 90 |
|
| 91 |
- name: Register rust problem matcher |
| 92 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 93 |
|
| 94 |
- name: Test sudo-test itself |
| 95 |
working-directory: test-framework |
| 96 |
run: cargo test -p sudo-test |
| 97 |
|
| 98 |
- name: Run all compliance tests against original sudo |
| 99 |
working-directory: test-framework |
| 100 |
run: cargo test -p sudo-compliance-tests -- --include-ignored |
| 101 |
|
| 102 |
compliance-tests: |
| 103 |
runs-on: ubuntu-latest |
| 104 |
timeout-minutes: 20 |
| 105 |
env: |
| 106 |
SUDO_TEST_PROFRAW_DIR: /tmp/profraw |
| 107 |
CI: true |
| 108 |
steps: |
| 109 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 110 |
with: |
| 111 |
persist-credentials: false |
| 112 |
|
| 113 |
- name: set up docker buildx |
| 114 |
run: docker buildx create --name builder --use |
| 115 |
|
| 116 |
- name: cache docker layers |
| 117 |
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae |
| 118 |
with: |
| 119 |
path: /tmp/.buildx-cache |
| 120 |
key: docker-buildx-rs-${{ github.sha }} |
| 121 |
restore-keys: docker-buildx-rs- |
| 122 |
|
| 123 |
- name: Rust Cache |
| 124 |
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 |
| 125 |
with: |
| 126 |
shared-key: "compliance-tests" |
| 127 |
workspaces: | |
| 128 |
test-framework |
| 129 |
|
| 130 |
- name: Register rust problem matcher |
| 131 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 132 |
|
| 133 |
- name: Run gated compliance tests against sudo-rs |
| 134 |
working-directory: test-framework |
| 135 |
env: |
| 136 |
SUDO_UNDER_TEST: ours |
| 137 |
run: cargo test -p sudo-compliance-tests --features apparmor |
| 138 |
|
| 139 |
- name: Check that we didn't forget to gate a passing compliance test |
| 140 |
working-directory: test-framework |
| 141 |
env: |
| 142 |
SUDO_UNDER_TEST: ours |
| 143 |
run: | |
| 144 |
tmpfile="$(mktemp)" |
| 145 |
cargo test -p sudo-compliance-tests -- --ignored | tee "$tmpfile" |
| 146 |
grep 'test result: FAILED. 0 passed' "$tmpfile" || ( echo "expected ALL tests to fail but at least one passed; the passing tests must be un-#[ignore]-d" && exit 1 ) |
| 147 |
|
| 148 |
- name: prevent the cache from growing too large |
| 149 |
run: | |
| 150 |
rm -rf /tmp/.buildx-cache |
| 151 |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
| 152 |
|
| 153 |
compliance-tests-lint: |
| 154 |
needs: compliance-tests-detect-changes |
| 155 |
if: ${{ needs.compliance-tests-detect-changes.outputs.updated != 'false' }} |
| 156 |
runs-on: ubuntu-latest |
| 157 |
|
| 158 |
steps: |
| 159 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 160 |
with: |
| 161 |
persist-credentials: false |
| 162 |
|
| 163 |
- name: Rust Cache |
| 164 |
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 |
| 165 |
with: |
| 166 |
shared-key: "compliance-tests" |
| 167 |
workspaces: | |
| 168 |
test-framework |
| 169 |
|
| 170 |
- name: Register rust problem matcher |
| 171 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 172 |
|
| 173 |
- name: clippy sudo-test |
| 174 |
working-directory: test-framework |
| 175 |
run: cargo clippy -p sudo-test --no-deps -- --deny warnings |
| 176 |
|
| 177 |
- name: clippy compliance-tests |
| 178 |
working-directory: test-framework |
| 179 |
run: cargo clippy -p sudo-compliance-tests --tests --no-deps -- --deny warnings |
| 180 |
|
| 181 |
- name: Check that all ignored tests are linked to a GH issue |
| 182 |
working-directory: test-framework/sudo-compliance-tests |
| 183 |
run: | |
| 184 |
grep -r '#\[ignore' ./src | grep -v -e '"gh' -e '"wontfix"' && echo 'found ignored tests not linked to a GitHub issue. please like them using the format #[ignore = "gh123"]' && exit 1; true |
| 185 |
|
| 186 |
build-and-test: |
| 187 |
runs-on: ubuntu-latest |
| 188 |
|
| 189 |
steps: |
| 190 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 191 |
with: |
| 192 |
persist-credentials: false |
| 193 |
|
| 194 |
- name: Correct permissions |
| 195 |
run: sudo chmod -R 755 /usr/share |
| 196 |
|
| 197 |
- name: Install llvm-tools component |
| 198 |
run: rustup component add llvm-tools |
| 199 |
|
| 200 |
- name: Add cargo-llvm-cov |
| 201 |
uses: taiki-e/install-action@8f531eaecd1898bc3da7d104ad91bee98d1b97bd |
| 202 |
with: |
| 203 |
tool: cargo-llvm-cov |
| 204 |
|
| 205 |
- name: Install dependencies |
| 206 |
run: | |
| 207 |
sudo apt update |
| 208 |
sudo apt install libpam0g-dev |
| 209 |
|
| 210 |
- name: Register rust problem matcher |
| 211 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 212 |
|
| 213 |
- name: Build |
| 214 |
run: cargo build --workspace --all-targets --release |
| 215 |
|
| 216 |
- name: Run tests |
| 217 |
run: cargo test --workspace --all-targets --release |
| 218 |
|
| 219 |
build-and-test-minimal: |
| 220 |
runs-on: ubuntu-latest |
| 221 |
|
| 222 |
steps: |
| 223 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 224 |
with: |
| 225 |
persist-credentials: false |
| 226 |
|
| 227 |
- name: Correct permissions |
| 228 |
run: sudo chmod -R 755 /usr/share |
| 229 |
|
| 230 |
- name: Install nightly rust |
| 231 |
run: | |
| 232 |
rustup set profile minimal |
| 233 |
rustup override set nightly |
| 234 |
|
| 235 |
- name: Install dependencies |
| 236 |
run: | |
| 237 |
sudo apt update |
| 238 |
sudo apt install libpam0g-dev |
| 239 |
|
| 240 |
- name: Register rust problem matcher |
| 241 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 242 |
|
| 243 |
- name: Update to minimal direct dependencies |
| 244 |
run: cargo update -Zdirect-minimal-versions |
| 245 |
|
| 246 |
- name: Build |
| 247 |
run: cargo build --workspace --all-targets --release |
| 248 |
|
| 249 |
- name: Run tests |
| 250 |
run: cargo test --workspace --all-targets --release |
| 251 |
|
| 252 |
build-and-test-msrv: |
| 253 |
runs-on: ubuntu-latest |
| 254 |
|
| 255 |
steps: |
| 256 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 257 |
with: |
| 258 |
persist-credentials: false |
| 259 |
|
| 260 |
- name: Correct permissions |
| 261 |
run: sudo chmod -R 755 /usr/share |
| 262 |
|
| 263 |
- name: Install rust 1.85 |
| 264 |
run: rustup override set 1.85 |
| 265 |
|
| 266 |
- name: Install dependencies |
| 267 |
run: | |
| 268 |
sudo apt update |
| 269 |
sudo apt install libpam0g-dev |
| 270 |
|
| 271 |
- name: Register rust problem matcher |
| 272 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 273 |
|
| 274 |
- name: Build |
| 275 |
run: cargo build --workspace --all-targets --release |
| 276 |
|
| 277 |
- name: Run tests |
| 278 |
run: cargo test --workspace --all-targets --release |
| 279 |
|
| 280 |
- name: Check test framework |
| 281 |
run: cd test-framework && cargo check --workspace --all-targets |
| 282 |
|
| 283 |
build-and-test-fedora: |
| 284 |
runs-on: ubuntu-latest |
| 285 |
container: fedora:latest |
| 286 |
|
| 287 |
steps: |
| 288 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 289 |
with: |
| 290 |
persist-credentials: false |
| 291 |
|
| 292 |
- name: Install dependencies |
| 293 |
run: | |
| 294 |
dnf install -y cargo pam-devel |
| 295 |
|
| 296 |
- name: Register rust problem matcher |
| 297 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 298 |
|
| 299 |
- name: Reduce privileges |
| 300 |
run: | |
| 301 |
useradd builder |
| 302 |
chown builder . |
| 303 |
|
| 304 |
- name: Build |
| 305 |
run: sudo -ubuilder cargo build --workspace --all-targets --release |
| 306 |
|
| 307 |
- name: Run tests |
| 308 |
run: sudo -ubuilder cargo test --workspace --all-targets --release |
| 309 |
|
| 310 |
build-and-test-alpine: |
| 311 |
runs-on: ubuntu-latest |
| 312 |
container: alpine:latest |
| 313 |
|
| 314 |
steps: |
| 315 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 316 |
with: |
| 317 |
persist-credentials: false |
| 318 |
|
| 319 |
- name: Install dependencies |
| 320 |
run: | |
| 321 |
apk add cargo linux-pam-dev sudo tzdata coreutils-fmt |
| 322 |
|
| 323 |
- name: Register rust problem matcher |
| 324 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 325 |
|
| 326 |
- name: Reduce privileges |
| 327 |
run: | |
| 328 |
adduser --disabled-password builder |
| 329 |
chown builder . |
| 330 |
|
| 331 |
- name: Build |
| 332 |
run: sudo -ubuilder cargo build --workspace --all-targets --release |
| 333 |
|
| 334 |
- name: Run tests |
| 335 |
run: | |
| 336 |
# Alpine hasn't done usr-merge yet |
| 337 |
sudo -ubuilder cargo test --workspace --all-targets --release \ |
| 338 |
-- --skip canonicalization --skip test_build_run_context |
| 339 |
|
| 340 |
build-and-test-32bit: |
| 341 |
runs-on: ubuntu-latest |
| 342 |
|
| 343 |
steps: |
| 344 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 345 |
with: |
| 346 |
persist-credentials: false |
| 347 |
|
| 348 |
- name: Correct permissions |
| 349 |
run: sudo chmod -R 755 /usr/share |
| 350 |
|
| 351 |
- name: Add 32-bit target |
| 352 |
run: | |
| 353 |
rustup target add i686-unknown-linux-gnu |
| 354 |
|
| 355 |
- name: Install dependencies |
| 356 |
run: | |
| 357 |
sudo dpkg --add-architecture i386 |
| 358 |
sudo apt update |
| 359 |
sudo apt install libpam0g-dev:i386 gcc-multilib |
| 360 |
|
| 361 |
- name: Register rust problem matcher |
| 362 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 363 |
|
| 364 |
- name: Build |
| 365 |
run: cargo build --target i686-unknown-linux-gnu --workspace --all-targets --release |
| 366 |
|
| 367 |
- name: Run tests |
| 368 |
run: cargo test --target i686-unknown-linux-gnu --workspace --all-targets --release |
| 369 |
|
| 370 |
miri: |
| 371 |
needs: build-and-test |
| 372 |
runs-on: ubuntu-latest |
| 373 |
|
| 374 |
steps: |
| 375 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 376 |
with: |
| 377 |
persist-credentials: false |
| 378 |
|
| 379 |
- name: Install nightly rust and miri |
| 380 |
run: | |
| 381 |
rustup set profile minimal |
| 382 |
rustup override set nightly |
| 383 |
rustup component add miri |
| 384 |
|
| 385 |
- name: Register rust problem matcher |
| 386 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 387 |
|
| 388 |
- name: Run tests |
| 389 |
run: cargo miri test --workspace miri |
| 390 |
|
| 391 |
check-bindings: |
| 392 |
runs-on: ubuntu-latest |
| 393 |
|
| 394 |
steps: |
| 395 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 396 |
with: |
| 397 |
persist-credentials: false |
| 398 |
|
| 399 |
- name: Install dependencies |
| 400 |
run: | |
| 401 |
sudo apt update |
| 402 |
sudo apt install libpam0g-dev |
| 403 |
|
| 404 |
- name: Install rust-bindgen |
| 405 |
uses: taiki-e/install-action@8f531eaecd1898bc3da7d104ad91bee98d1b97bd |
| 406 |
with: |
| 407 |
tool: [email protected] |
| 408 |
|
| 409 |
- name: Install cargo-minify |
| 410 |
run: cargo install --locked --git https://github.com/tweedegolf/cargo-minify cargo-minify |
| 411 |
|
| 412 |
- name: Regenerate bindings |
| 413 |
run: make -B pam-sys |
| 414 |
|
| 415 |
- name: Check for differences |
| 416 |
run: git diff --exit-code |
| 417 |
|
| 418 |
format: |
| 419 |
runs-on: ubuntu-latest |
| 420 |
env: |
| 421 |
RUSTDOCFLAGS: "-D warnings" |
| 422 |
steps: |
| 423 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 424 |
with: |
| 425 |
persist-credentials: false |
| 426 |
|
| 427 |
- name: Run rustfmt |
| 428 |
run: | |
| 429 |
cargo fmt --all -- --check |
| 430 |
cargo fmt --manifest-path test-framework/Cargo.toml --all -- --check |
| 431 |
|
| 432 |
clippy: |
| 433 |
needs: format |
| 434 |
runs-on: ubuntu-latest |
| 435 |
env: |
| 436 |
RUSTDOCFLAGS: "-D warnings" |
| 437 |
steps: |
| 438 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 439 |
with: |
| 440 |
persist-credentials: false |
| 441 |
|
| 442 |
- name: Register rust problem matcher |
| 443 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 444 |
|
| 445 |
- name: Run clippy |
| 446 |
run: cargo clippy --no-deps --all-targets -- --deny warnings |
| 447 |
|
| 448 |
docs: |
| 449 |
needs: clippy |
| 450 |
runs-on: ubuntu-latest |
| 451 |
env: |
| 452 |
RUSTDOCFLAGS: "-D warnings" |
| 453 |
steps: |
| 454 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 455 |
with: |
| 456 |
persist-credentials: false |
| 457 |
|
| 458 |
- name: Register rust problem matcher |
| 459 |
run: echo "::add-matcher::.github/problem-matchers/rust.json" |
| 460 |
|
| 461 |
- name: Build docs |
| 462 |
run: cargo doc --no-deps --document-private-items |
| 463 |
|
| 464 |
- name: Check CLI consistency |
| 465 |
run: | |
| 466 |
result="" |
| 467 |
documented_flags=$(grep -Eoe '"--?[A-Za-z][^"]*"' src/sudo/cli/mod.rs | tr -d '"' | sort -u | grep -v -e '-[EH]' -e '--set-home') |
| 468 |
for flag in $documented_flags; do |
| 469 |
for doc in src/sudo/cli/help.rs docs/man/sudo.8.md; do |
| 470 |
if ! grep -qFe "$flag" "$doc"; then |
| 471 |
result=failed; echo option "'$flag'" missing from "$doc" |
| 472 |
fi |
| 473 |
done |
| 474 |
done |
| 475 |
test -z "$result" |
| 476 |
|
| 477 |
gettext: |
| 478 |
runs-on: ubuntu-latest |
| 479 |
steps: |
| 480 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 481 |
with: |
| 482 |
persist-credentials: false |
| 483 |
|
| 484 |
- name: Install gettext |
| 485 |
run: | |
| 486 |
sudo apt update |
| 487 |
sudo apt install gettext |
| 488 |
|
| 489 |
- name: Check translation consistency |
| 490 |
run: | |
| 491 |
result="" |
| 492 |
for file in po/*.po; do msgfmt --verbose --check "$file" || result=failed; done |
| 493 |
test -z "$result" |
| 494 |
|
| 495 |
audit: |
| 496 |
needs: clippy |
| 497 |
runs-on: ubuntu-latest |
| 498 |
steps: |
| 499 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 500 |
with: |
| 501 |
persist-credentials: false |
| 502 |
|
| 503 |
- name: Install cargo-audit |
| 504 |
uses: taiki-e/install-action@8f531eaecd1898bc3da7d104ad91bee98d1b97bd |
| 505 |
with: |
| 506 |
tool: cargo-audit |
| 507 |
|
| 508 |
- name: Run audit |
| 509 |
run: cargo audit |