Debian Codegraph @

.github/workflows/make.yml

raw
1 name: make
2 # spell-checker:ignore (abbrev/names) CACHEDIR taiki
3 # spell-checker:ignore (env/flags) CHERE RUSTDOCFLAGS RUSTFLAGS CARGOFLAGS CLEVEL relocs EAGAIN
4 # spell-checker:ignore (jargon) deps softprops toolchain
5 # spell-checker:ignore (people) dawidd
6 # spell-checker:ignore (shell/tools) bsdtar nextest pacman sccache zstd
7 # spell-checker:ignore (misc) bindir busytest defconfig dynamicbase DESTDIR libopenssl manpages multisize noconfirm runtest testsuite toybox uutils
8
9 env:
10 PROJECT_NAME: coreutils
11 PROJECT_DESC: "Core universal (cross-platform) utilities"
12 PROJECT_AUTH: "uutils"
13 CARGO_INCREMENTAL: 0
14 # * style job configuration
15 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
16
17 on:
18 pull_request:
19 push:
20 tags:
21 - '*'
22 branches:
23 - '*'
24
25 permissions:
26 contents: read # to fetch code (actions/checkout)
27
28 # End the current execution if there is a new changeset in the PR.
29 concurrency:
30 group: ${{ github.workflow }}-${{ github.ref }}
31 cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
32
33 jobs:
34 build_makefile:
35 name: Build/Makefile and measure binary size
36 env:
37 # to reduce the size:
38 RUSTFLAGS: "-C force-unwind-tables=no -C strip=symbols -Clink-arg=-z -Clink-arg=pack-relative-relocs"
39 permissions:
40 contents: write # Publish individual binaries
41 runs-on: ${{ matrix.job.os }}
42 strategy:
43 fail-fast: false
44 matrix:
45 job:
46 - { os: ubuntu-latest , features: feat_os_unix }
47 steps:
48 - uses: actions/[email protected]
49 with:
50 persist-credentials: false
51 - uses: taiki-e/install-action@nextest
52 - uses: Swatinem/rust-cache@v2
53 # Test build on the system missing libselinux (don't install libselinux1-dev at here)
54 - name: Run sccache-cache
55 id: sccache-setup
56 uses: mozilla-actions/[email protected]
57 continue-on-error: true
58 - name: Export sccache
59 if: steps.sccache-setup.outcome == 'success'
60 run: |
61 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
62 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
63 - name: "`make build`"
64 # Also check that target/CACHEDIR.TAG is created on a fresh checkout
65 shell: bash
66 run: |
67 set -x
68 # Target directory must not exist to start with, otherwise cargo
69 # will not create target/CACHEDIR.TAG.
70 if [[ -d target ]]; then
71 mv -T target target.cache
72 fi
73 # Check that we don't cross-build uudoc
74 env CARGO_BUILD_TARGET=invalid-unknown-linux-gnu make install-manpages PREFIX=/tmp/usr UTILS=true
75 # We don't build coreutils without MULTICALL=y
76 ! test -e target/debug/coreutils
77 # build (host)
78 make build
79 echo "Check that target directory will be ignored by backup tools"
80 test -f target/CACHEDIR.TAG
81 # Restore cache for target/release (we only did a debug build)
82 mv -t target/ target.cache/release 2>/dev/null || true
83 - name: "`make nextest`"
84 shell: bash
85 run: make nextest PROFILE=ci CARGOFLAGS="--hide-progress-bar"
86 env:
87 RUST_BACKTRACE: "1"
88 - name: Upload test results to Codecov
89 if: ${{ !cancelled() }}
90 uses: codecov/codecov-action@v7
91 with:
92 token: ${{ secrets.CODECOV_TOKEN }}
93 report_type: test_results
94 files: target/nextest/ci/junit.xml
95 disable_search: true
96 flags: makefile,${{ matrix.job.os }}
97 fail_ci_if_error: false
98 - name: "`make install`"
99 shell: bash
100 run: |
101 set -x
102 DESTDIR=/tmp/ make PROFILE=release install
103 # Check that the utils are present
104 test -f /tmp/usr/local/bin/tty
105 # Check that the manpage is present
106 test -f /tmp/usr/local/share/man/man1/md5sum.1
107 # Check that the completion is present
108 test -f /tmp/usr/local/share/zsh/site-functions/_b2sum
109 test -f /tmp/usr/local/share/bash-completion/completions/head.bash
110 test -f /tmp/usr/local/share/fish/vendor_completions.d/cat.fish
111 env:
112 RUST_BACKTRACE: "1"
113 - name: "`make uninstall`"
114 shell: bash
115 run: |
116 set -x
117 DESTDIR=/tmp/ make uninstall
118 # Check that the utils are not present
119 ! test -f /tmp/usr/local/bin/tty
120 # Check that the manpage is not present
121 ! test -f /tmp/usr/local/share/man/man1/whoami.1
122 # Check that the completion is not present
123 ! test -f /tmp/usr/local/share/zsh/site-functions/_install
124 ! test -f /tmp/usr/local/share/bash-completion/completions/head.bash
125 ! test -f /tmp/usr/local/share/fish/vendor_completions.d/cat.fish
126 - name: "`make install MULTICALL=n`"
127 shell: bash
128 run: |
129 set -x
130 DESTDIR=/tmp/individual make PROFILE=release MULTICALL=n install
131 # Check that *sum are present
132 for s in {md5,b2,sha1,sha224,sha256,sha384,sha512}sum
133 do test -e /tmp/individual/usr/local/bin/${s}
134 done
135 - name: "`make install MULTICALL=y LN=ln -svf`"
136 shell: bash
137 run: |
138 set -x
139 DESTDIR=/tmp/ make PROFILE=release MULTICALL=y LN="ln -svf" install
140 # Check that symlinks of *sum are present
141 for s in {md5,b2,sha1,sha224,sha256,sha384,sha512}sum
142 do test $(readlink /tmp/usr/local/bin/${s}) = coreutils
143 done
144 - name: Package
145 shell: bash
146 run: |
147 # Check that libstdbuf is present too
148 mv target/release/deps/libstdbuf.so -t /tmp/individual/usr/local/bin
149 ZSTD_CLEVEL=19 tar --zstd -caf individual-x86_64-unknown-linux-gnu.tar.zst -C /tmp/individual/usr/local bin
150 - name: Publish
151 uses: softprops/action-gh-release@v3
152 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
153 with:
154 tag_name: latest-commit
155 draft: false
156 prerelease: true
157 files: |
158 individual-x86_64-unknown-linux-gnu.tar.zst
159 env:
160 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161 - name: Compute uutil release sizes
162 shell: bash
163 run: |
164 ## Compute uutil release sizes
165 DATE=$(date --rfc-email)
166 find /tmp/individual/usr/local/bin -type f -printf '%f\0' | sort -z |
167 while IFS= read -r -d '' name; do
168 size=$(du -s /tmp/individual/usr/local/bin/$name | awk '{print $1}')
169 echo "\"$name\""
170 echo "$size"
171 done | \
172 jq -n \
173 --arg date "$DATE" \
174 --arg sha "$GITHUB_SHA" \
175 'reduce inputs as $name ({}; . + { ($name): input }) | { ($date): {sha: $sha, sizes: map_values(.)} }' > individual-size-result.json
176 SIZE=$(cat individual-size-result.json | jq '[.[] | .sizes | .[]] | reduce .[] as $num (0; . + $num)')
177 SIZE_MULTI=$(du -s /tmp/usr/local/bin/coreutils | awk '{print $1}')
178 jq -n \
179 --arg date "$DATE" \
180 --arg sha "$GITHUB_SHA" \
181 --arg size "$SIZE" \
182 --arg multisize "$SIZE_MULTI" \
183 '{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
184 - name: Download the previous individual size result
185 uses: dawidd6/action-download-artifact@v24
186 with:
187 workflow: make.yml
188 name: individual-size-result
189 repo: uutils/coreutils
190 path: dl
191 - name: Download the previous size result
192 uses: dawidd6/action-download-artifact@v24
193 with:
194 workflow: make.yml
195 name: size-result
196 repo: uutils/coreutils
197 path: dl
198 - name: Compare individual binary sizes VS reference
199 shell: bash
200 run: |
201 ## Produce a per-binary size comparison and a PR comment body.
202 ## The comment body is consumed by the SizeComment workflow, which
203 ## mirrors GnuComment for the GNU testsuite results.
204 COMMENT_DIR="size-comment"
205 mkdir -p "${COMMENT_DIR}"
206 # `github.event.number` is empty on non-PR events; the downstream
207 # workflow only posts comments when triggered for a pull request.
208 echo "${{ github.event.number }}" > "${COMMENT_DIR}/NR"
209 COMMENT_LOG="${COMMENT_DIR}/result.txt"
210
211 if test -f dl/individual-size-result.json; then
212 python3 util/compare_size_results.py \
213 individual-size-result.json \
214 dl/individual-size-result.json \
215 --output "${COMMENT_LOG}"
216 else
217 echo "::warning ::Skipping individual size comparison; no reference is available."
218 fi
219 - name: Check uutil release multi-binary sizes
220 shell: bash
221 run: |
222 ## The aggregate `multiple binaries` and `multicall binary` totals
223 ## are still checked inline; they are simple scalar comparisons and
224 ## do not feed into the per-binary PR comment.
225 check() {
226 # Warn if the size increases by more than 5%
227 threshold='1.05'
228
229 if [[ "$2" -eq 0 || "$3" -eq 0 ]]; then
230 echo "::warning file=$4::Invalid size for $1. Sizes cannot be 0."
231 return
232 fi
233
234 ratio=$(jq -n "$2 / $3")
235 echo "$1: size=$2, previous_size=$3, ratio=$ratio, threshold=$threshold"
236 if [[ "$(jq -n "$ratio > $threshold")" == 'true' ]]; then
237 echo "::warning file=$4::Size of $1 increases by more than 5%"
238 fi
239 }
240 ## Check size result
241 size=$(cat size-result.json | jq -r '.[] | .size')
242 previous_size=$(cat dl/size-result.json | jq -r '.[] | .size')
243 check 'multiple binaries' "$size" "$previous_size" 'size-result.json'
244 multisize=$(cat size-result.json | jq -r '.[] | .multisize')
245 previous_multisize=$(cat dl/size-result.json | jq -r '.[] | .multisize')
246 check 'multicall binary' "$multisize" "$previous_multisize" 'size-result.json'
247 - name: Upload size comparison comment (for SizeComment workflow)
248 if: success() || failure() # run regardless of prior step success/failure
249 uses: actions/upload-artifact@v7
250 with:
251 name: size-comment
252 path: size-comment/
253 - name: Upload the individual size result
254 uses: actions/upload-artifact@v7
255 with:
256 name: individual-size-result
257 path: individual-size-result.json
258 - name: Upload the size result
259 uses: actions/upload-artifact@v7
260 with:
261 name: size-result
262 path: size-result.json
263 - name: "`make UTILS=XXX`"
264 shell: bash
265 run: |
266 set -x
267 # Regression-test for https://github.com/uutils/coreutils/issues/8701
268 make UTILS="rm chmod chown chgrp mv du"
269 # Verifies that
270 # 1. there is no "error: none of the selected packages contains this
271 # feature: feat_external_libstdbuf"
272 # 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped
273 DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install
274
275 # keep this job minimal to avoid have many duplicated build with CICD
276 build_makefile-windows-cygwin:
277 name: Build MSYS
278 permissions:
279 contents: write # Publish cygwin binary
280 runs-on: ${{ matrix.job.os }}
281 env:
282 CARGO_INCREMENTAL: 0
283 RUSTFLAGS: "-C link-arg=-Wl,--dynamicbase -C link-arg=-Wl,--enable-auto-image-base"
284 strategy:
285 fail-fast: false
286 matrix:
287 job:
288 - { os: windows-latest , features: feat_os_windows }
289 steps:
290 - uses: actions/[email protected]
291 with:
292 persist-credentials: false
293 - uses: Swatinem/rust-cache@v2
294 - name: Run sccache-cache
295 id: sccache-setup
296 uses: mozilla-actions/[email protected]
297 continue-on-error: true
298 - name: Export sccache
299 if: steps.sccache-setup.outcome == 'success'
300 run: |
301 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
302 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
303 - name: Disable Mandatory ASLR (required for Cygwin/MSYS2 bash on GitHub runners)
304 shell: powershell
305 run: |
306 # exit code 254 from bash.exe is caused by Windows Mandatory ASLR
307 # See: https://github.com/appveyor/ci/issues/3777
308 Set-ProcessMitigation -System -Disable ForceRelocateImages
309 - name: Update MSYS2 packages
310 # msys2-runtime must be upgraded in a separate bash session before the build.
311 # Upgrading it mid-session changes the shared memory layout (60344 -> 59320),
312 # which causes subsequent fork() calls to fail with EAGAIN (exit code 254).
313 shell: 'C:\msys64\usr\bin\bash.exe --login -eo pipefail {0}'
314 run: |
315 pacman -Sy --noconfirm --needed base-devel libopenssl make openssl-devel pkgconf rust
316 env:
317 CHERE_INVOKING: 1
318 - name: "`(x86_64-pc-cygwin) make install PROG_PREFIX=uu- PROFILE=release-small COMPLETIONS=n MANPAGES=n LOCALES=n`"
319 shell: 'C:\msys64\usr\bin\bash.exe --login -eo pipefail {0}'
320 run: |
321 set -x
322 export OPENSSL_NO_VENDOR=1
323 export CARGOFLAGS="--features openssl"
324 DESTDIR=/tmp/c make install PROG_PREFIX=uu- PROFILE=release-small COMPLETIONS=n MANPAGES=n LOCALES=n
325 # Check that cksum is linked with openssl (e.g. msys-crypto-*.dll)
326 # Also check that utils are built with given profile
327 ldd target/release-small/cksum | grep crypto
328 # Check that the progs have prefix
329 test -f /tmp/c/usr/local/bin/uu-tty
330 test -f /tmp/c/usr/local/libexec/uu-coreutils/libstdbuf.dll
331 # Check that the manpage is not present
332 ! test -f /tmp/c/usr/local/share/man/man1/uu-whoami.1
333 # Check that the completion is not present
334 ! test -f /tmp/c/usr/local/share/zsh/site-functions/_uu-install
335 ! test -f /tmp/c/usr/local/share/bash-completion/completions/uu-head.bash
336 ! test -f /tmp/c/usr/local/share/fish/vendor_completions.d/uu-cat.fish
337 # package
338 mv target/release-small/deps/stdbuf.dll -t /tmp/c/usr/local/bin
339 bsdtar -caf x86_64-pc-cygwin.tar.zst -C /tmp/c/usr/local bin
340 env:
341 CHERE_INVOKING: 1
342 RUST_BACKTRACE: "1"
343 - name: Publish
344 uses: softprops/action-gh-release@v3
345 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
346 with:
347 tag_name: latest-commit
348 draft: false
349 prerelease: true
350 files: |
351 individual-x86_64-pc-cygwin.tar.zst
352 env:
353 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
354 - name: "`make install`"
355 shell: bash
356 run: |
357 set -x
358 # Check that we exclude unix programs to avoid build failure
359 # Windows's stdbuf depends on Cygwin's libstdbuf. So make should not try to install libstdbuf
360 make install DESTDIR=/tmp/w PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \
361 SKIP_UTILS="arch b2sum base32 base64 basename basenc cat cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold head hostname hostid join link ln ls md5sum mkdir mktemp more mv nl nproc numfmt od paste pathchk pr printenv printf ptx pwd readlink realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split sum sync tac tail tee test touch tr true truncate tsort tty uname unexpand uniq unlink vdir wc whoami yes"
362 target/release/coreutils.exe stdbuf --version
363
364 test_busybox:
365 name: Tests/BusyBox test suite
366 runs-on: ${{ matrix.job.os }}
367 strategy:
368 fail-fast: false
369 matrix:
370 job:
371 - { os: ubuntu-latest }
372 steps:
373 - name: Initialize workflow variables
374 id: vars
375 shell: bash
376 run: |
377 ## VARs setup
378 echo "TEST_SUMMARY_FILE=busybox-result.json" >> $GITHUB_OUTPUT
379 - uses: actions/[email protected]
380 with:
381 persist-credentials: false
382 - uses: Swatinem/rust-cache@v2
383 - name: Run sccache-cache
384 id: sccache-setup
385 uses: mozilla-actions/[email protected]
386 continue-on-error: true
387 - name: Export sccache
388 if: steps.sccache-setup.outcome == 'success'
389 run: |
390 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
391 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
392 - name: Install/setup prerequisites
393 shell: bash
394 run: |
395 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
396 ## Install/setup prerequisites
397 make prepare-busytest
398 - name: Run BusyBox test suite
399 id: summary
400 shell: bash
401 run: |
402 ## Run BusyBox test suite
403 set -v
404 cp .busybox-config target/debug/.config
405 ## Run BusyBox test suite
406 bindir=$(pwd)/target/debug
407 cd tmp/busybox-*/testsuite
408 output=$(bindir=$bindir ./runtest 2>&1 || true)
409 printf "%s\n" "${output}"
410 FAIL=$(echo "$output" | grep "^FAIL:\s" | wc --lines)
411 PASS=$(echo "$output" | grep "^PASS:\s" | wc --lines)
412 SKIP=$(echo "$output" | grep "^SKIPPED:\s" | wc --lines)
413 TOTAL=`expr $FAIL + $PASS + $SKIP`
414 echo "FAIL $FAIL"
415 echo "SKIP $SKIP"
416 echo "PASS $PASS"
417 echo "TOTAL $TOTAL"
418 cd -
419 output="Busybox tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / SKIP: $SKIP"
420 echo "${output}"
421 if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
422 jq -n \
423 --arg date "$(date --rfc-email)" \
424 --arg sha "$GITHUB_SHA" \
425 --arg total "$TOTAL" \
426 --arg pass "$PASS" \
427 --arg skip "$SKIP" \
428 --arg fail "$FAIL" \
429 '{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, }}' > '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}'
430 HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
431 echo "HASH=${HASH}" >> $GITHUB_OUTPUT
432 - name: Reserve SHA1/ID of 'test-summary'
433 uses: actions/upload-artifact@v7
434 with:
435 name: "${{ steps.summary.outputs.HASH }}"
436 path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
437 - name: Reserve test results summary
438 uses: actions/upload-artifact@v7
439 with:
440 name: busybox-test-summary
441 path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
442 - name: Upload json results
443 uses: actions/upload-artifact@v7
444 with:
445 name: busybox-result.json
446 path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}
447
448 test_toybox:
449 name: Tests/Toybox test suite
450 runs-on: ${{ matrix.job.os }}
451 strategy:
452 fail-fast: false
453 matrix:
454 job:
455 - { os: ubuntu-latest }
456 steps:
457 - name: Initialize workflow variables
458 id: vars
459 shell: bash
460 run: |
461 ## VARs setup
462 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
463 TEST_SUMMARY_FILE="toybox-result.json"
464 outputs TEST_SUMMARY_FILE
465 - uses: actions/[email protected]
466 with:
467 persist-credentials: false
468 - uses: Swatinem/rust-cache@v2
469 - name: Run sccache-cache
470 id: sccache-setup
471 uses: mozilla-actions/[email protected]
472 continue-on-error: true
473 - name: Export sccache
474 if: steps.sccache-setup.outcome == 'success'
475 run: |
476 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
477 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
478 - name: Install/setup prerequisites
479 shell: bash
480 run: |
481 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
482 - name: Build coreutils
483 shell: bash
484 run: |
485 set -v
486 make MULTICALL=y && (cd target/debug && for binary in $(./coreutils --list);do ln -sf coreutils ${binary};done)
487 - name: Run toybox src
488 shell: bash
489 run: |
490 make toybox-src
491 - name: Run Toybox test suite
492 id: summary
493 shell: bash
494 run: |
495 ## Run Toybox test suite
496 set -v
497 cd tmp/toybox-*/
498 make defconfig
499 make tests &> tmp.log || true
500 cat tmp.log
501 FAIL=$(grep "FAIL" tmp.log | wc --lines)
502 PASS=$(grep "PASS:" tmp.log| wc --lines)
503 SKIP=$(grep " disabled$" tmp.log| wc --lines)
504 TOTAL=`expr $FAIL + $PASS + $SKIP`
505 echo "FAIL $FAIL"
506 echo "SKIP $SKIP"
507 echo "PASS $PASS"
508 echo "TOTAL $TOTAL"
509 cd -
510 jq -n \
511 --arg date "$(date --rfc-email)" \
512 --arg sha "$GITHUB_SHA" \
513 --arg total "$TOTAL" \
514 --arg pass "$PASS" \
515 --arg skip "$SKIP" \
516 --arg fail "$FAIL" \
517 '{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, }}' > '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}'
518 output="Toybox tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / SKIP: $SKIP"
519 echo "${output}"
520 if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
521 HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
522 echo "HASH=${HASH}" >> $GITHUB_OUTPUT
523 - name: Reserve SHA1/ID of 'test-summary'
524 uses: actions/upload-artifact@v7
525 with:
526 name: "${{ steps.summary.outputs.HASH }}"
527 path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
528 - name: Reserve test results summary
529 uses: actions/upload-artifact@v7
530 with:
531 name: toybox-test-summary
532 path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
533 - name: Upload json results
534 uses: actions/upload-artifact@v7
535 with:
536 name: toybox-result.json
537 path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}