Debian Codegraph @

.github/workflows/CICD.yml

raw
1 name: CICD
2
3 # spell-checker:ignore (abbrev/names) CACHEDIR CICD CodeCOV MacOS MinGW MSVC musl taiki
4 # spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic CARGOFLAGS CLEVEL nodocs
5 # spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata profraw Cprofile
6 # spell-checker:ignore (people) Peltoche rivy Anson dawidd
7 # spell-checker:ignore (shell/tools) binutils choco clippy dmake esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libcrypto libfuse libssl limactl nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache setfacl utmpdump xargs zstd
8 # spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest tempfile testsuite toybox uutils libsystemd codspeed wasip libexecinfo
9
10 env:
11 PROJECT_NAME: coreutils
12 PROJECT_DESC: "Core universal (cross-platform) utilities"
13 PROJECT_AUTH: "uutils"
14 RUST_MIN_SRV: "1.88.0"
15 CARGO_INCREMENTAL: "0"
16 # * style job configuration
17 STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis
18
19 on:
20 pull_request:
21 push:
22 tags:
23 - '*'
24 branches:
25 - '*'
26
27 permissions:
28 contents: read # to fetch code (actions/checkout)
29
30 # End the current execution if there is a new changeset in the PR.
31 concurrency:
32 group: ${{ github.workflow }}-${{ github.ref }}
33 cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
34
35 jobs:
36 cargo-deny:
37 name: Style/cargo-deny
38 runs-on: ubuntu-latest
39 steps:
40 - uses: actions/[email protected]
41 with:
42 persist-credentials: false
43 - uses: EmbarkStudios/cargo-deny-action@v2
44
45 style_deps:
46 ## ToDO: [2021-11-10; rivy] 'Style/deps' needs more informative output and better integration of results into the GHA dashboard
47 name: Style/deps
48 runs-on: ${{ matrix.job.os }}
49 strategy:
50 fail-fast: false
51 matrix:
52 job:
53 # note: `cargo-udeps` panics when processing stdbuf/libstdbuf ("uu_stdbuf_libstdbuf"); either b/c of the 'cpp' crate or 'libstdbuf' itself
54 # ... b/c of the panic, a more limited feature set is tested (though only excluding `stdbuf`)
55 - { os: ubuntu-latest , features: "feat_Tier1,feat_require_unix,feat_require_unix_utmpx" }
56 - { os: macos-latest , features: "feat_Tier1,feat_require_unix,feat_require_unix_utmpx" }
57 - { os: windows-latest , features: feat_os_windows }
58 steps:
59 - uses: actions/[email protected]
60 with:
61 persist-credentials: false
62 - uses: taiki-e/install-action@cargo-udeps
63 - uses: Swatinem/rust-cache@v2
64 - name: Initialize workflow variables
65 id: vars
66 shell: bash
67 run: |
68 echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" # Use -Z
69 ## VARs setup
70 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
71 # failure mode
72 unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
73 ''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
74 *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
75 esac;
76 outputs FAIL_ON_FAULT FAULT_TYPE
77 # target-specific options
78 # * CARGO_FEATURES_OPTION
79 CARGO_FEATURES_OPTION='' ;
80 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
81 outputs CARGO_FEATURES_OPTION
82 - name: Detect unused dependencies
83 shell: bash
84 run: |
85 ## Detect unused dependencies
86 unset fault
87 fault_type="${{ steps.vars.outputs.FAULT_TYPE }}"
88 fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]')
89 #
90 cargo udeps ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --all-targets &> udeps.log || cat udeps.log
91 grep --ignore-case "all deps seem to have been used" udeps.log || { printf "%s\n" "::${fault_type} ::${fault_prefix}: \`cargo udeps\`: style violation (unused dependency found)" ; fault=true ; }
92 if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi
93
94 doc_warnings:
95 name: Documentation/warnings
96 runs-on: ${{ matrix.job.os }}
97 strategy:
98 fail-fast: false
99 matrix:
100 job:
101 - { os: ubuntu-latest , features: feat_os_unix }
102 # for now, don't build it on mac & windows because the doc is only published from linux
103 # + it needs a bunch of duplication for build
104 # and I don't want to add a doc step in the regular build to avoid long builds
105 # - { os: macos-latest , features: feat_os_unix }
106 # - { os: windows-latest , features: feat_os_windows }
107 steps:
108 - uses: actions/[email protected]
109 with:
110 persist-credentials: false
111 - uses: Swatinem/rust-cache@v2
112 - name: Run sccache-cache
113 id: sccache-setup
114 uses: mozilla-actions/[email protected]
115 continue-on-error: true
116 - name: Export sccache
117 if: steps.sccache-setup.outcome == 'success'
118 run: |
119 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
120 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
121 - name: Install/setup prerequisites
122 shell: bash
123 run: |
124 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
125 - name: Initialize workflow variables
126 id: vars
127 shell: bash
128 run: |
129 ## VARs setup
130 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
131 # failure mode
132 unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
133 ''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
134 *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
135 esac;
136 outputs FAIL_ON_FAULT FAULT_TYPE
137 # target-specific options
138 # * CARGO_FEATURES_OPTION
139 CARGO_FEATURES_OPTION='--all-features' ;
140 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features ${{ matrix.job.features }}' ; fi
141 outputs CARGO_FEATURES_OPTION
142 # * determine sub-crate utility list
143 UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})"
144 echo UTILITY_LIST=${UTILITY_LIST}
145 CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)"
146 outputs CARGO_UTILITY_LIST_OPTIONS
147 - name: "`cargo doc` with warnings"
148 shell: bash
149 run: |
150 RUSTDOCFLAGS="-Dwarnings" cargo doc ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-deps --workspace --document-private-items
151 - uses: DavidAnson/markdownlint-cli2-action@v24
152 with:
153 fix: "true"
154 globs: |
155 *.md
156 docs/src/*.md
157 src/uu/*/*.md
158
159 min_version:
160 name: MinRustV # Minimum supported rust version (aka, MinSRV or MSRV)
161 runs-on: ${{ matrix.job.os }}
162 strategy:
163 matrix:
164 job:
165 - { os: ubuntu-latest , features: feat_os_unix }
166 steps:
167 - uses: actions/[email protected]
168 with:
169 persist-credentials: false
170 - uses: dtolnay/rust-toolchain@master
171 with:
172 toolchain: ${{ env.RUST_MIN_SRV }}
173 components: rustfmt
174 - uses: taiki-e/install-action@nextest
175 - uses: Swatinem/rust-cache@v2
176 - name: Run sccache-cache
177 id: sccache-setup
178 uses: mozilla-actions/[email protected]
179 continue-on-error: true
180 - name: Export sccache
181 if: steps.sccache-setup.outcome == 'success'
182 run: |
183 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
184 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
185 - name: Initialize workflow variables
186 id: vars
187 shell: bash
188 run: |
189 ## VARs setup
190 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
191 # target-specific options
192 # * CARGO_FEATURES_OPTION
193 unset CARGO_FEATURES_OPTION
194 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
195 outputs CARGO_FEATURES_OPTION
196 - name: Confirm MinSRV compatible '*/Cargo.lock'
197 shell: bash
198 run: |
199 ## Confirm MinSRV compatible '*/Cargo.lock'
200 # * '*/Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
201 for dir in "." "fuzz"; do
202 ( cd "$dir" && cargo fetch --locked --quiet --target $(rustc --print host-tuple)) || { echo "::error file=$dir/Cargo.lock::Incompatible (or out-of-date) '$dir/Cargo.lock' file; update using \`cd '$dir' && cargo +${{ env.RUST_MIN_SRV }} update\`" ; exit 1 ; }
203 done
204 - name: Install/setup prerequisites
205 shell: bash
206 run: |
207 # Install a package for one of the tests
208 sudo apt-get -y update ; sudo apt-get -y install attr
209 - name: Info
210 shell: bash
211 run: |
212 ## Info
213 # environment
214 echo "## environment"
215 echo "CI='${CI}'"
216 # tooling info display
217 echo "## tooling"
218 which gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
219 rustup -V 2>/dev/null
220 rustup show active-toolchain
221 cargo -V
222 rustc -V
223 cargo tree -V
224 # dependencies
225 echo "## dependency list"
226 ## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
227 cargo +stable fetch --locked --quiet --target $(rustc --print host-tuple)
228 cargo +stable tree --no-dedupe --locked -e=no-dev --prefix=none ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} | grep -vE "$PWD" | sort --unique
229 - name: Test
230 run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -p uucore -p coreutils
231 env:
232 RUSTFLAGS: "-Awarnings"
233 RUST_BACKTRACE: "1"
234 - name: Upload test results to Codecov
235 if: ${{ !cancelled() }}
236 uses: codecov/codecov-action@v7
237 with:
238 token: ${{ secrets.CODECOV_TOKEN }}
239 report_type: test_results
240 files: target/nextest/ci/junit.xml
241 disable_search: true
242 flags: msrv,${{ matrix.job.os }}
243 fail_ci_if_error: false
244
245 deps:
246 name: Dependencies
247 runs-on: ${{ matrix.job.os }}
248 strategy:
249 fail-fast: false
250 matrix:
251 job:
252 - { os: ubuntu-latest , features: feat_os_unix }
253 steps:
254 - uses: actions/[email protected]
255 with:
256 persist-credentials: false
257 - name: "`cargo update` testing"
258 shell: bash
259 run: |
260 ## `cargo update` testing
261 # * convert any errors/warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
262 for dir in "." "fuzz"; do
263 ( cd "$dir" && cargo fetch --locked --quiet --target host-tuple) || { echo "::error file=$dir/Cargo.lock::'$dir/Cargo.lock' file requires update (use \`cd '$dir' && cargo +${{ env.RUST_MIN_SRV }} update\`)" ; exit 1 ; }
264 done
265
266 build_rust_stable:
267 name: Build/stable
268 needs: [ min_version, deps ]
269 runs-on: ${{ matrix.job.os }}
270 timeout-minutes: 90
271 strategy:
272 fail-fast: false
273 matrix:
274 job:
275 - { os: ubuntu-latest , features: feat_os_unix }
276 - { os: macos-latest , features: feat_os_unix }
277 - { os: windows-latest , features: feat_os_windows }
278 steps:
279 - uses: actions/[email protected]
280 with:
281 persist-credentials: false
282 - uses: dtolnay/rust-toolchain@stable
283 - uses: taiki-e/install-action@nextest
284 - uses: Swatinem/rust-cache@v2
285 - name: Run sccache-cache
286 id: sccache-setup
287 uses: mozilla-actions/[email protected]
288 continue-on-error: true
289 - name: Export sccache
290 if: steps.sccache-setup.outcome == 'success'
291 run: |
292 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
293 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
294 - name: Test
295 run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }}
296 env:
297 RUST_BACKTRACE: "1"
298 - name: Upload test results to Codecov
299 if: ${{ !cancelled() }}
300 uses: codecov/codecov-action@v7
301 with:
302 token: ${{ secrets.CODECOV_TOKEN }}
303 report_type: test_results
304 files: target/nextest/ci/junit.xml
305 disable_search: true
306 flags: stable,${{ matrix.job.os }}
307 fail_ci_if_error: false
308
309 build_rust_nightly:
310 name: Build/nightly
311 needs: [ min_version, deps ]
312 runs-on: ${{ matrix.job.os }}
313 timeout-minutes: 90
314 strategy:
315 fail-fast: false
316 matrix:
317 job:
318 - { os: ubuntu-latest , features: feat_os_unix }
319 - { os: macos-latest , features: feat_os_unix }
320 - { os: windows-latest , features: feat_os_windows }
321 steps:
322 - uses: actions/[email protected]
323 with:
324 persist-credentials: false
325 - uses: dtolnay/rust-toolchain@nightly
326 - uses: taiki-e/install-action@nextest
327 - uses: Swatinem/rust-cache@v2
328 - name: Run sccache-cache
329 id: sccache-setup
330 uses: mozilla-actions/[email protected]
331 continue-on-error: true
332 - name: Export sccache
333 if: steps.sccache-setup.outcome == 'success'
334 run: |
335 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
336 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
337 - name: Test
338 run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }}
339 env:
340 RUST_BACKTRACE: "1"
341 - name: Upload test results to Codecov
342 if: ${{ !cancelled() }}
343 uses: codecov/codecov-action@v7
344 with:
345 token: ${{ secrets.CODECOV_TOKEN }}
346 report_type: test_results
347 files: target/nextest/ci/junit.xml
348 disable_search: true
349 flags: nightly,${{ matrix.job.os }}
350 fail_ci_if_error: false
351
352 build:
353 permissions:
354 contents: write # to create GitHub release (softprops/action-gh-release)
355
356 name: Build
357 needs: [ min_version, deps ]
358 runs-on: ${{ matrix.job.os }}
359 timeout-minutes: 90
360 env:
361 DOCKER_OPTS: '--volume /etc/passwd:/etc/passwd --volume /etc/group:/etc/group'
362 strategy:
363 fail-fast: false
364 matrix:
365 job:
366 # - { os , target , default-features, features , use-cross , toolchain, skip-tests, workspace-tests, skip-package, skip-publish }
367 # `pgo: PGO` marks a published target whose instrumented binary the
368 # runner can execute, which is what training a profile needs. It is
369 # therefore off for the `cross` targets (no emulator) and the wasm
370 # ones (no runtime). The value is spelled `PGO` because GitHub appends
371 # the matrix values to the job title, so those jobs read as
372 # "Build (..., x86_64-unknown-linux-gnu, ..., PGO)".
373 # enable openssl for performance if min_version: already tests pore-Rust checksum crates
374 - { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross , skip-tests: true }
375 - { os: ubuntu-24.04-arm , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf, pgo: PGO }
376 - { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
377 - { os: ubuntu-latest , target: riscv64gc-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
378 # - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_selinux , use-cross: use-cross }
379 - { os: ubuntu-latest , target: i686-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
380 - { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
381 - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross, skip-publish: true }
382 - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,openssl,uudoc" , use-cross: no, workspace-tests: true, pgo: PGO }
383 - { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
384 - { os: ubuntu-latest , target: x86_64-unknown-netbsd, features: "feat_os_unix", use-cross: use-cross , skip-tests: true , check-only: true }
385 # - { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true , check-only: true }
386 - { os: ubuntu-latest , target: wasm32-wasip1, default-features: false, features: feat_wasm, skip-tests: true }
387 - { os: ubuntu-latest , target: wasm32-wasip2, default-features: false, features: feat_wasm, skip-tests: true }
388 - { os: macos-latest , target: aarch64-apple-darwin , features: "feat_os_unix,openssl", workspace-tests: true, pgo: PGO } # M1 CPU
389 # PR #7964: chcon should not break build without the feature. cargo check is enough to detect it.
390 - { os: macos-latest , target: aarch64-apple-darwin , workspace-tests: true, check-only: true } # M1 CPU
391 - { os: macos-latest , target: x86_64-apple-darwin , features: feat_os_unix, workspace-tests: true, pgo: PGO }
392 - { os: windows-latest , target: i686-pc-windows-msvc , features: feat_os_windows }
393 # msvc and gnu works on the same target. So publishing msvc is enough.
394 - { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows, skip-publish: true }
395 # todo: enable static openssl via vcpkg for performance
396 - { os: windows-latest , target: x86_64-pc-windows-msvc , features: "feat_os_windows,openssl", pgo: PGO }
397 # No `pgo` here: on aarch64-pc-windows-msvc the instrumented binary
398 # writes .profraw files whose name table llvm-profdata rejects with
399 # "symbol name is empty", so every profile is unusable. Upstream bugs:
400 # https://github.com/rust-lang/rust/issues/150123 (same message with
401 # `-C instrument-coverage`) and https://github.com/rust-lang/rust/issues/156675.
402 - { os: windows-11-arm , target: aarch64-pc-windows-msvc , features: feat_os_windows }
403 steps:
404 - uses: actions/[email protected]
405 with:
406 persist-credentials: false
407 - name: Avoid no space left on device
408 shell: bash
409 run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android &
410 - uses: dtolnay/rust-toolchain@master
411 with:
412 toolchain: ${{ env.RUST_MIN_SRV }}
413 targets: ${{ matrix.job.target }}
414 - uses: Swatinem/rust-cache@v2
415 with:
416 key: "${{ matrix.job.os }}_${{ matrix.job.target }}"
417 - name: Run sccache-cache
418 id: sccache-setup
419 uses: mozilla-actions/[email protected]
420 continue-on-error: true
421 - name: Export sccache
422 if: steps.sccache-setup.outcome == 'success'
423 run: |
424 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
425 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
426 - name: Initialize workflow variables
427 id: vars
428 shell: bash
429 run: |
430 ## VARs setup
431 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
432 # toolchain
433 TOOLCHAIN="stable" ## default to "stable" toolchain
434 # * specify alternate/non-default TOOLCHAIN for *-pc-windows-gnu targets; gnu targets on Windows are broken for the standard *-pc-windows-msvc toolchain (refs: GH:rust-lang/rust#47048, GH:rust-lang/rust#53454, GH:rust-lang/cargo#6754)
435 case ${{ matrix.job.target }} in *-pc-windows-gnu) TOOLCHAIN="stable-${{ matrix.job.target }}" ;; esac;
436 # * use requested TOOLCHAIN if specified
437 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
438 outputs TOOLCHAIN
439 # staging directory
440 STAGING='_staging'
441 outputs STAGING
442 # parse commit reference info
443 echo GITHUB_REF=${GITHUB_REF}
444 echo GITHUB_SHA=${GITHUB_SHA}
445 REF_NAME=${GITHUB_REF#refs/*/}
446 unset REF_BRANCH ; case "${GITHUB_REF}" in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/} ;; esac;
447 unset REF_TAG ; case "${GITHUB_REF}" in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
448 REF_SHAS=${GITHUB_SHA:0:10}
449 outputs REF_NAME REF_BRANCH REF_TAG REF_SHAS
450 # parse target
451 unset TARGET_ARCH
452 case '${{ matrix.job.target }}' in
453 aarch64-*) TARGET_ARCH=arm64 ;;
454 riscv64gc-*) TARGET_ARCH=riscv64 ;;
455 arm-*-*hf) TARGET_ARCH=armhf ;;
456 i686-*) TARGET_ARCH=i686 ;;
457 x86_64-*) TARGET_ARCH=x86_64 ;;
458 esac;
459 unset TARGET_OS
460 case '${{ matrix.job.target }}' in
461 *-linux-*) TARGET_OS=linux ;;
462 *-apple-*) TARGET_OS=macos ;;
463 *-windows-*) TARGET_OS=windows ;;
464 *-redox*) TARGET_OS=redox ;;
465 esac
466 outputs TARGET_ARCH TARGET_OS
467 # package name
468 PKG_suffix=".tar.gz" ; case '${{ matrix.job.target }}' in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
469 # Some 3rd party utils need version at file names
470 # But we remove it from tag/latest-commit
471 test ${REF_TAG} \
472 && PKG_BASENAME=${PROJECT_NAME}-${REF_TAG}-${{ matrix.job.target }} \
473 || PKG_BASENAME=${PROJECT_NAME}-${{ matrix.job.target }}
474 PKG_NAME=${PKG_BASENAME}${PKG_suffix}
475 outputs PKG_suffix PKG_BASENAME PKG_NAME
476 # deployable tag? (ie, leading "vM" or "M"; M == version number)
477 unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
478 outputs DEPLOY
479 # target-specific options
480 # * CARGO_FEATURES_OPTION
481 CARGO_FEATURES_OPTION='' ;
482 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
483 outputs CARGO_FEATURES_OPTION
484 # * CARGO_DEFAULT_FEATURES_OPTION
485 CARGO_DEFAULT_FEATURES_OPTION='' ;
486 if [ "${{ matrix.job.default-features }}" == "false" ]; then CARGO_DEFAULT_FEATURES_OPTION='--no-default-features' ; fi
487 outputs CARGO_DEFAULT_FEATURES_OPTION
488 # * CARGO_CMD
489 CARGO_CMD='cross'
490 CARGO_CMD_OPTIONS='+${{ env.RUST_MIN_SRV }}'
491 # Added suffix for artifacts, needed when multiple jobs use the same target.
492 ARTIFACTS_SUFFIX=''
493 case '${{ matrix.job.use-cross }}' in
494 ''|0|f|false|n|no)
495 CARGO_CMD='cargo'
496 ARTIFACTS_SUFFIX='-nocross'
497 ;;
498 redoxer)
499 CARGO_CMD='redoxer'
500 CARGO_CMD_OPTIONS=''
501 ;;
502 esac
503 # needed for target "aarch64-apple-darwin". There are two jobs, and the difference between them is whether "features" is set
504 if [ -z "${{ matrix.job.features }}" ]; then ARTIFACTS_SUFFIX='-nofeatures' ; fi
505 outputs CARGO_CMD
506 outputs CARGO_CMD_OPTIONS
507 outputs ARTIFACTS_SUFFIX
508 CARGO_TEST_OPTIONS=''
509 case '${{ matrix.job.workspace-tests }}' in
510 1|t|true|y|yes)
511 # This also runs tests in other packages in the source directory (e.g. uucore).
512 # We cannot enable this everywhere as some platforms are currently broken, and
513 # we cannot use `cross` as its Docker image is ancient (Ubuntu 16.04) and is
514 # missing required system dependencies (e.g. recent libclang-dev).
515 CARGO_TEST_OPTIONS='--workspace'
516 ;;
517 esac
518 - uses: taiki-e/install-action@v2
519 # `cross` v0.2.5 lacks `libexecinfo` on NetBSD. However, this has been added in main.
520 # See https://github.com/cross-rs/cross/blob/main/docker/netbsd.sh
521 # We are pulling cross from a specific commit hash rather than HEAD to avoid any potential breakage that may be introduced.
522 # Once `cross` v0.3 is out, these conditionals can be removed.
523 if: steps.vars.outputs.CARGO_CMD == 'cross' && matrix.job.target != 'x86_64-unknown-netbsd'
524 with:
525 tool: [email protected]
526 - name: Install cross from git (NetBSD)
527 if: steps.vars.outputs.CARGO_CMD == 'cross' && matrix.job.target == 'x86_64-unknown-netbsd'
528 run: cargo install cross --git https://github.com/cross-rs/cross --rev f86fd03bb70b4c6802847c18087e21391498b0b4
529 - name: Create all needed build/work directories
530 shell: bash
531 run: |
532 ## Create build/work space
533 mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
534 - name: Install/setup prerequisites
535 shell: bash
536 run: |
537 ## Install/setup prerequisites
538 case '${{ matrix.job.target }}' in
539 arm-unknown-linux-gnueabihf)
540 sudo apt-get -y update
541 sudo apt-get -y install gcc-arm-linux-gnueabihf
542 ;;
543 aarch64-unknown-linux-*)
544 sudo apt-get -y update
545 sudo apt-get -y install gcc-aarch64-linux-gnu
546 ;;
547 riscv64gc-unknown-linux-*)
548 sudo apt-get -y update
549 sudo apt-get -y install gcc-riscv64-linux-gnu
550 ;;
551 *-redox*)
552 sudo apt-get -y update
553 sudo apt-get -y install fuse3 libfuse-dev
554 ;;
555 esac
556 case '${{ matrix.job.os }}' in
557 ubuntu-*)
558 # selinux and systemd headers needed to build tests
559 sudo apt-get -y update
560 sudo apt-get -y install libselinux1-dev libsystemd-dev
561 # pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
562 # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing.
563 # The account also has empty gecos fields.
564 # To work around these issues for pinky (and who) tests, we create a fake utmp file with a
565 # system boot entry and a login entry for the GH runner account.
566 FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]'
567 FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
568 (echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp
569 # ... and add a full name to each account with a gecos field but no full name.
570 sudo sed -i 's/:,/:runner name,/' /etc/passwd
571 # We also create a couple optional files pinky looks for
572 touch /home/runner/.project
573 echo "foo" > /home/runner/.plan
574 # add user with digital username for testing with issue #7787
575 echo 200:x:2000:2000::/home/200:/bin/bash | sudo tee -a /etc/passwd
576 echo 200:x:2000: | sudo tee -a /etc/group
577 ;;
578 esac
579 - uses: taiki-e/install-action@v2
580 if: steps.vars.outputs.CARGO_CMD == 'redoxer'
581 with:
582 tool: [email protected]
583 - name: Initialize toolchain-dependent workflow variables
584 id: dep_vars
585 shell: bash
586 run: |
587 ## Dependent VARs setup
588 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
589 # * determine sub-crate utility list
590 UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})"
591 echo UTILITY_LIST=${UTILITY_LIST}
592 CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)"
593 outputs CARGO_UTILITY_LIST_OPTIONS
594 - name: Info
595 shell: bash
596 run: |
597 ## Info
598 # commit info
599 echo "## commit"
600 echo GITHUB_REF=${GITHUB_REF}
601 echo GITHUB_SHA=${GITHUB_SHA}
602 # environment
603 echo "## environment"
604 echo "CI='${CI}'"
605 # tooling info display
606 echo "## tooling"
607 which gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
608 rustup -V 2>/dev/null
609 rustup show active-toolchain
610 cargo -V
611 rustc -V
612 cargo tree -V
613 # dependencies
614 echo "## dependency list"
615 cargo fetch --locked --quiet --target $(rustc --print host-tuple)
616 cargo tree --locked --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }} --no-dedupe -e=no-dev --prefix=none | grep -vE "$PWD" | sort --unique
617 - name: Check
618 shell: bash
619 if: matrix.job.skip-publish != true && matrix.job.check-only == true
620 run: |
621 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} check \
622 --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
623 - name: Test
624 if: matrix.job.skip-tests != true && matrix.job.check-only != true
625 shell: bash
626 run: |
627 ## Test
628 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} test --target=${{ matrix.job.target }} \
629 ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }} \
630 ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -p coreutils
631 env:
632 RUST_BACKTRACE: "1"
633 - name: Install llvm-tools (PGO)
634 if: matrix.job.pgo
635 shell: bash
636 run: rustup component add llvm-tools
637 - name: Train PGO profiles
638 if: matrix.job.pgo
639 shell: bash
640 run: |
641 ## The target dir is relative: on Windows `github.workspace` is a
642 ## backslash path that git-bash would not resolve. The script writes the
643 ## profile's absolute path (natively spelled) to profdata-path.txt.
644 ./util/build-pgo.sh \
645 --target "${{ matrix.job.target }}" \
646 --target-dir target/coreutils-pgo \
647 --features "${{ matrix.job.features }}" \
648 --train-only
649 echo "RUSTFLAGS=${RUSTFLAGS:+${RUSTFLAGS} }-Cprofile-use=$(cat target/coreutils-pgo/profdata-path.txt)" >> "$GITHUB_ENV"
650 - name: Verify PGO is applied to the published build
651 if: matrix.job.pgo
652 shell: bash
653 run: |
654 ## The release artifact must be the PGO build: if RUSTFLAGS did not
655 ## survive GITHUB_ENV we would silently publish an unoptimized binary.
656 echo "RUSTFLAGS=${RUSTFLAGS}"
657 case "${RUSTFLAGS}" in
658 *-Cprofile-use=*) ;;
659 *) echo "::error::-Cprofile-use missing from RUSTFLAGS" ; exit 1 ;;
660 esac
661 test -s "$(cat target/coreutils-pgo/profdata-path.txt)"
662 - name: Build coreutils
663 shell: bash
664 if: matrix.job.skip-publish != true && matrix.job.check-only != true && matrix.job.target != 'x86_64-pc-windows-msvc'
665 run: |
666 ## Build
667 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release --config=profile.release.strip=true \
668 --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
669 # We don't want to have many duplicated long jobs at here
670 # So we build individual binaries (including coreutils) for few platforms until we deduplicate many release build for Linux
671 - name: Build all binaries
672 if: matrix.job.skip-tests != true && matrix.job.target == 'x86_64-pc-windows-msvc'
673 shell: bash
674 run: |
675 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release --config=profile.release.strip=true \
676 --target=${{ matrix.job.target }} \
677 ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} \
678 -p coreutils --features=${{ matrix.job.features }}
679 - name: Package
680 if: matrix.job.skip-publish != true && matrix.job.check-only != true
681 shell: bash
682 run: |
683 ## Package artifact(s)
684 find target/${{ matrix.job.target }}/release -maxdepth 1 -type f \
685 \( -name "*.wasm" -o -name "*.exe" -o -perm -u+x \) \
686 -exec ln -v {} "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/" \;
687 # README and LICENSE
688 # * spell-checker:ignore EADME ICENSE
689 (shopt -s nullglob; for f in [R]"EADME"{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' ; done)
690 (shopt -s nullglob; for f in [L]"ICENSE"{-*,}{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' ; done)
691 # core compressed package
692 pushd '${{ steps.vars.outputs.STAGING }}/' >/dev/null
693 case '${{ matrix.job.target }}' in
694 *-pc-windows-*) 7z -y a '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* | tail -2 ;;
695 *) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
696 esac
697 popd >/dev/null
698 - name: Package manpages and completions
699 if: matrix.job.target == 'x86_64-unknown-linux-gnu' && matrix.job.features == 'feat_os_unix,uudoc'
700 run: |
701 mkdir -p share/{man/man1,bash-completion/completions,fish/vendor_completions.d,zsh/site-functions,elvish/lib}
702 _uudoc=target/${{ matrix.job.target }}/release/uudoc
703 for bin in $('target/${{ matrix.job.target }}/release/coreutils' --list) coreutils;do
704 ${_uudoc} manpage ${bin} > share/man/man1/${bin}.1
705 ${_uudoc} completion ${bin} bash > share/bash-completion/completions/${bin}.bash
706 ${_uudoc} completion ${bin} fish > share/fish/vendor_completions.d/${bin}.fish
707 ${_uudoc} completion ${bin} zsh > share/zsh/site-functions/_${bin}
708 ${_uudoc} completion ${bin} elvish > share/elvish/lib/${bin}.elv
709 done
710 rm share/zsh/site-functions/_[ # not supported
711 tar --zstd -cf docs.tar.zst share
712 - name: Publish
713 uses: softprops/action-gh-release@v3
714 if: steps.vars.outputs.DEPLOY && matrix.job.skip-publish != true && matrix.job.check-only != true
715 with:
716 draft: true
717 overwrite_files: true
718 files: |
719 ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
720 docs.tar.zst
721 env:
722 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
723 - name: Publish latest commit
724 uses: softprops/action-gh-release@v3
725 if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.job.skip-publish != true && matrix.job.check-only != true
726 with:
727 tag_name: latest-commit
728 body: |
729 commit: ${{ github.sha }}
730 draft: false
731 prerelease: true
732 files: |
733 ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
734 docs.tar.zst
735 env:
736 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
737
738 coverage:
739 name: Code Coverage
740 runs-on: ${{ matrix.job.os }}
741 timeout-minutes: 90
742 env:
743 RUSTC_BOOTSTRAP: 1
744 strategy:
745 fail-fast: false
746 matrix:
747 job:
748 - { os: ubuntu-latest , features: unix }
749 # FIXME: Re-enable macos code coverage
750 # - { os: macos-latest , features: macos }
751 # FIXME: Re-enable Code Coverage on windows, which currently fails due to "profiler_builtins". See #6686.
752 # - { os: windows-latest , features: windows, toolchain: stable-x86_64-pc-windows-gnu }
753 steps:
754 - uses: actions/[email protected]
755 with:
756 persist-credentials: false
757 - uses: taiki-e/install-action@v2
758 with:
759 tool: nextest,[email protected]
760 - uses: Swatinem/rust-cache@v2
761 - name: Run sccache-cache
762 id: sccache-setup
763 uses: mozilla-actions/[email protected]
764 continue-on-error: true
765 - name: Export sccache
766 if: steps.sccache-setup.outcome == 'success'
767 run: |
768 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
769 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
770
771 # - name: Reattach HEAD ## may be needed for accurate code coverage info
772 # run: git checkout ${{ github.head_ref }}
773
774 - name: Initialize workflow variables
775 id: vars
776 shell: bash
777 run: |
778 ## VARs setup
779 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
780
781 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
782 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
783
784 # * use requested TOOLCHAIN if specified
785 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
786 outputs TOOLCHAIN
787
788 # target-specific options
789
790 # * CARGO_FEATURES_OPTION
791 CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
792 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
793 outputs CARGO_FEATURES_OPTION
794
795 # * CODECOV_FLAGS
796 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
797 outputs CODECOV_FLAGS
798
799 - name: Install/setup prerequisites
800 shell: bash
801 run: |
802 ## Install/setup prerequisites
803 case '${{ matrix.job.os }}' in
804 ubuntu-latest)
805 # selinux and systemd headers needed to build tests
806 # acl: setfacl for coverage profile-trace dir default ACL (umask 0777 tests)
807 sudo apt-get -y update
808 sudo apt-get -y install libselinux1-dev libsystemd-dev acl
809 # pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
810 # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing.
811 # The account also has empty gecos fields.
812 # To work around these issues for pinky (and who) tests, we create a fake utmp file with a
813 # system boot entry and a login entry for the GH runner account.
814 FAKE_UTMP_2='[2] [00000] [~~ ] [reboot] [~ ] [6.0.0-test] [0.0.0.0] [2022-02-22T22:11:22,222222+00:00]'
815 FAKE_UTMP_7='[7] [999999] [tty2] [runner] [tty2] [ ] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
816 (echo "$FAKE_UTMP_2" ; echo "$FAKE_UTMP_7") | sudo utmpdump -r -o /var/run/utmp
817 # ... and add a full name to each account with a gecos field but no full name.
818 sudo sed -i 's/:,/:runner name,/' /etc/passwd
819 # We also create a couple optional files pinky looks for
820 touch /home/runner/.project
821 echo "foo" > /home/runner/.plan
822 # add user with digital username for testing with issue #7787
823 echo 200:x:2000:2000::/home/200:/bin/bash | sudo tee -a /etc/passwd
824 echo 200:x:2000: | sudo tee -a /etc/group
825 ;;
826 esac
827
828 ## Install the llvm-tools component to get access to `llvm-profdata`
829 rustup component add llvm-tools
830
831 - name: Run test and coverage
832 id: run_test_cov
833 run: |
834 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
835
836 # Run the coverage script
837 ./util/build-run-test-coverage-linux.sh
838
839 outputs REPORT_FILE
840 env:
841 COVERAGE_DIR: ${{ github.workspace }}/coverage
842 FEATURES_OPTION: ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
843 # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
844
845 - name: Upload coverage results (to Codecov.io)
846 uses: codecov/codecov-action@v7
847 with:
848 token: ${{ secrets.CODECOV_TOKEN }}
849 files: ${{ steps.run_test_cov.outputs.report }}
850 ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
851 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
852 name: codecov-umbrella
853 fail_ci_if_error: false
854 - name: Upload test results to Codecov
855 if: ${{ !cancelled() }}
856 uses: codecov/codecov-action@v7
857 with:
858 token: ${{ secrets.CODECOV_TOKEN }}
859 report_type: test_results
860 files: target/nextest/coverage/junit.xml
861 disable_search: true
862 flags: coverage,${{ matrix.job.os }}
863 fail_ci_if_error: false
864
865 test_openssl_dynamic:
866 name: Build/OpenSSL (dynamic)
867 needs: [ min_version, deps ]
868 runs-on: ${{ matrix.job.os }}
869 timeout-minutes: 60
870 strategy:
871 fail-fast: false
872 matrix:
873 job:
874 # Linux: exercises OPENSSL_NO_VENDOR=1 (dynamic against system libcrypto). ubuntu-latest ships libssl-dev
875 # binaries with OPENSSL_NO_VENDOR=0 are tested and published at build job
876 - { os: ubuntu-latest, features: "md5sum,sha1sum,sha224sum,sha256sum,sha384sum,sha512sum,cksum,openssl" }
877 # macOS: vendored only — system libcrypto needs OPENSSL_DIR
878 # pointing at Homebrew, which isn't worth wiring up for a smoke test.
879 # todo: check Windows (MinGW's system openssl)
880 steps:
881 - uses: actions/checkout@v7
882 with:
883 persist-credentials: false
884 - uses: taiki-e/install-action@nextest
885 - uses: Swatinem/rust-cache@v2
886 - name: Run sccache-cache
887 id: sccache-setup
888 uses: mozilla-actions/[email protected]
889 continue-on-error: true
890 - name: Export sccache
891 if: steps.sccache-setup.outcome == 'success'
892 run: |
893 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
894 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
895 - name: Test checksum utilities with OpenSSL (system / dynamic)
896 shell: bash
897 env:
898 OPENSSL_NO_VENDOR: "1"
899 RUST_BACKTRACE: "1"
900 run: |
901 cargo nextest run --hide-progress-bar --profile ci \
902 --no-default-features --features "${{ matrix.job.features }}"
903
904 test_no_diagnostics:
905 name: Build/No-diagnostics
906 needs: [ min_version, deps ]
907 runs-on: ubuntu-latest
908 timeout-minutes: 60
909 steps:
910 - uses: actions/checkout@v7
911 with:
912 persist-credentials: false
913 - uses: taiki-e/install-action@nextest
914 - uses: Swatinem/rust-cache@v2
915 - name: Run sccache-cache
916 id: sccache-setup
917 uses: mozilla-actions/[email protected]
918 continue-on-error: true
919 - name: Export sccache
920 if: steps.sccache-setup.outcome == 'success'
921 run: |
922 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
923 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
924 # The caret diagnostics (`feat_diagnostics`) are on by default; packagers
925 # who want the smaller dependency tree build with them off, so that build
926 # must stay green. The caret snapshot tests are gated on the feature and
927 # compile out; everything else runs as usual against the plain messages.
928 - name: Test without the diagnostics feature
929 shell: bash
930 env:
931 RUST_BACKTRACE: "1"
932 run: |
933 cargo nextest run --hide-progress-bar --profile ci \
934 --no-default-features --features feat_os_unix
935 # Confirm the feature actually compiles the renderer out. If ariadne is
936 # still in the tree, some crate re-grew a hard dependency on it.
937 # (`cargo tree -i` exits non-zero when the crate is absent from the graph.)
938 - name: Verify ariadne is compiled out
939 shell: bash
940 run: |
941 if cargo tree -p coreutils --no-default-features --features feat_os_unix -e normal -i ariadne 2>/dev/null; then
942 echo "ERROR: ariadne is still in the dependency tree without feat_diagnostics"
943 exit 1
944 fi
945 echo "OK: ariadne is not in the dependency tree"
946
947 test_selinux:
948 name: Build/SELinux
949 needs: [ min_version, deps ]
950 runs-on: ubuntu-latest
951 steps:
952 - uses: actions/[email protected]
953 with:
954 persist-credentials: false
955 - name: Setup Lima
956 uses: lima-vm/lima-actions/setup@v1
957 id: lima-actions-setup
958 - name: Cache ~/.cache/lima
959 uses: actions/cache@v6
960 with:
961 path: ~/.cache/lima
962 key: lima-${{ steps.lima-actions-setup.outputs.version }}
963 - name: Start Fedora VM with SELinux
964 run: limactl start --plain --name=default --cpus=4 --disk=30 --memory=4 --network=lima:user-v2 template:fedora
965 - run: rsync -v -a -e ssh . lima-default:~/work/
966 - name: Setup Rust and other build deps in VM
967 run: |
968 lima sudo dnf install --nodocs gcc g++ git rustup libselinux-devel clang-devel attr -y
969 lima rustup-init -y --default-toolchain stable --profile minimal -c clippy
970 - name: Verify SELinux Status
971 run: |
972 lima getenforce
973 lima ls -laZ /etc/selinux
974 - name: Build and Test with SELinux
975 run: |
976 lima ls
977 lima bash -c "cd work && cargo test --features 'feat_selinux' --no-default-features"
978 - name: Lint with SELinux
979 run: lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' --no-default-features -- -D warnings"
980
981 test_selinux_stubs:
982 name: Build/SELinux-Stubs (Non-Linux)
983 needs: [ min_version, deps ]
984 runs-on: ${{ matrix.job.os }}
985 strategy:
986 fail-fast: false
987 matrix:
988 job:
989 - { os: macos-latest , features: feat_os_unix }
990 - { os: windows-latest , features: feat_os_windows }
991
992 steps:
993 - uses: actions/[email protected]
994 with:
995 persist-credentials: false
996 - uses: Swatinem/rust-cache@v2
997 - name: Build SELinux utilities as stubs
998 run: cargo build -p uu_chcon -p uu_runcon
999 - name: Verify stub binaries exist
1000 shell: bash
1001 run: |
1002 test -f target/debug/chcon || test -f target/debug/chcon.exe
1003 test -f target/debug/runcon || test -f target/debug/runcon.exe
1004 # check is enough to detect workspace breakage by chcon
1005 - name: Verify workspace builds with stubs
1006 run: cargo check --features ${{ matrix.job.features }}
1007
1008 test_safe_traversal:
1009 name: Safe Traversal Security Check
1010 runs-on: ubuntu-latest
1011 needs: [ min_version, deps ]
1012
1013 steps:
1014 - uses: actions/[email protected]
1015 with:
1016 persist-credentials: false
1017 - uses: Swatinem/rust-cache@v2
1018 - name: Install strace and libselinux headers (needed to build chcon)
1019 run: sudo apt-get update && sudo apt-get install -y strace libselinux1-dev
1020 - name: Build utilities with safe traversal
1021 run: cargo build --profile=release-small -p uu_rm -p uu_chmod -p uu_chown -p uu_chgrp -p uu_mv -p uu_du -p uu_split -p uu_chcon
1022 - name: Run safe traversal verification
1023 run: ./util/check-safe-traversal.sh
1024
1025 test_libc_interposition:
1026 name: libc Interposition Check
1027 runs-on: ubuntu-latest
1028 needs: [ min_version, deps ]
1029
1030 steps:
1031 - uses: actions/[email protected]
1032 with:
1033 persist-credentials: false
1034 - uses: Swatinem/rust-cache@v2
1035 - name: Install fakeroot
1036 run: sudo apt-get update && sudo apt-get install -y fakeroot
1037 - name: Build utilities that must stay interposable
1038 run: cargo build --profile=release-small -p uu_chmod -p uu_chown
1039 - name: Run libc interposition verification
1040 run: ./util/check-libc-interposition.sh
1041
1042 test_open_once:
1043 name: Redundant Open Check
1044 runs-on: ubuntu-latest
1045 needs: [ min_version, deps ]
1046
1047 steps:
1048 - uses: actions/[email protected]
1049 with:
1050 persist-credentials: false
1051 - uses: Swatinem/rust-cache@v2
1052 - name: Install strace
1053 run: sudo apt-get update && sudo apt-get install -y strace
1054 - name: Build utilities for redundant open checks
1055 run: cargo build --profile=release-small -p uu_cp -p uu_mv
1056 - name: Run redundant open verification
1057 run: ./util/check-open-once.sh
1058
1059 test_toctou:
1060 name: TOCTOU Security Check
1061 runs-on: ubuntu-latest
1062 needs: [ min_version, deps ]
1063
1064 steps:
1065 - uses: actions/[email protected]
1066 with:
1067 persist-credentials: false
1068 - uses: Swatinem/rust-cache@v2
1069 - name: Install strace
1070 run: sudo apt-get update && sudo apt-get install -y strace
1071 - name: Build utilities for TOCTOU checks
1072 run: cargo build --profile=release-small -p uu_mkfifo -p uu_touch -p uu_head
1073 - name: Run TOCTOU verification
1074 run: ./util/check-toctou.sh