2023-03-25 09:00:52 +00:00
|
|
|
name: FreeBSD
|
|
|
|
|
2023-04-14 17:19:57 +00:00
|
|
|
# spell-checker:ignore sshfs usesh vmactions taiki Swatinem esac fdescfs fdesc
|
2023-03-28 03:13:21 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
# * style job configuration
|
|
|
|
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
|
|
|
|
|
2023-12-01 10:52:23 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-03-25 09:00:52 +00:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
|
|
|
# End the current execution if there is a new changeset in the PR.
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
|
|
|
|
jobs:
|
2023-03-28 03:13:21 +00:00
|
|
|
style:
|
|
|
|
name: Style and Lint
|
|
|
|
runs-on: ${{ matrix.job.os }}
|
|
|
|
timeout-minutes: 90
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
job:
|
2024-09-06 14:10:11 +00:00
|
|
|
- { os: ubuntu-24.04 , features: unix }
|
2023-03-28 03:13:21 +00:00
|
|
|
env:
|
|
|
|
SCCACHE_GHA_ENABLED: "true"
|
|
|
|
RUSTC_WRAPPER: "sccache"
|
|
|
|
steps:
|
2023-09-04 15:42:41 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-28 03:13:21 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Run sccache-cache
|
2024-06-17 12:16:12 +00:00
|
|
|
uses: mozilla-actions/sccache-action@v0.0.5
|
2023-03-28 03:13:21 +00:00
|
|
|
- name: Prepare, build and test
|
2024-09-21 11:37:50 +00:00
|
|
|
uses: vmactions/freebsd-vm@v1.1.3
|
2023-03-28 03:13:21 +00:00
|
|
|
with:
|
|
|
|
usesh: true
|
2023-11-30 16:59:48 +00:00
|
|
|
sync: rsync
|
|
|
|
copyback: false
|
2024-01-02 18:28:28 +00:00
|
|
|
# We need jq and GNU coreutils to run show-utils.sh and bash to use inline shell string replacement
|
|
|
|
prepare: pkg install -y curl sudo jq coreutils bash
|
2023-03-28 03:13:21 +00:00
|
|
|
run: |
|
|
|
|
## Prepare, build, and test
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
TEST_USER=tester
|
|
|
|
REPO_NAME=${GITHUB_WORKSPACE##*/}
|
2023-11-30 16:59:48 +00:00
|
|
|
WORKSPACE_PARENT="/home/runner/work/${REPO_NAME}"
|
2023-03-28 03:13:21 +00:00
|
|
|
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
|
|
|
|
#
|
|
|
|
pw adduser -n ${TEST_USER} -d /root/ -g wheel -c "Coreutils user to build" -w random
|
2023-11-30 16:59:48 +00:00
|
|
|
chown -R ${TEST_USER}:wheel /root/ "${WORKSPACE_PARENT}"/
|
2023-03-28 03:13:21 +00:00
|
|
|
whoami
|
|
|
|
#
|
|
|
|
# Further work needs to be done in a sudo as we are changing users
|
|
|
|
sudo -i -u ${TEST_USER} bash << EOF
|
|
|
|
set -e
|
|
|
|
whoami
|
|
|
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
|
|
sh rustup.sh -y -c rustfmt,clippy --profile=minimal -t stable
|
|
|
|
. ${HOME}/.cargo/env
|
|
|
|
## VARs setup
|
|
|
|
cd "${WORKSPACE}"
|
|
|
|
unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
|
|
|
|
''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
|
|
|
|
*) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
|
|
|
|
esac;
|
|
|
|
FAULT_PREFIX=\$(echo "\${FAULT_TYPE}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
# * determine sub-crate utility list
|
|
|
|
UTILITY_LIST="\$(./util/show-utils.sh --features ${{ matrix.job.features }})"
|
|
|
|
CARGO_UTILITY_LIST_OPTIONS="\$(for u in \${UTILITY_LIST}; do echo -n "-puu_\${u} "; done;)"
|
|
|
|
## Info
|
|
|
|
# environment
|
|
|
|
echo "## environment"
|
|
|
|
echo "CI='${CI}'"
|
|
|
|
echo "REPO_NAME='${REPO_NAME}'"
|
|
|
|
echo "TEST_USER='${TEST_USER}'"
|
|
|
|
echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'"
|
|
|
|
echo "WORKSPACE='${WORKSPACE}'"
|
|
|
|
echo "FAULT_PREFIX='\${FAULT_PREFIX}'"
|
|
|
|
echo "UTILITY_LIST='\${UTILITY_LIST}'"
|
|
|
|
env | sort
|
|
|
|
# tooling info
|
|
|
|
echo "## tooling info"
|
|
|
|
cargo -V
|
|
|
|
rustc -V
|
|
|
|
#
|
|
|
|
# To ensure that files are cleaned up, we don't want to exit on error
|
|
|
|
set +e
|
|
|
|
unset FAULT
|
|
|
|
## cargo fmt testing
|
|
|
|
echo "## cargo fmt testing"
|
|
|
|
# * convert any errors/warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
|
|
|
S=\$(cargo fmt -- --check) && printf "%s\n" "\$S" || { printf "%s\n" "\$S" ; printf "%s\n" "\$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+\${PWD//\//\\\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*\$/::\${FAULT_TYPE} file=\1,line=\2::\${FAULT_PREFIX}: \\\`cargo fmt\\\`: style violation (file:'\1', line:\2; use \\\`cargo fmt -- \"\1\"\\\`)/p" ; FAULT=true ; }
|
|
|
|
## cargo clippy lint testing
|
|
|
|
if [ -z "\${FAULT}" ]; then
|
|
|
|
echo "## cargo clippy lint testing"
|
|
|
|
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
|
|
|
S=\$(cargo clippy --all-targets \${CARGO_UTILITY_LIST_OPTIONS} -- -W clippy::manual_string_new -D warnings 2>&1) && printf "%s\n" "\$S" || { printf "%s\n" "\$S" ; printf "%s" "\$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*\$/::\${FAULT_TYPE} file=\2,line=\3,col=\4::\${FAULT_PREFIX}: \\\`cargo clippy\\\`: \1 (file:'\2', line:\3)/p;" -e '}' ; FAULT=true ; }
|
|
|
|
fi
|
|
|
|
# Clean to avoid to rsync back the files
|
|
|
|
cargo clean
|
|
|
|
if [ -n "\${FAIL_ON_FAULT}" ] && [ -n "\${FAULT}" ]; then exit 1 ; fi
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test:
|
|
|
|
name: Tests
|
2023-03-25 09:00:52 +00:00
|
|
|
runs-on: ${{ matrix.job.os }}
|
|
|
|
timeout-minutes: 90
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
job:
|
2024-09-06 14:10:11 +00:00
|
|
|
- { os: ubuntu-24.04 , features: unix }
|
2023-03-25 09:00:52 +00:00
|
|
|
env:
|
|
|
|
mem: 4096
|
|
|
|
SCCACHE_GHA_ENABLED: "true"
|
|
|
|
RUSTC_WRAPPER: "sccache"
|
|
|
|
steps:
|
2023-09-04 15:42:41 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-25 09:00:52 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Run sccache-cache
|
2024-06-17 12:16:12 +00:00
|
|
|
uses: mozilla-actions/sccache-action@v0.0.5
|
2023-03-25 09:00:52 +00:00
|
|
|
- name: Prepare, build and test
|
2024-09-21 11:37:50 +00:00
|
|
|
uses: vmactions/freebsd-vm@v1.1.3
|
2023-03-25 09:00:52 +00:00
|
|
|
with:
|
|
|
|
usesh: true
|
2023-11-30 16:59:48 +00:00
|
|
|
sync: rsync
|
|
|
|
copyback: false
|
2023-03-25 09:00:52 +00:00
|
|
|
prepare: pkg install -y curl gmake sudo
|
|
|
|
run: |
|
|
|
|
## Prepare, build, and test
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# We need a file-descriptor file system to test test_ls::test_ls_io_errors
|
|
|
|
mount -t fdescfs fdesc /dev/fd
|
|
|
|
#
|
|
|
|
TEST_USER=tester
|
|
|
|
REPO_NAME=${GITHUB_WORKSPACE##*/}
|
2023-11-30 16:59:48 +00:00
|
|
|
WORKSPACE_PARENT="/home/runner/work/${REPO_NAME}"
|
2023-03-25 09:00:52 +00:00
|
|
|
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
|
|
|
|
#
|
|
|
|
pw adduser -n ${TEST_USER} -d /root/ -g wheel -c "Coreutils user to build" -w random
|
|
|
|
# chown -R ${TEST_USER}:wheel /root/ "${WORKSPACE_PARENT}"/
|
2023-11-30 16:59:48 +00:00
|
|
|
chown -R ${TEST_USER}:wheel /root/ "${WORKSPACE_PARENT}"/
|
2023-03-25 09:00:52 +00:00
|
|
|
whoami
|
|
|
|
#
|
|
|
|
# Further work needs to be done in a sudo as we are changing users
|
|
|
|
sudo -i -u ${TEST_USER} sh << EOF
|
|
|
|
set -e
|
|
|
|
whoami
|
|
|
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
|
|
sh rustup.sh -y --profile=minimal
|
|
|
|
. $HOME/.cargo/env
|
2023-04-14 17:19:57 +00:00
|
|
|
# Install nextest
|
|
|
|
mkdir -p ~/.cargo/bin
|
|
|
|
curl -LsSf https://get.nexte.st/latest/freebsd | tar zxf - -C ~/.cargo/bin
|
2023-03-25 09:00:52 +00:00
|
|
|
## Info
|
|
|
|
# environment
|
|
|
|
echo "## environment"
|
|
|
|
echo "CI='${CI}'"
|
|
|
|
echo "REPO_NAME='${REPO_NAME}'"
|
|
|
|
echo "TEST_USER='${TEST_USER}'"
|
|
|
|
echo "WORKSPACE_PARENT='${WORKSPACE_PARENT}'"
|
|
|
|
echo "WORKSPACE='${WORKSPACE}'"
|
|
|
|
env | sort
|
|
|
|
# tooling info
|
|
|
|
echo "## tooling info"
|
|
|
|
cargo -V
|
2023-04-14 17:19:57 +00:00
|
|
|
cargo nextest --version
|
2023-03-25 09:00:52 +00:00
|
|
|
rustc -V
|
|
|
|
#
|
|
|
|
# To ensure that files are cleaned up, we don't want to exit on error
|
|
|
|
set +e
|
|
|
|
cd "${WORKSPACE}"
|
|
|
|
unset FAULT
|
|
|
|
cargo build || FAULT=1
|
2023-04-14 17:19:57 +00:00
|
|
|
export PATH=~/.cargo/bin:${PATH}
|
2023-03-25 09:00:52 +00:00
|
|
|
export RUST_BACKTRACE=1
|
2023-04-14 17:19:57 +00:00
|
|
|
export CARGO_TERM_COLOR=always
|
|
|
|
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --features '${{ matrix.job.features }}' || FAULT=1 ; fi
|
|
|
|
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --all-features -p uucore || FAULT=1 ; fi
|
2023-03-25 09:00:52 +00:00
|
|
|
# Clean to avoid to rsync back the files
|
|
|
|
cargo clean
|
|
|
|
if (test -n "\$FAULT"); then exit 1 ; fi
|
|
|
|
EOF
|