diff --git a/.editorconfig b/.editorconfig index d93fa7c0e..53ccc4f9a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# EditorConfig (is awesome): http://EditorConfig.org +# EditorConfig (is awesome!; ref: http://EditorConfig.org; v2022.02.11 [rivy]) # * top-most EditorConfig file root = true @@ -13,27 +13,49 @@ insert_final_newline = true max_line_length = 100 trim_trailing_whitespace = true -[[Mm]akefile{,.*}, *.{mk,[Mm][Kk]}] +[{[Mm]akefile{,.*},*.{mak,mk,[Mm][Aa][Kk],[Mm][Kk]},[Gg][Nn][Uu]makefile}] # makefiles ~ TAB-style indentation indent_style = tab +[*.bash] +# `bash` shell scripts +indent_size = 4 +indent_style = space +# * ref: +# shell_variant = bash ## allow `shellcheck` to decide via script hash-bang/sha-bang line +switch_case_indent = true + [*.{bat,cmd,[Bb][Aa][Tt],[Cc][Mm][Dd]}] # BAT/CMD ~ DOS/Win requires BAT/CMD files to have CRLF EOLNs end_of_line = crlf +[*.{cjs,cjx,cts,ctx,js,jsx,mjs,mts,mtx,ts,tsx,json,jsonc}] +# js/ts/json ~ Prettier/XO-style == TAB indention + SPACE alignment +indent_size = 2 +indent_style = tab + [*.go] # go ~ TAB-style indentation (SPACE-style alignment); ref: @@ indent_style = tab -[*.{cjs,js,json,mjs,ts}] -# js/ts -indent_size = 2 - [*.{markdown,md,mkd,[Mm][Dd],[Mm][Kk][Dd],[Mm][Dd][Oo][Ww][Nn],[Mm][Kk][Dd][Oo][Ww][Nn],[Mm][Aa][Rr][Kk][Dd][Oo][Ww][Nn]}] # markdown indent_size = 2 indent_style = space +[*.sh] +# POSIX shell scripts +indent_size = 4 +indent_style = space +# * ref: +# shell_variant = posix ## allow `shellcheck` to decide via script hash-bang/sha-bang line +switch_case_indent = true + +[*.{sln,vc{,x}proj{,.*},[Ss][Ln][Nn],[Vv][Cc]{,[Xx]}[Pp][Rr][Oo][Jj]{,.*}}] +# MSVC sln/vcproj/vcxproj files, when used, will persistantly revert to CRLF EOLNs and eat final EOLs +end_of_line = crlf +insert_final_newline = false + [*.{yaml,yml,[Yy][Mm][Ll],[Yy][Aa][Mm][Ll]}] # YAML indent_size = 2 diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 81147c8dc..b47540ed9 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -4,7 +4,7 @@ name: CICD # spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic # spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain # spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy -# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs +# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rsync rustc rustfmt rustup shopt xargs # spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend pell runtest tempfile testsuite uutils DESTDIR sizemulti # ToDO: [2021-06; rivy] change from `cargo-tree` to `cargo tree` once MSRV is >= 1.45 diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index 69a26608c..f95166c94 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -1,6 +1,6 @@ name: GnuTests -# spell-checker:ignore (names) gnulib ; (people) Dawid Dziurla * dawidd6 ; (utils) autopoint chksum gperf pyinotify shopt texinfo ; (vars) FILESET XPASS +# spell-checker:ignore (names) gnulib ; (jargon) submodules ; (people) Dawid Dziurla * dawidd ; (utils) autopoint chksum gperf pyinotify shopt texinfo ; (vars) FILESET XPASS on: [push, pull_request] @@ -17,16 +17,15 @@ jobs: outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; } # * config path_GNU="gnu" - path_GNULIB="gnulib" - path_GNU_tests="gnu/tests" + path_GNU_tests="${path_GNU}/tests" path_UUTILS="uutils" path_reference="reference" - outputs path_GNU path_GNU_tests path_GNULIB path_reference path_UUTILS + outputs path_GNU path_GNU_tests path_reference path_UUTILS # + repo_default_branch="${{ github.event.repository.default_branch }}" repo_GNU_ref="v9.0" - repo_GNULIB_ref="8e99f24c0931a38880c6ee9b8287c7da80b0036b" repo_reference_branch="${{ github.event.repository.default_branch }}" - outputs repo_GNU_ref repo_GNULIB_ref repo_reference_branch + outputs repo_default_branch repo_GNU_ref repo_reference_branch # SUITE_LOG_FILE="${path_GNU_tests}/test-suite.log" 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 @@ -34,29 +33,26 @@ jobs: TEST_FILESET_SUFFIX='.txt' TEST_SUMMARY_FILE='gnu-result.json' outputs SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE - - name: Checkout code uutil + - name: Checkout code (uutil) uses: actions/checkout@v2 with: path: '${{ steps.vars.outputs.path_UUTILS }}' - - name: Checkout GNU coreutils + - name: Checkout code (GNU coreutils) uses: actions/checkout@v2 with: repository: 'coreutils/coreutils' path: '${{ steps.vars.outputs.path_GNU }}' ref: ${{ steps.vars.outputs.repo_GNU_ref }} - - name: Checkout GNU coreutils library (gnulib) - uses: actions/checkout@v2 - with: - repository: 'coreutils/gnulib' - path: '${{ steps.vars.outputs.path_GNULIB }}' - ref: ${{ steps.vars.outputs.repo_GNULIB_ref }} - fetch-depth: 0 # full depth checkout (o/w gnu gets upset if gnulib is a shallow checkout) + submodules: recursive - name: Retrieve reference artifacts uses: dawidd6/action-download-artifact@v2 + # ref: 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 }}" + # 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) path: "${{ steps.vars.outputs.path_reference }}" - name: Install `rust` toolchain uses: actions-rs/toolchain@v1 @@ -81,7 +77,6 @@ jobs: shell: bash run: | path_GNU='${{ steps.vars.outputs.path_GNU }}' - path_GNULIB='${{ steps.vars.outputs.path_GNULIB }}' path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}' bash "${path_UUTILS}/util/run-gnu-test.sh" - name: Extract/summarize testing info @@ -157,7 +152,7 @@ jobs: do if ! grep -Fxq $LINE<<<"$REF_FAILING" then - echo "::error ::GNU test failed: $LINE. $LINE is passing on 'main'. Maybe you have to rebase?" + echo "::error ::GNU test failed: $LINE. $LINE is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?" fi done else diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 000000000..2a0c75141 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +# * using all default `cargo fmt`/`rustfmt` options diff --git a/.vscode/cSpell.json b/.vscode/cSpell.json index 2ff4d4b7e..6dfb3b666 100644 --- a/.vscode/cSpell.json +++ b/.vscode/cSpell.json @@ -1,7 +1,7 @@ // `cspell` settings { - // version of the setting file (always 0.1) - "version": "0.1", + // version of the setting file + "version": "0.2", // spelling language "language": "en", diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a02baee69..bd9dcf485 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,13 @@ // spell-checker:ignore (misc) matklad // see for the documentation about the extensions.json format +// * +// "foxundermoon.shell-format" ~ shell script formatting ; note: ENABLE "Use EditorConfig" +// "matklad.rust-analyzer" ~ `rust` language support +// "streetsidesoftware.code-spell-checker" ~ `cspell` spell-checker support { - "recommendations": [ - // Rust language support - "matklad.rust-analyzer", - // `cspell` spell-checker support - "streetsidesoftware.code-spell-checker" - ] + "recommendations": [ + "matklad.rust-analyzer", + "streetsidesoftware.code-spell-checker", + "foxundermoon.shell-format" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..54df63a5b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{ "cSpell.import": [".vscode/cspell.json"] } diff --git a/util/GHA-delete-GNU-workflow-logs.sh b/util/GHA-delete-GNU-workflow-logs.sh index f7406b831..ebeb7cfe8 100755 --- a/util/GHA-delete-GNU-workflow-logs.sh +++ b/util/GHA-delete-GNU-workflow-logs.sh @@ -2,10 +2,10 @@ # spell-checker:ignore (utils) gitsome jq ; (gh) repos -ME="${0}" -ME_dir="$(dirname -- "${ME}")" -ME_parent_dir="$(dirname -- "${ME_dir}")" -ME_parent_dir_abs="$(realpath -mP -- "${ME_parent_dir}")" +# ME="${0}" +# ME_dir="$(dirname -- "${ME}")" +# ME_parent_dir="$(dirname -- "${ME_dir}")" +# ME_parent_dir_abs="$(realpath -mP -- "${ME_parent_dir}")" # ref: @@ -33,12 +33,17 @@ if [ -z "${GH}" ] || [ -z "${JQ}" ]; then exit 1 fi -dry_run=true +case "${dry_run}" in + '0' | 'f' | 'false' | 'no' | 'never' | 'none') unset dry_run ;; + *) dry_run="true" ;; +esac -USER_NAME=uutils -REPO_NAME=coreutils -WORK_NAME=GNU +USER_NAME="${USER_NAME:-uutils}" +REPO_NAME="${REPO_NAME:-coreutils}" +WORK_NAME="${WORK_NAME:-GNU}" # * `--paginate` retrieves all pages # gh api --paginate "repos/${USER_NAME}/${REPO_NAME}/actions/runs" | jq -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z "$dry_run" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ -gh api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" | jq -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z "$dry_run" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ +gh api "repos/${USER_NAME}/${REPO_NAME}/actions/runs" | + jq -r ".workflow_runs[] | select(.name == \"${WORK_NAME}\") | (.id)" | + xargs -n1 sh -c "for arg do { echo gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; if [ -z \"${dry_run}\" ]; then gh api repos/${USER_NAME}/${REPO_NAME}/actions/runs/\${arg} -X DELETE ; fi ; } ; done ;" _ diff --git a/util/build-code_coverage.sh b/util/build-code_coverage.sh index b92b7eb48..4082bc13d 100755 --- a/util/build-code_coverage.sh +++ b/util/build-code_coverage.sh @@ -4,15 +4,16 @@ # spell-checker:ignore (jargon) toolchain # spell-checker:ignore (rust) Ccodegen Cinline Coverflow Cpanic RUSTC RUSTDOCFLAGS RUSTFLAGS RUSTUP Zpanic # spell-checker:ignore (shell) OSID esac -# spell-checker:ignore (utils) genhtml grcov lcov readlink sccache uutils +# spell-checker:ignore (utils) genhtml grcov lcov readlink sccache shellcheck uutils FEATURES_OPTION="--features feat_os_unix" -ME_dir="$(dirname -- "$(readlink -fm -- "$0")")" +ME="${0}" +ME_dir="$(dirname -- "$(readlink -fm -- "${ME}")")" REPO_main_dir="$(dirname -- "${ME_dir}")" cd "${REPO_main_dir}" && -echo "[ \"$PWD\" ]" + echo "[ \"$PWD\" ]" #shellcheck disable=SC2086 UTIL_LIST=$("${ME_dir}"/show-utils.sh ${FEATURES_OPTION}) @@ -26,13 +27,14 @@ done # cargo clean export CARGO_INCREMENTAL=0 -export RUSTC_WRAPPER="" ## NOTE: RUSTC_WRAPPER=='sccache' breaks code coverage calculations (uu_*.gcno files are not created during build) +export RUSTC_WRAPPER="" ## NOTE: RUSTC_WRAPPER=='sccache' breaks code coverage calculations (uu_*.gcno files are not created during build) # export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads" export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" export RUSTDOCFLAGS="-Cpanic=abort" export RUSTUP_TOOLCHAIN="nightly-gnu" #shellcheck disable=SC2086 -{ cargo build ${FEATURES_OPTION} +{ + cargo build ${FEATURES_OPTION} cargo test --no-run ${FEATURES_OPTION} cargo test --quiet ${FEATURES_OPTION} cargo test --quiet ${FEATURES_OPTION} ${CARGO_INDIVIDUAL_PACKAGE_OPTIONS} @@ -55,4 +57,5 @@ if genhtml --version 2>/dev/null 1>&2; then else grcov . --output-type html --output-path "${COVERAGE_REPORT_DIR}" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()' fi -if [ $? -ne 0 ]; then exit 1 ; fi +# shellcheck disable=SC2181 +if [ $? -ne 0 ]; then exit 1; fi diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 8f6e431a6..2ab23ddc7 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -1,64 +1,86 @@ #!/bin/bash +# `build-gnu.bash` ~ builds GNU coreutils (from supplied sources) +# +# UU_MAKE_PROFILE == 'debug' | 'release' ## build profile for *uutils* build; may be supplied by caller, defaults to 'debug' -# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode ; (vars/env) BUILDDIR SRCDIR +# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode submodules ; (vars/env) SRCDIR set -e -if test ! -d ../gnu; then - echo "Could not find ../gnu" - echo "git clone https://github.com/coreutils/coreutils.git gnu" - exit 1 -fi -if test ! -d ../gnulib; then - echo "Could not find ../gnulib" - echo "git clone https://github.com/coreutils/gnulib.git gnulib" + +ME="${0}" +ME_dir="$(dirname -- "$(readlink -fm -- "${ME}")")" +REPO_main_dir="$(dirname -- "${ME_dir}")" + +echo "ME='${ME}'" +echo "ME_dir='${ME_dir}'" +echo "REPO_main_dir='${REPO_main_dir}'" + +### * config (from environment with fallback defaults); note: GNU is expected to be a sibling repo directory + +path_UUTILS=${path_UUTILS:-${REPO_main_dir}} +path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" + +echo "path_UUTILS='${path_UUTILS}'" +echo "path_GNU='${path_GNU}'" + +### + +if test ! -d "${path_GNU}"; then + echo "Could not find GNU (expected at '${path_GNU}')" + echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\"" exit 1 fi +### -pushd "$PWD" -make PROFILE=release -BUILDDIR="$PWD/target/release/" -cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target +UU_MAKE_PROFILE=${UU_MAKE_PROFILE:-release} +echo "UU_MAKE_PROFILE='${UU_MAKE_PROFILE}'" + +UU_BUILD_DIR="${path_UUTILS}/target/${UU_MAKE_PROFILE}" +echo "UU_BUILD_DIR='${UU_BUILD_DIR}'" + +cd "${path_UUTILS}" && echo "[ pwd:'${PWD}' ]" +make PROFILE="${UU_MAKE_PROFILE}" +cp "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target # Create *sum binaries -for sum in b2sum b3sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum -do - sum_path="${BUILDDIR}/${sum}" - test -f "${sum_path}" || cp "${BUILDDIR}/hashsum" "${sum_path}" +for sum in b2sum b3sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum; do + sum_path="${UU_BUILD_DIR}/${sum}" + test -f "${sum_path}" || cp "${UU_BUILD_DIR}/hashsum" "${sum_path}" done -test -f "${BUILDDIR}/[" || cp "${BUILDDIR}/test" "${BUILDDIR}/[" -popd -GNULIB_SRCDIR="$PWD/../gnulib" -pushd ../gnu/ +test -f "${UU_BUILD_DIR}/[" || cp "${UU_BUILD_DIR}/test" "${UU_BUILD_DIR}/[" + +## + +cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]" # Any binaries that aren't built become `false` so their tests fail -for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs) -do - bin_path="${BUILDDIR}/${binary}" - test -f "${bin_path}" || { echo "'${binary}' was not built with uutils, using the 'false' program"; cp "${BUILDDIR}/false" "${bin_path}"; } +for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs); do + bin_path="${UU_BUILD_DIR}/${binary}" + test -f "${bin_path}" || { + echo "'${binary}' was not built with uutils, using the 'false' program" + cp "${UU_BUILD_DIR}/false" "${bin_path}" + } done -./bootstrap --gnulib-srcdir="$GNULIB_SRCDIR" +./bootstrap ./configure --quiet --disable-gcc-warnings #Add timeout to to protect against hangs sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils -sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${BUILDDIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile +sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile sed -i 's| tr | /usr/bin/tr |' tests/init.sh make -j "$(nproc)" # Generate the factor tests, so they can be fixed # Used to be 36. Reduced to 20 to decrease the log size -for i in {00..20} -do +for i in {00..20}; do make "tests/factor/t${i}.sh" done # strip the long stuff -for i in {21..36} -do +for i in {21..36}; do sed -i -e "s/\$(tf)\/t${i}.sh//g" Makefile done - grep -rl 'path_prepend_' tests/* | xargs sed -i 's| path_prepend_ ./src||' sed -i -e 's|^seq |/usr/bin/seq |' -e 's|sha1sum |/usr/bin/sha1sum |' tests/factor/t*sh @@ -97,11 +119,9 @@ sed -i 's|seq |/usr/bin/seq |' tests/misc/sort-discrim.sh # Add specific timeout to tests that currently hang to limit time spent waiting sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh - # Remove dup of /usr/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' - #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) # we should not regress our project just to match what GNU is going. @@ -117,7 +137,7 @@ sed -i -e "s|rm: cannot remove 'a/1'|rm: cannot remove 'a'|g" tests/rm/rm2.sh sed -i -e "s|removed directory 'a/'|removed directory 'a'|g" tests/rm/v-slash.sh -test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}" +test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" # When decoding an invalid base32/64 string, gnu writes everything it was able to decode until # it hit the decode error, while we don't write anything if the input is invalid. diff --git a/util/dwr.sh b/util/dwr.sh new file mode 100644 index 000000000..ff1f81170 --- /dev/null +++ b/util/dwr.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# `dwr` - delete workflow runs (by DJ Adams) +# ref: +# ref: [Mass deletion of GitHub Actions workflow runs](https://qmacro.org/autodidactics/2021/03/26/mass-deletion-of-github-actions-workflow-runs) @@ + +# LICENSE: "Feel free to steal, modify, or make fun of" (from ) + +# spell-checker:ignore (options) multi ; (people) DJ Adams * qmacro ; (words) gsub + +# Given an "owner/repo" name, such as "qmacro/thinking-aloud", +# retrieve the workflow runs for that repo and present them in a +# list. Selected runs will be deleted. Uses the GitHub API. + +# Requires gh (GitHub CLI) and jq (JSON processor) + +# First version + +set -o errexit +set -o pipefail + +declare repo=${1:?No owner/repo specified} + +jq_script() { + + cat </dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;; -esac ; +# WSL? +if [ -z "${OSID_tags}" ]; then + if [ -e '/proc/sys/fs/binfmt_misc/WSLInterop' ] && (grep '^enabled$' '/proc/sys/fs/binfmt_misc/WSLInterop' >/dev/null); then + __="wsl" + case ";${OSID_tags};" in ";;") OSID_tags="$__" ;; *";$__;"*) ;; *) OSID_tags="$__;$OSID_tags" ;; esac + unset __ + # Windows version == ... + # Release ID; see [Release ID/Version vs Build](https://winreleaseinfoprod.blob.core.windows.net/winreleaseinfoprod/en-US.html)[`@`](https://archive.is/GOj1g) + OSID_wsl_build="$(uname -r | sed 's/^[0-9.][0-9.]*-\([0-9][0-9]*\)-.*$/\1/g')" + OSID_wsl_revision="$(uname -v | sed 's/^#\([0-9.][0-9.]*\)-.*$/\1/g')" + export OSID_wsl_build OSID_wsl_revision + fi +fi + +case ";${OSID_tags};" in + *";wsl;"*) powershell.exe -c "$(wslpath -w "${COVERAGE_REPORT_DIR}"/index.html)" ;; + *) xdg-open --version >/dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;; +esac diff --git a/util/show-utils.sh b/util/show-utils.sh index f69b42678..0db72e1c4 100755 --- a/util/show-utils.sh +++ b/util/show-utils.sh @@ -17,11 +17,11 @@ project_main_dir="${ME_parent_dir_abs}" # printf 'project_main_dir="%s"\n' "${project_main_dir}" cd "${project_main_dir}" && -# `jq` available? -if ! jq --version 1>/dev/null 2>&1; then - echo "WARN: missing \`jq\` (install with \`sudo apt install jq\`); falling back to default (only fully cross-platform) utility list" 1>&2 - echo "$default_utils" -else - cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")" - # cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")" -fi + # `jq` available? + if ! jq --version 1>/dev/null 2>&1; then + echo "WARN: missing \`jq\` (install with \`sudo apt install jq\`); falling back to default (only fully cross-platform) utility list" 1>&2 + echo "$default_utils" + else + cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")" + # cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")" + fi