on: [push, pull_request] name: Basic CI env: CARGO_TERM_COLOR: always jobs: check: name: cargo check runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo check test: name: cargo test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo test fmt: name: cargo fmt --all -- --check runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: rustup component add rustfmt - run: cargo fmt --all -- --check clippy: name: cargo clippy -- -D warnings runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: rustup component add clippy - run: cargo clippy -- -D warnings gnu-testsuite: name: GNU test suite runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo build --release # do not fail, the report is merely informative (at least until all tests pass reliably) - run: ./tests/run-upstream-testsuite.sh release || true env: TERM: xterm - uses: actions/upload-artifact@v4 with: name: test-results.json path: tests/test-results.json - run: ./tests/print-test-results.sh tests/test-results.json build: name: build ${{ matrix.binary || 'findutils' }} ${{ matrix.target }} runs-on: ${{ matrix.os }} container: ${{ fromJson(matrix.container || '{"image":null}') }} timeout-minutes: 30 strategy: fail-fast: false matrix: include: - os: ubuntu-20.04 target: x86_64-unknown-linux-musl - os: ubuntu-20.04 target: aarch64-unknown-linux-musl - os: ubuntu-20.04 target: armv7-unknown-linux-musleabi container: '{"image": "messense/rust-musl-cross:armv7-musleabi"}' - os: ubuntu-20.04 target: i686-unknown-linux-musl container: '{"image": "messense/rust-musl-cross:i686-musl"}' - os: macOS-11 target: x86_64-apple-darwin macosx_deployment_target: 10.13 developer_dir: /Applications/Xcode_11.7.app sdkroot: /Applications/Xcode_11.7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk - os: macos-14 target: aarch64-apple-darwin macosx_deployment_target: 11.0 - os: windows-2019 target: x86_64-pc-windows-msvc rustflags: -Ctarget-feature=+crt-static steps: - name: Clone repository uses: actions/checkout@v4 - name: Install rust uses: ./.github/actions/rust-toolchain with: toolchain: ${{ matrix.target == 'aarch64-apple-darwin' && 'beta' || 'stable' }} target: ${{ matrix.target }} if: ${{ !matrix.container }} - name: Install musl-tools (x86_64) run: sudo apt-get install musl-tools if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} - name: Install musl-tools (arm64) run: | set -x sed 's/mirror+file:\/etc\/apt\/apt-mirrors\.txt/[arch=arm64] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list sudo dpkg --add-architecture arm64 sudo apt-get update || true sudo apt-get install musl-dev:arm64 binutils-multiarch gcc-10-aarch64-linux-gnu libc6-dev-arm64-cross apt-get download musl-tools:arm64 sudo dpkg-deb -x musl-tools_*_arm64.deb / sed 2iREALGCC=aarch64-linux-gnu-gcc-10 /usr/bin/musl-gcc | sudo tee /usr/bin/aarch64-linux-musl-gcc > /dev/null sudo chmod +x /usr/bin/aarch64-linux-musl-gcc if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} - name: Build run: cargo build --locked --release --bin ${{ matrix.binary || 'findutils' }} --target ${{ matrix.target }} --features=openssl/vendored ${{ matrix.extra_args }} env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} DEVELOPER_DIR: ${{ matrix.developer_dir }} SDKROOT: ${{ matrix.sdkroot }} RUSTFLAGS: ${{ matrix.rustflags }} # Workaround for the lack of substring() function in github actions expressions. - name: Id id: id shell: bash run: echo "id=${ID#refs/tags/}" >> $GITHUB_OUTPUT env: ID: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.sha }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.binary || 'findutils' }}-${{ steps.id.outputs.id }}-${{ matrix.target }} path: target/${{ matrix.target }}/release/${{ matrix.binary || 'findutils' }}${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }} if-no-files-found: error coverage: name: Code Coverage runs-on: ${{ matrix.job.os }} strategy: fail-fast: false matrix: job: - { os: ubuntu-latest , features: unix } - { os: macos-latest , features: macos } - { os: windows-latest , features: windows } steps: - uses: actions/checkout@v4 - name: Initialize workflow variables id: vars shell: bash run: | ## VARs setup outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } # toolchain TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac; # * use requested TOOLCHAIN if specified if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi outputs TOOLCHAIN # target-specific options # * CARGO_FEATURES_OPTION CARGO_FEATURES_OPTION='--all -- --check' ; ## default to '--all-features' for code coverage # * CODECOV_FLAGS CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' ) outputs CODECOV_FLAGS - name: rust toolchain ~ install uses: dtolnay/rust-toolchain@nightly - name: Test run: cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-fail-fast env: CARGO_INCREMENTAL: "0" RUSTC_WRAPPER: "" RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort" - name: "`grcov` ~ install" id: build_grcov shell: bash run: | git clone https://github.com/mozilla/grcov.git ~/grcov/ cd ~/grcov # Hardcode the version of crossbeam-epoch. See # https://github.com/uutils/coreutils/issues/3680 sed -i -e "s|tempfile =|crossbeam-epoch = \"=0.9.8\"\ntempfile =|" Cargo.toml cargo install --path . cd - # Uncomment when the upstream issue # https://github.com/mozilla/grcov/issues/849 is fixed # uses: actions-rs/install@v0.1 # with: # crate: grcov # version: latest # use-tool-cache: false - name: Generate coverage data (via `grcov`) id: coverage shell: bash run: | ## Generate coverage data COVERAGE_REPORT_DIR="target/debug" COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info" mkdir -p "${COVERAGE_REPORT_DIR}" # display coverage files 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 # generate coverage report 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\()" echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) uses: codecov/codecov-action@v3 # if: steps.vars.outputs.HAS_CODECOV_TOKEN with: # token: ${{ secrets.CODECOV_TOKEN }} file: ${{ steps.coverage.outputs.report }} ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }} flags: ${{ steps.vars.outputs.CODECOV_FLAGS }} name: codecov-umbrella fail_ci_if_error: false release: name: release runs-on: ubuntu-latest needs: [build, clippy, check, test] if: ${{ startsWith(github.ref, 'refs/tags/') }} steps: - name: Clone repository uses: actions/checkout@v4 - name: Check versions run: | tag_name=${GITHUB_REF#refs/tags/} v=$(grep -m 1 "^version" Cargo.toml|sed -e "s|version = \"\(.*\)\"|\1|") if ! echo $tag_name|grep -q $v; then echo "Mistmatch of the version:" echo "Cargo.toml says $v while the tag is $tag_name" exit 2 fi - name: Get artifacts uses: actions/download-artifact@v4 - name: Create release assets run: | for d in findutils-*; do chmod +x "$d/findutils"* cp README.md LICENSE "$d/" tar -zcvf "$d.tar.gz" "$d" echo -n "$(shasum -ba 256 "$d.tar.gz" | cut -d " " -f 1)" > "$d.tar.gz.sha256" if [[ $d =~ (findutils-)(.*)?(x86_64-pc-windows)(.*)? ]]; then zip -r "$d.zip" "$d" echo -n "$(shasum -ba 256 "$d.zip" | cut -d " " -f 1)" > "$d.zip.sha256" fi done - name: Create release run: | sudo apt-get update && sudo apt-get install -y hub tag_name=${GITHUB_REF#refs/tags/} for f in findutils-*.tar.gz* findutils-*.zip*; do if [[ -f "$f" ]]; then files="$files -a $f"; fi done hub release create -m $tag_name $tag_name $files env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}