2021-06-13 04:37:00 +00:00
name : GnuTests
2021-01-21 07:19:08 +00:00
2023-01-18 17:35:26 +00:00
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests
# spell-checker:ignore (jargon) submodules
# spell-checker:ignore (libs/utils) autopoint chksum gperf lcov libexpect pyinotify shopt texinfo valgrind
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
# spell-checker:ignore (people) Dawid Dziurla * dawidd
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS
2022-02-22 14:00:37 +00:00
# * note: to run a single test => `REPO/util/run-gnu-test.sh PATH/TO/TEST/SCRIPT`
2021-06-12 22:34:48 +00:00
2022-10-08 12:57:01 +00:00
on : [ push, pull_request]
2021-01-21 07:19:08 +00:00
2022-09-25 14:17:38 +00:00
permissions :
contents : read
2021-01-21 07:19:08 +00:00
jobs :
gnu :
2022-04-29 01:01:27 +00:00
permissions :
actions : read # for dawidd6/action-download-artifact to query and download artifacts
contents : read # for actions/checkout to fetch code
2022-10-09 17:12:38 +00:00
pull-requests : read # for dawidd6/action-download-artifact to query commit hash
2021-01-21 07:19:08 +00:00
name : Run GNU tests
2022-11-29 16:43:12 +00:00
runs-on : ubuntu-20.04
2021-01-21 07:19:08 +00:00
steps :
2022-02-03 19:42:13 +00:00
- name : Initialize workflow variables
id : vars
shell : bash
run : |
## VARs setup
2023-01-18 17:43:07 +00:00
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
2022-02-03 19:42:13 +00:00
# * config
path_GNU="gnu"
2022-02-11 06:52:28 +00:00
path_GNU_tests="${path_GNU}/tests"
2022-02-03 19:42:13 +00:00
path_UUTILS="uutils"
path_reference="reference"
2022-02-11 06:52:28 +00:00
outputs path_GNU path_GNU_tests path_reference path_UUTILS
2022-02-03 19:42:13 +00:00
#
2022-02-06 18:14:12 +00:00
repo_default_branch="${{ github.event.repository.default_branch }}"
2022-04-18 12:54:54 +00:00
repo_GNU_ref="v9.1"
2022-02-03 19:42:13 +00:00
repo_reference_branch="${{ github.event.repository.default_branch }}"
2022-02-12 17:13:04 +00:00
outputs repo_default_branch repo_GNU_ref repo_reference_branch
2022-02-03 19:42:13 +00:00
#
SUITE_LOG_FILE="${path_GNU_tests}/test-suite.log"
2022-09-16 07:14:13 +00:00
ROOT_SUITE_LOG_FILE="${path_GNU_tests}/test-suite-root.log"
2022-02-03 19:42:13 +00:00
TEST_LOGS_GLOB="${path_GNU_tests}/**/*.log" ## note: not usable at bash CLI; [why] double globstar not enabled by default b/c MacOS includes only bash v3 which doesn't have double globstar support
TEST_FILESET_PREFIX='test-fileset-IDs.sha1#'
TEST_FILESET_SUFFIX='.txt'
TEST_SUMMARY_FILE='gnu-result.json'
2022-02-13 15:51:24 +00:00
TEST_FULL_SUMMARY_FILE='gnu-full-result.json'
2022-09-17 09:08:12 +00:00
outputs SUITE_LOG_FILE ROOT_SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
2022-02-11 06:52:28 +00:00
- name : Checkout code (uutil)
2022-05-06 06:38:11 +00:00
uses : actions/checkout@v3
2021-01-21 07:19:08 +00:00
with :
2022-02-03 19:42:13 +00:00
path : '${{ steps.vars.outputs.path_UUTILS }}'
2022-02-11 06:52:28 +00:00
- name : Checkout code (GNU coreutils)
2022-05-06 06:38:11 +00:00
uses : actions/checkout@v3
2021-01-21 07:19:08 +00:00
with :
repository : 'coreutils/coreutils'
2022-02-03 19:42:13 +00:00
path : '${{ steps.vars.outputs.path_GNU }}'
ref : ${{ steps.vars.outputs.repo_GNU_ref }}
2022-02-11 06:52:28 +00:00
submodules : recursive
2022-02-03 19:42:13 +00:00
- name : Retrieve reference artifacts
uses : dawidd6/action-download-artifact@v2
2022-02-08 17:11:15 +00:00
# ref: <https://github.com/dawidd6/action-download-artifact>
2022-02-03 19:42:13 +00:00
continue-on-error : true ## don't break the build for missing reference artifacts (may be expired or just not generated yet)
with :
workflow : GnuTests.yml
branch : "${{ steps.vars.outputs.repo_reference_branch }}"
2022-02-08 17:11:15 +00:00
# workflow_conclusion: success ## (default); * but, if commit with failed GnuTests is merged into the default branch, future commits will all show regression errors in GnuTests CI until o/w fixed
workflow_conclusion : completed ## continually recalibrates to last commit of default branch with a successful GnuTests (ie, "self-heals" from GnuTest regressions, but needs more supervision for/of regressions)
2022-02-03 19:42:13 +00:00
path : "${{ steps.vars.outputs.path_reference }}"
2021-01-21 07:19:08 +00:00
- name : Install `rust` toolchain
2022-11-19 06:59:51 +00:00
run : |
2023-01-18 17:41:39 +00:00
## Install `rust` toolchain
2022-11-19 06:59:51 +00:00
rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt}
rustup toolchain install stable -c rustfmt --profile minimal
rustup default stable
2021-06-12 22:34:48 +00:00
- name : Install dependencies
2021-01-21 07:19:08 +00:00
shell : bash
run : |
2021-06-12 22:34:48 +00:00
## Install dependencies
2021-02-03 21:27:30 +00:00
sudo apt-get update
2022-11-24 09:13:26 +00:00
sudo apt-get install autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl
2022-02-12 18:20:17 +00:00
- name : Add various locales
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Add various locales
2022-02-12 18:20:17 +00:00
echo "Before:"
locale -a
## Some tests fail with 'cannot change locale (en_US.ISO-8859-1): No such file or directory'
## Some others need a French locale
sudo locale-gen
2022-09-16 07:07:42 +00:00
sudo locale-gen --keep-existing fr_FR
sudo locale-gen --keep-existing fr_FR.UTF-8
sudo locale-gen --keep-existing sv_SE
sudo locale-gen --keep-existing sv_SE.UTF-8
sudo locale-gen --keep-existing en_US
sudo locale-gen --keep-existing ru_RU.KOI8-R
2022-02-12 18:20:17 +00:00
sudo update-locale
echo "After:"
locale -a
2021-05-21 11:27:35 +00:00
- name : Build binaries
shell : bash
run : |
2021-06-12 22:34:48 +00:00
## Build binaries
2022-02-03 19:42:13 +00:00
cd '${{ steps.vars.outputs.path_UUTILS }}'
2021-06-12 22:34:48 +00:00
bash util/build-gnu.sh
2021-01-21 22:56:02 +00:00
- name : Run GNU tests
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Run GNU tests
2022-02-03 19:42:13 +00:00
path_GNU='${{ steps.vars.outputs.path_GNU }}'
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
bash "${path_UUTILS}/util/run-gnu-test.sh"
2022-09-17 09:08:12 +00:00
- name : Run GNU root tests
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Run GNU root tests
2022-09-17 09:08:12 +00:00
path_GNU='${{ steps.vars.outputs.path_GNU }}'
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
bash "${path_UUTILS}/util/run-gnu-test.sh" run-root
2022-02-13 15:51:24 +00:00
- name : Extract testing info into JSON
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Extract testing info into JSON
2022-02-13 15:51:24 +00:00
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
python ${path_UUTILS}/util/gnu-json-result.py ${{ steps.vars.outputs.path_GNU_tests }} > ${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}
2022-02-03 19:42:13 +00:00
- name : Extract/summarize testing info
id : summary
2021-02-11 14:42:41 +00:00
shell : bash
run : |
2022-02-03 19:42:13 +00:00
## Extract/summarize testing info
2023-01-18 17:43:07 +00:00
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
2022-02-03 19:42:13 +00:00
#
2023-01-18 17:41:39 +00:00
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
#
2022-02-03 19:42:13 +00:00
SUITE_LOG_FILE='${{ steps.vars.outputs.SUITE_LOG_FILE }}'
2022-09-16 07:14:13 +00:00
ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.ROOT_SUITE_LOG_FILE }}'
ls -al ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
2022-02-03 19:42:13 +00:00
if test -f "${SUITE_LOG_FILE}"
2021-03-21 14:45:34 +00:00
then
2022-09-16 07:14:13 +00:00
source ${path_UUTILS}/util/analyze-gnu-results.sh ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
2021-06-22 16:03:12 +00:00
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then
2022-02-03 19:42:13 +00:00
echo "::error ::Failed to parse test results from '${SUITE_LOG_FILE}'; failing early"
2022-02-02 05:01:56 +00:00
exit 1
2021-06-22 12:25:32 +00:00
fi
2022-04-01 08:00:44 +00:00
output="GNU tests summary = TOTAL: $TOTAL / PASS: $PASS / FAIL: $FAIL / ERROR: $ERROR / SKIP: $SKIP"
2021-06-12 22:34:48 +00:00
echo "${output}"
if [[ "$FAIL" -gt 0 || "$ERROR" -gt 0 ]]; then echo "::warning ::${output}" ; fi
2021-05-18 19:31:55 +00:00
jq -n \
2021-05-19 18:33:28 +00:00
--arg date "$(date --rfc-email)" \
2021-05-22 19:59:54 +00:00
--arg sha "$GITHUB_SHA" \
2021-05-18 19:31:55 +00:00
--arg total "$TOTAL" \
--arg pass "$PASS" \
--arg skip "$SKIP" \
--arg fail "$FAIL" \
--arg xpass "$XPASS" \
--arg error "$ERROR" \
2022-02-03 19:42:13 +00:00
'{($date): { sha: $sha, total: $total, pass: $pass, skip: $skip, fail: $fail, xpass: $xpass, error: $error, }}' > '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}'
HASH=$(sha1sum '${{ steps.vars.outputs.TEST_SUMMARY_FILE }}' | cut --delim=" " -f 1)
outputs HASH
2021-03-21 14:45:34 +00:00
else
2022-02-03 19:42:13 +00:00
echo "::error ::Failed to find summary of test results (missing '${SUITE_LOG_FILE}'); failing early"
exit 1
2021-03-21 14:45:34 +00:00
fi
2022-03-18 11:01:48 +00:00
# Compress logs before upload (fails otherwise)
gzip ${{ steps.vars.outputs.TEST_LOGS_GLOB }}
2022-02-03 19:42:13 +00:00
- name : Reserve SHA1/ID of 'test-summary'
2022-05-06 06:38:13 +00:00
uses : actions/upload-artifact@v3
2021-05-18 19:31:55 +00:00
with :
2022-02-03 19:42:13 +00:00
name : "${{ steps.summary.outputs.HASH }}"
path : "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name : Reserve test results summary
2022-05-06 06:38:13 +00:00
uses : actions/upload-artifact@v3
2021-08-05 14:44:03 +00:00
with :
2022-02-03 19:42:13 +00:00
name : test-summary
path : "${{ steps.vars.outputs.TEST_SUMMARY_FILE }}"
- name : Reserve test logs
2022-05-06 06:38:13 +00:00
uses : actions/upload-artifact@v3
2021-08-08 14:48:38 +00:00
with :
2022-02-03 19:42:13 +00:00
name : test-logs
path : "${{ steps.vars.outputs.TEST_LOGS_GLOB }}"
2022-02-13 15:51:24 +00:00
- name : Upload full json results
2022-05-06 06:38:13 +00:00
uses : actions/upload-artifact@v3
2022-02-13 15:51:24 +00:00
with :
name : gnu-full-result.json
path : ${{ steps.vars.outputs.TEST_FULL_SUMMARY_FILE }}
2022-02-03 19:42:13 +00:00
- name : Compare test failures VS reference
2021-08-08 14:48:38 +00:00
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Compare test failures VS reference
2022-02-14 03:46:45 +00:00
have_new_failures=""
2022-02-03 19:42:13 +00:00
REF_LOG_FILE='${{ steps.vars.outputs.path_reference }}/test-logs/test-suite.log'
REF_SUMMARY_FILE='${{ steps.vars.outputs.path_reference }}/test-summary/gnu-result.json'
2022-03-31 21:38:46 +00:00
REPO_DEFAULT_BRANCH='${{ steps.vars.outputs.repo_default_branch }}'
2022-10-08 13:08:44 +00:00
2022-10-08 12:57:01 +00:00
mkdir -p ${{ steps.vars.outputs.path_reference }}
2022-10-08 13:08:44 +00:00
COMMENT_DIR="${{ steps.vars.outputs.path_reference }}/comment"
mkdir -p ${COMMENT_DIR}
echo ${{ github.event.number }} > ${COMMENT_DIR}/NR
COMMENT_LOG="${COMMENT_DIR}/result.txt"
2022-10-09 21:03:12 +00:00
# The comment log might be downloaded from a previous run
# We only want the new changes, so remove it if it exists.
rm -f ${COMMENT_LOG}
2022-10-08 12:57:01 +00:00
touch ${COMMENT_LOG}
2022-10-08 13:08:44 +00:00
2022-02-03 19:42:13 +00:00
if test -f "${REF_LOG_FILE}"; then
2022-02-14 03:46:45 +00:00
echo "Reference SHA1/ID: $(sha1sum -- "${REF_SUMMARY_FILE}")"
2022-05-06 21:54:12 +00:00
REF_ERROR=$(sed -n "s/^ERROR: \([[:print:]]\+\).*/\1/p" "${REF_LOG_FILE}" | sort)
NEW_ERROR=$(sed -n "s/^ERROR: \([[:print:]]\+\).*/\1/p" '${{ steps.vars.outputs.path_GNU_tests }}/test-suite.log' | sort)
2022-02-03 19:42:13 +00:00
REF_FAILING=$(sed -n "s/^FAIL: \([[:print:]]\+\).*/\1/p" "${REF_LOG_FILE}" | sort)
NEW_FAILING=$(sed -n "s/^FAIL: \([[:print:]]\+\).*/\1/p" '${{ steps.vars.outputs.path_GNU_tests }}/test-suite.log' | sort)
2022-02-14 03:46:45 +00:00
for LINE in ${REF_FAILING}
2022-02-03 19:42:13 +00:00
do
2022-02-14 03:46:45 +00:00
if ! grep -Fxq ${LINE}<<<"${NEW_FAILING}"; then
2022-10-08 12:57:01 +00:00
MSG="Congrats! The gnu test ${LINE} is no longer failing!"
echo "::warning ::$MSG"
echo $MSG >> ${COMMENT_LOG}
2022-02-03 19:42:13 +00:00
fi
done
2022-02-14 03:46:45 +00:00
for LINE in ${NEW_FAILING}
2022-02-03 19:42:13 +00:00
do
2022-02-14 03:46:45 +00:00
if ! grep -Fxq ${LINE}<<<"${REF_FAILING}"
2022-02-03 19:42:13 +00:00
then
2022-10-08 12:57:01 +00:00
MSG="GNU test failed: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?"
echo "::error ::$MSG"
echo $MSG >> ${COMMENT_LOG}
2022-02-14 03:46:45 +00:00
have_new_failures="true"
2022-02-03 19:42:13 +00:00
fi
done
2022-05-01 15:07:29 +00:00
for LINE in ${REF_ERROR}
do
if ! grep -Fxq ${LINE}<<<"${NEW_ERROR}"; then
2022-10-08 12:57:01 +00:00
MSG="Congrats! The gnu test ${LINE} is no longer ERROR!"
echo "::warning ::$MSG"
echo $MSG >> ${COMMENT_LOG}
2022-05-01 15:07:29 +00:00
fi
done
for LINE in ${NEW_ERROR}
do
if ! grep -Fxq ${LINE}<<<"${REF_ERROR}"
then
2022-10-08 12:57:01 +00:00
MSG="GNU test error: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?"
echo "::error ::$MSG"
echo $MSG >> ${COMMENT_LOG}
2022-05-01 15:07:29 +00:00
have_new_failures="true"
fi
done
2022-02-03 19:42:13 +00:00
else
echo "::warning ::Skipping test failure comparison; no prior reference test logs are available."
fi
2022-02-14 03:46:45 +00:00
if test -n "${have_new_failures}" ; then exit -1 ; fi
2022-10-08 13:08:44 +00:00
- name : Upload comparison log (for GnuComment workflow)
2022-10-08 21:53:48 +00:00
if : success() || failure() # run regardless of prior step success/failure
2022-10-08 12:57:01 +00:00
uses : actions/upload-artifact@v3
with :
2022-10-08 13:08:44 +00:00
name : comment
path : ${{ steps.vars.outputs.path_reference }}/comment/
2022-02-03 19:42:13 +00:00
- name : Compare test summary VS reference
2022-02-14 03:46:45 +00:00
if : success() || failure() # run regardless of prior step success/failure
2021-08-05 14:44:03 +00:00
shell : bash
run : |
2023-01-18 17:41:39 +00:00
## Compare test summary VS reference
2022-02-03 19:42:13 +00:00
REF_SUMMARY_FILE='${{ steps.vars.outputs.path_reference }}/test-summary/gnu-result.json'
if test -f "${REF_SUMMARY_FILE}"; then
2022-02-14 03:46:45 +00:00
echo "Reference SHA1/ID: $(sha1sum -- "${REF_SUMMARY_FILE}")"
2022-02-03 19:42:13 +00:00
mv "${REF_SUMMARY_FILE}" main-gnu-result.json
python uutils/util/compare_gnu_result.py
else
echo "::warning ::Skipping test summary comparison; no prior reference summary is available."
fi
2022-02-03 10:03:48 +00:00
gnu_coverage :
name : Run GNU tests with coverage
2022-11-29 16:43:12 +00:00
runs-on : ubuntu-20.04
2022-02-03 10:03:48 +00:00
steps :
- name : Checkout code uutil
2022-05-06 06:38:11 +00:00
uses : actions/checkout@v3
2022-02-03 10:03:48 +00:00
with :
path : 'uutils'
- name : Checkout GNU coreutils
2022-05-06 06:38:11 +00:00
uses : actions/checkout@v3
2022-02-03 10:03:48 +00:00
with :
repository : 'coreutils/coreutils'
path : 'gnu'
2022-04-17 22:34:42 +00:00
ref : 'v9.1'
2022-02-03 10:03:48 +00:00
submodules : recursive
- name : Install `rust` toolchain
2022-11-19 06:59:51 +00:00
run : |
2023-01-18 17:41:39 +00:00
## Install `rust` toolchain
2022-11-19 06:59:51 +00:00
rm -f "${HOME}/.cargo/bin/"{rustfmt,cargo-fmt}
rustup toolchain install nightly -c rustfmt --profile minimal
rustup default nightly
2022-02-03 10:03:48 +00:00
- name : Install dependencies
run : |
2023-01-18 17:41:39 +00:00
## Install dependencies
2022-02-03 10:03:48 +00:00
sudo apt update
2022-11-24 09:13:26 +00:00
sudo apt install autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl -y
2022-02-03 10:03:48 +00:00
- name : Add various locales
run : |
2023-01-18 17:41:39 +00:00
## Add various locales
2022-02-03 10:03:48 +00:00
echo "Before:"
locale -a
## Some tests fail with 'cannot change locale (en_US.ISO-8859-1): No such file or directory'
## Some others need a French locale
sudo locale-gen
2022-09-16 07:07:42 +00:00
sudo locale-gen --keep-existing fr_FR
sudo locale-gen --keep-existing fr_FR.UTF-8
2022-02-03 10:03:48 +00:00
sudo update-locale
echo "After:"
locale -a
- name : Build binaries
env :
CARGO_INCREMENTAL : "0"
RUSTFLAGS : "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS : "-Cpanic=abort"
run : |
2023-01-18 17:41:39 +00:00
## Build binaries
2022-02-03 10:03:48 +00:00
cd uutils
UU_MAKE_PROFILE=debug bash util/build-gnu.sh
- name : Run GNU tests
run : bash uutils/util/run-gnu-test.sh
- name : "`grcov` ~ install"
2022-11-19 08:54:44 +00:00
run : cargo install grcov
2022-02-03 10:03:48 +00:00
- name : Generate coverage data (via `grcov`)
id : coverage
run : |
## Generate coverage data
cd uutils
COVERAGE_REPORT_DIR="target/debug"
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
mkdir -p "${COVERAGE_REPORT_DIR}"
2022-02-20 11:15:48 +00:00
sudo chown -R "$(whoami)" "${COVERAGE_REPORT_DIR}"
2022-02-03 10:03:48 +00:00
# display coverage files
2022-11-15 07:54:13 +00:00
grcov . --output-type files --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
2022-02-03 10:03:48 +00:00
# generate coverage report
2022-11-15 07:54:13 +00:00
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
2022-10-20 06:59:00 +00:00
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
2022-02-03 10:03:48 +00:00
- name : Upload coverage results (to Codecov.io)
2022-05-06 06:38:03 +00:00
uses : codecov/codecov-action@v3
2022-02-03 10:03:48 +00:00
with :
file : ${{ steps.coverage.outputs.report }}
flags : gnutests
name : gnutests
working-directory : uutils