Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ jobs:
usesh: true
sync: rsync
copyback: false
# We need jq and GNU coreutils to run show-utils.sh and bash to use inline shell string replacement
prepare: pkg install -y rust sudo jaq coreutils bash python3
# We need jq-compat util and bash to use inline shell string replacement
prepare: pkg install -y rust sudo jaq bash python3
run: |
## Prepare, build, and test
sudo ln -s $(command -v jaq) /usr/local/bin/jq
# implementation modelled after ref: <https://github.com/rust-lang/rustup/pull/2783>
# * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host
set -e
Expand Down Expand Up @@ -134,7 +133,6 @@ jobs:
prepare: pkg install -y gmake nextest rust sudo jaq
run: |
## Prepare, build, and test
sudo ln -s $(command -v jaq) /usr/local/bin/jq
# implementation modelled after ref: <https://github.com/rust-lang/rustup/pull/2783>
# * NOTE: All steps need to be run in this block, otherwise, we are operating back on the mac host
set -e
Expand Down Expand Up @@ -185,7 +183,7 @@ jobs:
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --features '${{ matrix.job.features }}' || FAULT=1 ; fi
# There is no systemd-logind on FreeBSD, so test all features except feat_systemd_logind ( https://github.com/rust-lang/cargo/issues/3126#issuecomment-2523441905 )
if (test -z "\$FAULT"); then
UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -)
UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jaq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -)
cargo nextest run --hide-progress-bar --profile ci --features "\$UUCORE_FEATURES" -p uucore || FAULT=1
fi
# Test building with make
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/openbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ jobs:
sync: rsync
copyback: false
mem: 4096
# We need jq and GNU coreutils to run show-utils.sh and bash to use inline shell string replacement
# We need jq and bash to use inline shell string replacement
# Use sudo-- to get the default sudo package without ambiguity
# Install rust and cargo from OpenBSD packages
prepare: |
# Clean up disk space before installing packages
df -h
pkg_add curl sudo-- jq coreutils bash rust rust-clippy rust-rustfmt python3
pkg_add curl sudo-- jq bash rust rust-clippy rust-rustfmt python3
rm -rf /usr/share/relink/* /usr/X11R6/* /usr/share/doc/* /usr/share/man/* &
# Clean up package cache after installation
pkg_delete -a &
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ jobs:
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
CARGO_TARGET_WASM32_WASIP2_RUNNER: wasmtime
run: |
# Get all utilities and exclude ones that don't compile for ${{ matrix.job.target }}
EXCLUDE="df|du|env|more"
UTILS=$(./util/show-utils.sh | tr ' ' '\n' | grep -vE "^($EXCLUDE)$" | sed 's/^/-p uu_/' | tr '\n' ' ')
UTILS=$(./util/show-utils.sh --features=feat_wasm | sed 's/^/-p uu_/' | tr '\n' ' ')
cargo test --target ${{ matrix.job.target }} --no-default-features $UTILS
- name: Run integration tests via wasmtime
if: matrix.job.target == 'wasm32-wasip1'
Expand Down
26 changes: 12 additions & 14 deletions util/show-utils.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/usr/bin/env bash

set -eo pipefail
# spell-checker:ignore (jq) deps startswith

cd -- "$(dirname -- "$0")/.."

# `jq` available?
if ! jq --version 1>/dev/null 2>&1; then
# refs: <https://forge.rust-lang.org/release/platform-support.html> , <https://docs.rs/platforms/0.2.1/platforms/platform/tier1/index.html>
# default utility list
default_utils=$(cargo tree --depth 1 --features feat_common_core --format "{lib}" --prefix none | sed -n 's/^uu_//p')
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"
if test "$*";then
_args=("$@")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, in POSIX sh, arrays are undefined (see SC3030), although this script already requires Bash, so this doesn't introduce an additional portability concern.

else
# Find 'coreutils' id with regex
# with cargo v1.76.0, id = "coreutils 0.0.26 (path+file://<coreutils local directory>)"
# with cargo >= v1.77.0
# - if local path != '<...>/coreutils' id = "path+file://<coreutils local directory>#coreutils@0.0.26"
# - if local path == '<...>/coreutils' id = "path+file://<parent directory>/coreutils#0.0.26"
cargo metadata "$@" --format-version 1 | jq -r '[.resolve.nodes[] | select(.id|match(".*coreutils[ |@|#]\\d+\\.\\d+\\.\\d+")) | .deps[] | select(.pkg|match("uu_")) | .name | sub("^uu_"; "")] | sort | join(" ")'
export CARGO_BUILD_TARGET="${CARGO_BUILD_TARGET:-$(rustc --print host-tuple)}"
case "$CARGO_BUILD_TARGET" in
*windows*) _args=("--features=windows");;
*wasip*) _args=("--features=feat_wasm");;
# unix is default since we don't support too many non-unix
*) _args=("--features=unix");;
esac
fi
# refs: <https://forge.rust-lang.org/release/platform-support.html> , <https://docs.rs/platforms/0.2.1/platforms/platform/tier1/index.html>
# default utility list
cargo tree --depth 1 --format "{lib}" "${_args[@]}" --prefix none | sed -n 's/^uu_//p'
Loading