| 1 |
name: GnuTests |
| 2 |
|
| 3 |
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests |
| 4 |
# spell-checker:ignore (jargon) submodules devel |
| 5 |
# spell-checker:ignore (libs/utils) chksum dpkg getenforce gperf lcov libexpect limactl pyinotify setenforce shopt valgrind libattr libcap taiki-e zstd cpio |
| 6 |
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic |
| 7 |
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS |
| 8 |
# spell-checker:ignore userns nodocs |
| 9 |
|
| 10 |
# * note: to run a single test => `REPO/util/run-gnu-test.sh PATH/TO/TEST/SCRIPT` |
| 11 |
|
| 12 |
on: |
| 13 |
pull_request: |
| 14 |
push: |
| 15 |
branches: |
| 16 |
- '*' |
| 17 |
## the reference branch carries no code, only published test results |
| 18 |
- '!gnu-reference' |
| 19 |
|
| 20 |
permissions: |
| 21 |
contents: read |
| 22 |
|
| 23 |
# End the current execution if there is a new changeset in the PR. |
| 24 |
concurrency: |
| 25 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 26 |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 27 |
|
| 28 |
env: |
| 29 |
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 30 |
## Machine-maintained branch holding the latest GNU test results of the |
| 31 |
## default branch; every PR run is compared against what it carries. |
| 32 |
REFERENCE_BRANCH: 'gnu-reference' |
| 33 |
TEST_FULL_SUMMARY_FILE: 'gnu-full-result.json' |
| 34 |
TEST_ROOT_FULL_SUMMARY_FILE: 'gnu-root-full-result.json' |
| 35 |
TEST_STTY_FULL_SUMMARY_FILE: 'gnu-stty-full-result.json' |
| 36 |
TEST_SELINUX_FULL_SUMMARY_FILE: 'selinux-gnu-full-result.json' |
| 37 |
TEST_SELINUX_ROOT_FULL_SUMMARY_FILE: 'selinux-root-gnu-full-result.json' |
| 38 |
TEST_QEMU_FULL_SUMMARY_FILE: 'qemu-gnu-full-result.json' |
| 39 |
|
| 40 |
jobs: |
| 41 |
native: |
| 42 |
name: Run GNU tests (native) |
| 43 |
runs-on: ubuntu-24.04 |
| 44 |
steps: |
| 45 |
#### Get the code |
| 46 |
- name: Checkout code (uutils) |
| 47 |
uses: actions/[email protected] |
| 48 |
with: |
| 49 |
path: 'uutils' |
| 50 |
persist-credentials: false |
| 51 |
- uses: Swatinem/rust-cache@v2 |
| 52 |
with: |
| 53 |
workspaces: "./uutils -> target" |
| 54 |
- name: Checkout code (GNU coreutils) |
| 55 |
run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh) |
| 56 |
#### Build environment setup |
| 57 |
- name: Install dependencies |
| 58 |
shell: bash |
| 59 |
run: | |
| 60 |
## Install dependencies |
| 61 |
sudo apt-get update |
| 62 |
## Check that build-gnu.sh works on the non SELinux system by installing libselinux only on lima |
| 63 |
sudo apt-get install -y gperf gdb python3-pyinotify valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev attr quilt |
| 64 |
- name: Add various locales |
| 65 |
shell: bash |
| 66 |
run: | |
| 67 |
## Add various locales |
| 68 |
echo "Before:" |
| 69 |
locale -a |
| 70 |
## Some tests fail with 'cannot change locale (en_US.ISO-8859-1): No such file or directory' |
| 71 |
## Some others need a French locale |
| 72 |
sudo locale-gen |
| 73 |
sudo locale-gen --keep-existing fr_FR |
| 74 |
sudo locale-gen --keep-existing fr_FR.UTF-8 |
| 75 |
sudo locale-gen --keep-existing es_ES.UTF-8 |
| 76 |
sudo locale-gen --keep-existing sv_SE |
| 77 |
sudo locale-gen --keep-existing sv_SE.UTF-8 |
| 78 |
sudo locale-gen --keep-existing en_US |
| 79 |
sudo locale-gen --keep-existing en_US.UTF-8 |
| 80 |
sudo locale-gen --keep-existing ru_RU.KOI8-R |
| 81 |
sudo locale-gen --keep-existing fa_IR.UTF-8 # Iran |
| 82 |
sudo locale-gen --keep-existing am_ET.UTF-8 # Ethiopia |
| 83 |
sudo locale-gen --keep-existing th_TH.UTF-8 # Thailand |
| 84 |
sudo locale-gen --keep-existing zh_CN.GB18030 # China |
| 85 |
|
| 86 |
sudo update-locale |
| 87 |
echo "After:" |
| 88 |
locale -a |
| 89 |
|
| 90 |
### Build |
| 91 |
- name: Build binaries |
| 92 |
shell: bash |
| 93 |
run: | |
| 94 |
## Build binaries |
| 95 |
cd 'uutils' |
| 96 |
env PROFILE=release-small bash util/build-gnu.sh |
| 97 |
|
| 98 |
### Run tests as user |
| 99 |
- name: Run GNU tests |
| 100 |
shell: bash |
| 101 |
run: | |
| 102 |
## Use unshare |
| 103 |
sudo sysctl -w kernel.unprivileged_userns_clone=1 |
| 104 |
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 |
| 105 |
## Run GNU tests |
| 106 |
path_GNU='gnu' |
| 107 |
path_UUTILS='uutils' |
| 108 |
bash "uutils/util/run-gnu-test.sh" |
| 109 |
- name: Extract testing info from individual logs into JSON |
| 110 |
shell: bash |
| 111 |
run : | |
| 112 |
path_UUTILS='uutils' |
| 113 |
python uutils/util/gnu-json-result.py gnu/tests > ${{ env.TEST_FULL_SUMMARY_FILE }} |
| 114 |
|
| 115 |
### Run tests as root |
| 116 |
- name: Run GNU root tests |
| 117 |
shell: bash |
| 118 |
run: | |
| 119 |
## Run GNU root tests |
| 120 |
path_GNU='gnu' |
| 121 |
path_UUTILS='uutils' |
| 122 |
bash "uutils/util/run-gnu-test.sh" run-root |
| 123 |
|
| 124 |
- name: Extract testing info from individual logs (run as root) into JSON |
| 125 |
shell: bash |
| 126 |
run : | |
| 127 |
path_UUTILS='uutils' |
| 128 |
python uutils/util/gnu-json-result.py gnu/tests > ${{ env.TEST_ROOT_FULL_SUMMARY_FILE }} |
| 129 |
|
| 130 |
### This shell has been changed from "bash" to this command |
| 131 |
### "script" will start a pty and the -q command removes the "script" initiation log |
| 132 |
### the -e flag makes it propagate the error code and -c runs the command in a pty |
| 133 |
### the primary purpose of this change is to run the tty GNU tests |
| 134 |
### The reason its separated from the rest of the tests is because one test can corrupt the other |
| 135 |
### tests through the use of the shared terminal and it changes the environment that the other |
| 136 |
### tests are run in, which can cause different results. |
| 137 |
- name: Run GNU stty tests |
| 138 |
shell: 'script -q -e -c "bash {0}"' |
| 139 |
run: | |
| 140 |
## Run GNU root tests |
| 141 |
path_GNU='gnu' |
| 142 |
path_UUTILS='uutils' |
| 143 |
bash "uutils/util/run-gnu-test.sh" run-tty |
| 144 |
|
| 145 |
- name: Extract testing info from individual logs (stty) into JSON |
| 146 |
shell: bash |
| 147 |
run : | |
| 148 |
path_UUTILS='uutils' |
| 149 |
python uutils/util/gnu-json-result.py gnu/tests > ${{ env.TEST_STTY_FULL_SUMMARY_FILE }} |
| 150 |
|
| 151 |
### Upload artifacts |
| 152 |
- name: Upload full json results |
| 153 |
uses: actions/upload-artifact@v7 |
| 154 |
with: |
| 155 |
name: gnu-full-result |
| 156 |
path: ${{ env.TEST_FULL_SUMMARY_FILE }} |
| 157 |
- name: Upload root json results |
| 158 |
uses: actions/upload-artifact@v7 |
| 159 |
with: |
| 160 |
name: gnu-root-full-result |
| 161 |
path: ${{ env.TEST_ROOT_FULL_SUMMARY_FILE }} |
| 162 |
- name: Upload stty json results |
| 163 |
uses: actions/upload-artifact@v7 |
| 164 |
with: |
| 165 |
name: gnu-stty-full-result |
| 166 |
path: ${{ env.TEST_STTY_FULL_SUMMARY_FILE }} |
| 167 |
|
| 168 |
- name: Compress test logs |
| 169 |
shell: bash |
| 170 |
run : | |
| 171 |
# Compress logs before upload (fails otherwise) |
| 172 |
gzip gnu/tests/*/*.log |
| 173 |
- name: Upload test logs |
| 174 |
uses: actions/upload-artifact@v7 |
| 175 |
with: |
| 176 |
name: test-logs |
| 177 |
path: | |
| 178 |
gnu/tests/*.log |
| 179 |
gnu/tests/*/*.log.gz |
| 180 |
|
| 181 |
selinux: |
| 182 |
name: Run GNU tests (SELinux) |
| 183 |
runs-on: ubuntu-24.04 |
| 184 |
steps: |
| 185 |
#### Get the code |
| 186 |
- name: Checkout code (uutils) |
| 187 |
uses: actions/[email protected] |
| 188 |
with: |
| 189 |
path: 'uutils' |
| 190 |
persist-credentials: false |
| 191 |
- name: Checkout code (GNU coreutils) |
| 192 |
run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh) |
| 193 |
|
| 194 |
#### Lima build environment setup |
| 195 |
- name: Setup Lima |
| 196 |
uses: lima-vm/lima-actions/setup@v1 |
| 197 |
id: lima-actions-setup |
| 198 |
- name: Cache ~/.cache/lima |
| 199 |
uses: actions/cache@v6 |
| 200 |
with: |
| 201 |
path: ~/.cache/lima |
| 202 |
key: lima-${{ steps.lima-actions-setup.outputs.version }} |
| 203 |
- name: Start Fedora VM with SELinux |
| 204 |
run: limactl start --plain --name=default --cpus=4 --disk=40 --memory=8 --network=lima:user-v2 template:fedora |
| 205 |
- name: Verify SELinux Status and Configuration |
| 206 |
run: | |
| 207 |
lima getenforce |
| 208 |
lima ls -laZ /etc/selinux |
| 209 |
lima sudo sestatus |
| 210 |
|
| 211 |
- name: Install dependencies in VM |
| 212 |
run: | |
| 213 |
lima sudo dnf -y install --nodocs autoconf bison gperf gcc gdb jq libacl-devel libattr-devel libcap-devel libselinux-devel attr rustup clang-devel automake patch quilt |
| 214 |
lima rustup-init -y --profile=minimal --default-toolchain stable |
| 215 |
- name: Copy the sources to VM |
| 216 |
run: | |
| 217 |
rsync -a -e ssh . lima-default:~/work/ |
| 218 |
|
| 219 |
### Build |
| 220 |
- name: Build binaries |
| 221 |
run: | |
| 222 |
lima bash -c "cd ~/work/uutils/ && SELINUX_ENABLED=1 PROFILE=release-small bash util/build-gnu.sh" |
| 223 |
|
| 224 |
### Run tests as user |
| 225 |
- name: Generate SELinux tests list |
| 226 |
run: | |
| 227 |
# Find and list all tests that require SELinux |
| 228 |
lima bash -c "cd ~/work/gnu/ && grep -l 'require_selinux_' -r tests/ > ~/work/uutils/selinux-tests.txt" |
| 229 |
lima bash -c "cd ~/work/uutils/ && cat selinux-tests.txt" |
| 230 |
|
| 231 |
# Count the tests |
| 232 |
lima bash -c "cd ~/work/uutils/ && echo 'Found SELinux tests:'; wc -l selinux-tests.txt" |
| 233 |
- name: Run GNU SELinux tests |
| 234 |
run: | |
| 235 |
# Ensure we're running in enforcing mode |
| 236 |
lima sudo setenforce 1 |
| 237 |
lima getenforce |
| 238 |
|
| 239 |
# Create test files with SELinux contexts for testing |
| 240 |
lima sudo mkdir -p /var/test_selinux |
| 241 |
lima sudo touch /var/test_selinux/test_file |
| 242 |
lima sudo chcon -t etc_t /var/test_selinux/test_file |
| 243 |
lima ls -Z /var/test_selinux/test_file # Verify context |
| 244 |
|
| 245 |
lima cat /proc/filesystems |
| 246 |
lima bash -c "cd ~/work/uutils/ && bash util/run-gnu-test.sh \$(cat selinux-tests.txt)" |
| 247 |
- name: Extract testing info from individual logs into JSON |
| 248 |
shell: bash |
| 249 |
run : | |
| 250 |
lima bash -c "cd ~/work/gnu/ && python3 ../uutils/util/gnu-json-result.py tests > ~/work/${{ env.TEST_SELINUX_FULL_SUMMARY_FILE }}" |
| 251 |
|
| 252 |
### Run tests as root |
| 253 |
- name: Run GNU SELinux root tests |
| 254 |
run: | |
| 255 |
lima bash -c "cd ~/work/uutils/ && CI=1 bash util/run-gnu-test.sh run-root \$(cat selinux-tests.txt)" |
| 256 |
- name: Extract testing info from individual logs (run as root) into JSON |
| 257 |
shell: bash |
| 258 |
run : | |
| 259 |
lima bash -c "cd ~/work/gnu/ && python3 ../uutils/util/gnu-json-result.py tests > ~/work/${{ env.TEST_SELINUX_ROOT_FULL_SUMMARY_FILE }}" |
| 260 |
|
| 261 |
### Upload artifacts |
| 262 |
- name: Collect test logs and test results from VM |
| 263 |
run: | |
| 264 |
mkdir -p gnu/tests-selinux |
| 265 |
|
| 266 |
# Copy the json output back from the Lima VM to the host |
| 267 |
rsync -v -a -e ssh lima-default:~/work/*.json ./ |
| 268 |
# Copy the test directory now |
| 269 |
rsync -v -a -e ssh lima-default:~/work/gnu/tests/ ./gnu/tests-selinux/ |
| 270 |
- name: Upload SELinux json results |
| 271 |
uses: actions/upload-artifact@v7 |
| 272 |
with: |
| 273 |
name: selinux-gnu-full-result |
| 274 |
path: ${{ env.TEST_SELINUX_FULL_SUMMARY_FILE }} |
| 275 |
- name: Upload SELinux root json results |
| 276 |
uses: actions/upload-artifact@v7 |
| 277 |
with: |
| 278 |
name: selinux-root-gnu-full-result |
| 279 |
path: ${{ env.TEST_SELINUX_ROOT_FULL_SUMMARY_FILE }} |
| 280 |
- name: Compress SELinux test logs |
| 281 |
shell: bash |
| 282 |
run : | |
| 283 |
# Compress logs before upload (fails otherwise) |
| 284 |
gzip gnu/tests-selinux/*/*.log |
| 285 |
- name: Upload SELinux test logs |
| 286 |
uses: actions/upload-artifact@v7 |
| 287 |
with: |
| 288 |
name: selinux-test-logs |
| 289 |
path: | |
| 290 |
gnu/tests-selinux/*.log |
| 291 |
gnu/tests-selinux/*/*.log.gz |
| 292 |
|
| 293 |
qemu: |
| 294 |
name: Run GNU tests (SMACK/ROOTFS) |
| 295 |
runs-on: ubuntu-24.04 |
| 296 |
steps: |
| 297 |
- name: Checkout code (uutils) |
| 298 |
uses: actions/[email protected] |
| 299 |
with: |
| 300 |
path: 'uutils' |
| 301 |
persist-credentials: false |
| 302 |
- uses: Swatinem/rust-cache@v2 |
| 303 |
with: |
| 304 |
workspaces: "./uutils -> target" |
| 305 |
- name: Checkout code (GNU coreutils) |
| 306 |
run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh) |
| 307 |
- name: Install dependencies |
| 308 |
run: | |
| 309 |
sudo apt-get update |
| 310 |
sudo apt-get install -y qemu-system-x86 zstd cpio |
| 311 |
- name: Run GNU SMACK/ROOTFS tests |
| 312 |
run: | |
| 313 |
cd uutils |
| 314 |
bash util/run-gnu-tests-smack-ci.sh "$GITHUB_WORKSPACE/gnu" "$GITHUB_WORKSPACE/gnu/tests-qemu" |
| 315 |
- name: Extract testing info into JSON |
| 316 |
run: | |
| 317 |
python3 uutils/util/gnu-json-result.py gnu/tests-qemu > ${{ env.TEST_QEMU_FULL_SUMMARY_FILE }} |
| 318 |
- name: Upload SMACK/ROOTFS json results |
| 319 |
uses: actions/upload-artifact@v7 |
| 320 |
with: |
| 321 |
name: qemu-gnu-full-result |
| 322 |
path: ${{ env.TEST_QEMU_FULL_SUMMARY_FILE }} |
| 323 |
- name: Compress SMACK/ROOTFS test logs |
| 324 |
run: gzip gnu/tests-qemu/*/*.log 2>/dev/null || true |
| 325 |
- name: Upload SMACK/ROOTFS test logs |
| 326 |
uses: actions/upload-artifact@v7 |
| 327 |
with: |
| 328 |
name: qemu-test-logs |
| 329 |
path: | |
| 330 |
gnu/tests-qemu/*.log |
| 331 |
gnu/tests-qemu/*/*.log.gz |
| 332 |
|
| 333 |
aggregate: |
| 334 |
needs: [native, selinux, qemu] |
| 335 |
permissions: |
| 336 |
actions: read # to download this run's own result artifacts |
| 337 |
contents: read # for actions/checkout to fetch code, and to read the reference branch |
| 338 |
name: Aggregate GNU test results |
| 339 |
runs-on: ubuntu-24.04 |
| 340 |
steps: |
| 341 |
- name: Initialize workflow variables |
| 342 |
id: vars |
| 343 |
shell: bash |
| 344 |
run: | |
| 345 |
## VARs setup |
| 346 |
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } |
| 347 |
# |
| 348 |
TEST_SUMMARY_FILE='gnu-result.json' |
| 349 |
AGGREGATED_SUMMARY_FILE='aggregated-result.json' |
| 350 |
|
| 351 |
outputs TEST_SUMMARY_FILE AGGREGATED_SUMMARY_FILE |
| 352 |
- name: Checkout code (uutils) |
| 353 |
uses: actions/[email protected] |
| 354 |
with: |
| 355 |
path: 'uutils' |
| 356 |
persist-credentials: false |
| 357 |
- name: Fetch reference results (default branch) |
| 358 |
shell: bash |
| 359 |
env: |
| 360 |
GH_TOKEN: ${{ github.token }} |
| 361 |
run: | |
| 362 |
## Fetch the reference results published by the last GnuTests run on the |
| 363 |
## default branch. |
| 364 |
## They live on a dedicated, machine-maintained branch rather than in a |
| 365 |
## workflow artifact: an artifact is addressable only by run id, so |
| 366 |
## finding one meant listing workflow runs, and the server-side 'branch' |
| 367 |
## filter of that listing is served by a search index that is only |
| 368 |
## eventually consistent (observed returning nothing newer than a month |
| 369 |
## old while the unfiltered listing was current). A run resolved from a |
| 370 |
## stale listing made every test fixed on the default branch since then |
| 371 |
## look like a fix contributed by the PR, and every test broken since |
| 372 |
## then like a regression introduced by it. A branch has no such index, |
| 373 |
## and no 90-day expiry either. |
| 374 |
## A missing reference is not fatal: the branch does not exist until the |
| 375 |
## first run on the default branch has published to it. |
| 376 |
mkdir -p reference/aggregated-result reference/test-summary |
| 377 |
## Resolve the branch tip once and read every file at that commit. The |
| 378 |
## branch is force-pushed by 'publish-reference', so reading each file |
| 379 |
## by branch name could straddle a publish and pair one file with |
| 380 |
## another reference's, comparing against a baseline that never existed. |
| 381 |
## Only a 404 means "no reference yet"; any other failure must not be |
| 382 |
## mistaken for one, or a transient API error would silently skip both |
| 383 |
## comparisons and let a regression through unnoticed. |
| 384 |
REFERENCE_SHA='' |
| 385 |
ref_err="${RUNNER_TEMP:-/tmp}/reference-ref.err" |
| 386 |
for attempt in 1 2 3; do |
| 387 |
if REFERENCE_SHA=$(gh api "repos/${{ github.repository }}/git/refs/heads/${REFERENCE_BRANCH}" \ |
| 388 |
--jq '.object.sha' 2>"${ref_err}"); then |
| 389 |
break |
| 390 |
fi |
| 391 |
REFERENCE_SHA='' |
| 392 |
if grep -q 'HTTP 404' "${ref_err}"; then |
| 393 |
## The branch does not exist until the first run on the default |
| 394 |
## branch has published to it. |
| 395 |
break |
| 396 |
fi |
| 397 |
if [[ "${attempt}" -eq 3 ]]; then |
| 398 |
cat "${ref_err}" >&2 |
| 399 |
echo "::error ::Could not resolve the '${REFERENCE_BRANCH}' branch; refusing to report an API failure as a missing baseline." |
| 400 |
exit 1 |
| 401 |
fi |
| 402 |
sleep $(( attempt * 5 )) |
| 403 |
done |
| 404 |
fetch() { |
| 405 |
gh api "repos/${{ github.repository }}/contents/${1}?ref=${REFERENCE_SHA}" \ |
| 406 |
-H 'Accept: application/vnd.github.raw' > "${2}" 2>/dev/null \ |
| 407 |
&& [[ -s "${2}" ]] |
| 408 |
} |
| 409 |
if [[ -n "${REFERENCE_SHA}" ]] \ |
| 410 |
&& fetch aggregated-result.json reference/aggregated-result/aggregated-result.json \ |
| 411 |
&& fetch gnu-result.json reference/test-summary/gnu-result.json; then |
| 412 |
## 'meta.json' says which commit the reference was built from; it is |
| 413 |
## informational, so tolerate it being absent or unparsable. |
| 414 |
meta=$(gh api "repos/${{ github.repository }}/contents/meta.json?ref=${REFERENCE_SHA}" \ |
| 415 |
-H 'Accept: application/vnd.github.raw' 2>/dev/null || true) |
| 416 |
published_sha=$(jq -r '.sha // empty' <<< "${meta}" 2>/dev/null || true) |
| 417 |
published_at=$(jq -r '.published_at // empty' <<< "${meta}" 2>/dev/null || true) |
| 418 |
echo "Reference: ${{ env.DEFAULT_BRANCH }}@${published_sha:-<unknown>} (published ${published_at:-<unknown>}, ${REFERENCE_BRANCH}@${REFERENCE_SHA})" |
| 419 |
published_epoch='' |
| 420 |
if [[ -n "${published_at}" ]]; then |
| 421 |
published_epoch=$(date -u -d "${published_at}" +%s 2>/dev/null || true) |
| 422 |
fi |
| 423 |
if [[ -n "${published_epoch}" ]]; then |
| 424 |
age_days=$(( ( $(date -u +%s) - published_epoch ) / 86400 )) |
| 425 |
if [[ "${age_days}" -gt 2 ]]; then |
| 426 |
echo "::warning ::The reference results are ${age_days} days old (${published_at}); the comparison below may report unrelated fixes and regressions." |
| 427 |
fi |
| 428 |
fi |
| 429 |
else |
| 430 |
rm -f reference/aggregated-result/aggregated-result.json reference/test-summary/gnu-result.json |
| 431 |
echo "::warning ::No reference results found on the '${REFERENCE_BRANCH}' branch; the comparisons below will be skipped." |
| 432 |
fi |
| 433 |
- name: Download full json results |
| 434 |
uses: actions/download-artifact@v8 |
| 435 |
with: |
| 436 |
name: gnu-full-result |
| 437 |
path: results |
| 438 |
merge-multiple: true |
| 439 |
- name: Download root json results |
| 440 |
uses: actions/download-artifact@v8 |
| 441 |
with: |
| 442 |
name: gnu-root-full-result |
| 443 |
path: results |
| 444 |
merge-multiple: true |
| 445 |
- name: Download stty json results |
| 446 |
uses: actions/download-artifact@v8 |
| 447 |
with: |
| 448 |
name: gnu-stty-full-result |
| 449 |
path: results |
| 450 |
merge-multiple: true |
| 451 |
|
| 452 |
- name: Download selinux json results |
| 453 |
uses: actions/download-artifact@v8 |
| 454 |
with: |
| 455 |
name: selinux-gnu-full-result |
| 456 |
path: results |
| 457 |
merge-multiple: true |
| 458 |
- name: Download selinux root json results |
| 459 |
uses: actions/download-artifact@v8 |
| 460 |
with: |
| 461 |
name: selinux-root-gnu-full-result |
| 462 |
path: results |
| 463 |
merge-multiple: true |
| 464 |
- name: Download SMACK/ROOTFS json results |
| 465 |
uses: actions/download-artifact@v8 |
| 466 |
with: |
| 467 |
name: qemu-gnu-full-result |
| 468 |
path: results |
| 469 |
merge-multiple: true |
| 470 |
- name: Extract/summarize testing info |
| 471 |
id: summary |
| 472 |
shell: bash |
| 473 |
run: | |
| 474 |
## Extract/summarize testing info |
| 475 |
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } |
| 476 |
|
| 477 |
path_UUTILS='uutils' |
| 478 |
|
| 479 |
json_count=$(ls -l results/*.json | wc -l) |
| 480 |
if [[ "$json_count" -ne 6 ]]; then |
| 481 |
echo "::error ::Failed to download all results json files (expected 6 files, found $json_count); failing early" |
| 482 |
ls -lR results || true |
| 483 |
exit 1 |
| 484 |
fi |
| 485 |
|
| 486 |
# Look at all individual results and summarize |
| 487 |
eval $(python3 uutils/util/analyze-gnu-results.py -o=${{ steps.vars.outputs.AGGREGATED_SUMMARY_FILE }} results/*.json) |
| 488 |
|
| 489 |
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then |
| 490 |
echo "::error ::Failed to parse test results from '${{ env.TEST_FULL_SUMMARY_FILE }}'; failing early" |
| 491 |
exit 1 |
| 492 |
fi |
| 493 |
|
| 494 |
output="GNU tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / ERROR: $ERROR / SKIP: $SKIP" |
| 495 |
echo "${output}" |
| 496 |
|
| 497 |
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then |
| 498 |
echo "::warning ::${output}" |
| 499 |
fi |
| 500 |
|
| 501 |
jq -n \ |
| 502 |
--arg date "$(date --rfc-email)" \ |
| 503 |
--arg sha "$GITHUB_SHA" \ |
| 504 |
--arg total "$TOTAL" \ |
| 505 |
--arg pass "$PASS" \ |
| 506 |
--arg skip "$SKIP" \ |
| 507 |
--arg fail "$FAIL" \ |
| 508 |
--arg xpass "$XPASS" \ |
| 509 |
--arg error "$ERROR" \ |
| 510 |
'{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, xpass: $xpass, error: $error, }}' > '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' |
| 511 |
HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1) |
| 512 |
outputs HASH |
| 513 |
- name: Upload SHA1/ID of 'test-summary' |
| 514 |
uses: actions/upload-artifact@v7 |
| 515 |
with: |
| 516 |
name: "${{ steps.summary.outputs.HASH }}" |
| 517 |
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}" |
| 518 |
- name: Upload test results summary |
| 519 |
uses: actions/upload-artifact@v7 |
| 520 |
with: |
| 521 |
name: test-summary |
| 522 |
path: "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}" |
| 523 |
- name: Upload aggregated json results |
| 524 |
uses: actions/upload-artifact@v7 |
| 525 |
with: |
| 526 |
name: aggregated-result |
| 527 |
path: ${{ steps.vars.outputs.AGGREGATED_SUMMARY_FILE }} |
| 528 |
- name: Compare test failures VS reference |
| 529 |
shell: bash |
| 530 |
run: | |
| 531 |
## Compare test failures VS reference using JSON files |
| 532 |
REF_SUMMARY_FILE='reference/aggregated-result/aggregated-result.json' |
| 533 |
CURRENT_SUMMARY_FILE='${{ steps.vars.outputs.AGGREGATED_SUMMARY_FILE }}' |
| 534 |
REPO_DEFAULT_BRANCH='${{ env.DEFAULT_BRANCH }}' |
| 535 |
path_UUTILS='uutils' |
| 536 |
|
| 537 |
# Path to ignore file for intermittent issues |
| 538 |
IGNORE_INTERMITTENT="uutils/.github/workflows/ignore-intermittent.txt" |
| 539 |
|
| 540 |
# Set up comment directory |
| 541 |
COMMENT_DIR="reference/comment" |
| 542 |
mkdir -p ${COMMENT_DIR} |
| 543 |
echo ${{ github.event.number }} > ${COMMENT_DIR}/NR |
| 544 |
COMMENT_LOG="${COMMENT_DIR}/result.txt" |
| 545 |
|
| 546 |
COMPARISON_RESULT=0 |
| 547 |
if test -f "${CURRENT_SUMMARY_FILE}"; then |
| 548 |
if test -f "${REF_SUMMARY_FILE}"; then |
| 549 |
echo "Reference summary SHA1/ID: $(sha1sum -- "${REF_SUMMARY_FILE}")" |
| 550 |
echo "Current summary SHA1/ID: $(sha1sum -- "${CURRENT_SUMMARY_FILE}")" |
| 551 |
|
| 552 |
python3 uutils/util/compare_test_results.py \ |
| 553 |
--ignore-file "${IGNORE_INTERMITTENT}" \ |
| 554 |
--output "${COMMENT_LOG}" \ |
| 555 |
"${CURRENT_SUMMARY_FILE}" "${REF_SUMMARY_FILE}" |
| 556 |
|
| 557 |
COMPARISON_RESULT=$? |
| 558 |
else |
| 559 |
echo "::warning ::Skipping test comparison; no prior reference summary is available at '${REF_SUMMARY_FILE}'." |
| 560 |
fi |
| 561 |
else |
| 562 |
echo "::error ::Failed to find summary of test results (missing '${CURRENT_SUMMARY_FILE}'); failing early" |
| 563 |
exit 1 |
| 564 |
fi |
| 565 |
|
| 566 |
if [ ${COMPARISON_RESULT} -eq 1 ]; then |
| 567 |
echo "ONLY_INTERMITTENT=false" >> $GITHUB_ENV |
| 568 |
echo "::error ::Found new non-intermittent test failures" |
| 569 |
exit 1 |
| 570 |
else |
| 571 |
echo "ONLY_INTERMITTENT=true" >> $GITHUB_ENV |
| 572 |
echo "::notice ::No new test failures detected" |
| 573 |
fi |
| 574 |
- name: Upload comparison log (for GnuComment workflow) |
| 575 |
if: success() || failure() # run regardless of prior step success/failure |
| 576 |
uses: actions/upload-artifact@v7 |
| 577 |
with: |
| 578 |
name: comment |
| 579 |
path: reference/comment/ |
| 580 |
- name: Compare test summary VS reference |
| 581 |
if: success() || failure() # run regardless of prior step success/failure |
| 582 |
shell: bash |
| 583 |
run: | |
| 584 |
## Compare test summary VS reference |
| 585 |
REF_SUMMARY_FILE='reference/test-summary/gnu-result.json' |
| 586 |
if test -f "${REF_SUMMARY_FILE}"; then |
| 587 |
echo "Reference SHA1/ID: $(sha1sum -- "${REF_SUMMARY_FILE}")" |
| 588 |
mv "${REF_SUMMARY_FILE}" main-gnu-result.json |
| 589 |
python uutils/util/compare_gnu_result.py |
| 590 |
else |
| 591 |
echo "::warning ::Skipping test summary comparison; no prior reference summary is available." |
| 592 |
fi |
| 593 |
|
| 594 |
publish-reference: |
| 595 |
## Publish this run's results as the reference that every later PR run is |
| 596 |
## compared against. Only runs on a push to the default branch, so a fork |
| 597 |
## PR can never reach it. |
| 598 |
needs: aggregate |
| 599 |
if: > |
| 600 |
always() |
| 601 |
&& github.event_name == 'push' |
| 602 |
&& github.ref_name == github.event.repository.default_branch |
| 603 |
&& needs.aggregate.result != 'cancelled' |
| 604 |
&& needs.aggregate.result != 'skipped' |
| 605 |
permissions: |
| 606 |
actions: read # to download this run's own result artifacts |
| 607 |
contents: write # to push to the reference branch |
| 608 |
name: Publish reference GNU test results |
| 609 |
runs-on: ubuntu-24.04 |
| 610 |
## Only one run may publish at a time. The step below reads the currently |
| 611 |
## published run id and then force-pushes; two overlapping runs could |
| 612 |
## interleave those, letting an older one overwrite a newer reference. |
| 613 |
concurrency: |
| 614 |
group: publish-gnu-reference |
| 615 |
cancel-in-progress: false |
| 616 |
steps: |
| 617 |
- name: Download aggregated json results |
| 618 |
continue-on-error: true ## 'aggregate' may have failed before uploading |
| 619 |
uses: actions/download-artifact@v8 |
| 620 |
with: |
| 621 |
name: aggregated-result |
| 622 |
path: publish |
| 623 |
- name: Download test results summary |
| 624 |
continue-on-error: true ## 'aggregate' may have failed before uploading |
| 625 |
uses: actions/download-artifact@v8 |
| 626 |
with: |
| 627 |
name: test-summary |
| 628 |
path: publish |
| 629 |
- name: Publish to the reference branch |
| 630 |
shell: bash |
| 631 |
env: |
| 632 |
GH_TOKEN: ${{ github.token }} |
| 633 |
run: | |
| 634 |
## Publish to the reference branch |
| 635 |
## The branch is a single-commit orphan history, force-pushed on every |
| 636 |
## run, so it never accumulates history. Runs on the default branch can |
| 637 |
## finish out of order, so refuse to overwrite a reference published by a |
| 638 |
## *newer* run (run ids are monotonic). |
| 639 |
if [[ ! -s publish/aggregated-result.json || ! -s publish/gnu-result.json ]]; then |
| 640 |
echo "::warning ::This run produced no results to publish; leaving the '${REFERENCE_BRANCH}' branch untouched." |
| 641 |
exit 0 |
| 642 |
fi |
| 643 |
## Fail closed: only a 404 means nothing has been published yet. A |
| 644 |
## suppressed error read as run id 0 would let this run force-push over |
| 645 |
## a reference a newer run had already placed. |
| 646 |
published_run=0 |
| 647 |
meta_err="${RUNNER_TEMP:-/tmp}/published-meta.err" |
| 648 |
for attempt in 1 2 3; do |
| 649 |
if published_meta=$(gh api "repos/${{ github.repository }}/contents/meta.json?ref=${REFERENCE_BRANCH}" \ |
| 650 |
-H 'Accept: application/vnd.github.raw' 2>"${meta_err}"); then |
| 651 |
published_run=$(jq -r '.run_id // 0' <<< "${published_meta}" 2>/dev/null || echo 0) |
| 652 |
break |
| 653 |
fi |
| 654 |
if grep -q 'HTTP 404' "${meta_err}"; then |
| 655 |
break |
| 656 |
fi |
| 657 |
if [[ "${attempt}" -eq 3 ]]; then |
| 658 |
cat "${meta_err}" >&2 |
| 659 |
echo "::error ::Could not read the published reference; refusing to force-push over a possibly newer one." |
| 660 |
exit 1 |
| 661 |
fi |
| 662 |
sleep $(( attempt * 5 )) |
| 663 |
done |
| 664 |
if [[ "${published_run}" =~ ^[0-9]+$ ]] && (( published_run > GITHUB_RUN_ID )); then |
| 665 |
echo "::notice ::Run ${published_run} already published a newer reference; nothing to do." |
| 666 |
exit 0 |
| 667 |
fi |
| 668 |
jq -n --arg sha "${GITHUB_SHA}" \ |
| 669 |
--arg run_id "${GITHUB_RUN_ID}" \ |
| 670 |
--arg branch "${GITHUB_REF_NAME}" \ |
| 671 |
--arg published_at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ |
| 672 |
'{sha: $sha, run_id: $run_id, branch: $branch, published_at: $published_at}' \ |
| 673 |
> publish/meta.json |
| 674 |
printf '%s\n' \ |
| 675 |
'# GNU test reference results' \ |
| 676 |
'' \ |
| 677 |
'Machine-maintained branch: the GNU test results of the latest run of' \ |
| 678 |
'the `GnuTests` workflow on the default branch. Every pull request run' \ |
| 679 |
'is compared against the files here, so that it reports only the test' \ |
| 680 |
'changes the pull request is itself responsible for.' \ |
| 681 |
'' \ |
| 682 |
'Do not commit here by hand; the branch is force-pushed on every run.' \ |
| 683 |
> publish/README.md |
| 684 |
cd publish |
| 685 |
git init -q -b "${REFERENCE_BRANCH}" |
| 686 |
git config user.name 'github-actions[bot]' |
| 687 |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 688 |
git add -A |
| 689 |
git commit -q -m "GNU test results for ${GITHUB_SHA}" |
| 690 |
git push -q --force \ |
| 691 |
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \ |
| 692 |
"HEAD:refs/heads/${REFERENCE_BRANCH}" |
| 693 |
echo "::notice ::Published reference results for ${GITHUB_SHA}." |