mirror of
https://github.com/uutils/diffutils.git
synced 2026-05-08 06:59:57 -04:00
179 lines
5.8 KiB
YAML
179 lines
5.8 KiB
YAML
on: [push, pull_request]
|
|
|
|
name: Basic CI
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
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
|
|
- 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
|
|
- name: install GNU patch on MacOS
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
brew install gpatch
|
|
echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
|
|
- name: set up PATH on Windows
|
|
# Needed to use GNU's patch.exe instead of Strawberry Perl patch
|
|
if: runner.os == 'Windows'
|
|
run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
|
|
- run: cargo test
|
|
|
|
fmt:
|
|
name: cargo fmt --all -- --check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- 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
|
|
- run: cargo clippy -- -D warnings
|
|
|
|
gnu-testsuite:
|
|
permissions:
|
|
contents: write # Publish diffutils instead of discarding
|
|
name: GNU test suite
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- run: |
|
|
cargo build --config=profile.release.strip=true --profile=release #-fast
|
|
zstd -19 target/release/diffutils -o diffutils-x86_64-unknown-linux-gnu.zst
|
|
# 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
|
|
- name: Publish latest commit
|
|
uses: softprops/action-gh-release@v3
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
with:
|
|
tag_name: latest-commit
|
|
draft: false
|
|
prerelease: true
|
|
files: |
|
|
diffutils-x86_64-unknown-linux-gnu.zst
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
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
|
|
env:
|
|
# Use -Z
|
|
RUSTC_BOOTSTRAP: 1
|
|
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; }
|
|
# target-specific options
|
|
# * CODECOV_FLAGS
|
|
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
|
|
outputs CODECOV_FLAGS
|
|
|
|
- name: install GNU patch on MacOS
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
brew install gpatch
|
|
echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
|
|
- name: set up PATH on Windows
|
|
# Needed to use GNU's patch.exe instead of Strawberry Perl patch
|
|
if: runner.os == 'Windows'
|
|
run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
|
|
- name: Test
|
|
run: cargo test --all-features --no-fail-fast
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
RUSTC_WRAPPER: ""
|
|
RUSTFLAGS: "-Cinstrument-coverage -Zcoverage-options=branch -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
|
|
RUSTDOCFLAGS: "-Cpanic=abort"
|
|
LLVM_PROFILE_FILE: "diffutils-%p-%m.profraw"
|
|
# Use -Z
|
|
RUSTC_BOOTSTRAP: 1
|
|
- name: "`grcov` ~ install"
|
|
env:
|
|
# Use -Z
|
|
RUSTC_BOOTSTRAP: 1
|
|
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 --binary-path "${COVERAGE_REPORT_DIR}" | sort --unique
|
|
# generate coverage report
|
|
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --binary-path "${COVERAGE_REPORT_DIR}" --branch
|
|
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
|
|
- name: Upload coverage results (to Codecov.io)
|
|
uses: codecov/codecov-action@v6
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ${{ 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
|
|
|