mirror of
https://github.com/uutils/grep.git
synced 2026-10-16 02:48:22 -07:00
onig_sys builds oniguruma from C sources, so `cargo check --target wasm32-wasip1` fails unless the caller supplies a C WASI sysroot. Add a default-on `oniguruma` feature; `--no-default-features` drops the C dependency and falls back to a literal-only matcher that reports an explicit error for patterns needing a regex engine. Gating on the feature rather than on `target_os = "wasi"` keeps the real engine for WASI builds that do have a sysroot: oniguruma compiles and passes the full BRE/ERE/-P suite on wasm32-wasip2 when CC_wasm32_wasip2 and CFLAGS_wasm32_wasip2 point at a wasi-sdk. CI checks wasm32-wasip1 with --no-default-features and builds and tests the fallback natively.
126 lines
4.0 KiB
YAML
126 lines
4.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build & test (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ ubuntu-latest, macOS-latest, windows-latest ]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
|
|
- name: Run tests
|
|
run: cargo test --verbose
|
|
|
|
wasm:
|
|
name: Check wasm32-wasip1 (no oniguruma)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: wasm32-wasip1
|
|
|
|
# Without a C sysroot, oniguruma cannot be built for this target, so the
|
|
# crate is checked with the literal-only matcher. A WASI build that does
|
|
# have a wasi-sdk sysroot can keep the default features instead.
|
|
- name: Check
|
|
run: cargo check --target wasm32-wasip1 --no-default-features
|
|
|
|
no-oniguruma:
|
|
name: Build & test without oniguruma
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build
|
|
run: cargo build --no-default-features --verbose
|
|
|
|
# Most of the suite exercises real regexes, which this configuration
|
|
# cannot serve; only the tests covering the fallback itself are run.
|
|
- name: Run fallback tests
|
|
run: cargo test --no-default-features --verbose literal_only_build
|
|
|
|
coverage:
|
|
name: Code coverage (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ ubuntu-latest, macOS-latest, windows-latest ]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- 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; }
|
|
# CODECOV_FLAGS
|
|
CODECOV_FLAGS=$( echo "${{ matrix.os }}" | sed 's/[^[:alnum:]]/_/g' )
|
|
outputs CODECOV_FLAGS
|
|
|
|
- name: Install Rust (nightly)
|
|
uses: dtolnay/rust-toolchain@nightly
|
|
- run: rustup component add llvm-tools-preview
|
|
|
|
- name: Test
|
|
run: cargo test --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: "${{ github.workspace }}/grep-%p-%m.profraw"
|
|
|
|
- name: Install grcov
|
|
shell: bash
|
|
run: |
|
|
git clone https://github.com/mozilla/grcov.git ~/grcov/
|
|
cd ~/grcov
|
|
cargo install --path .
|
|
|
|
- name: Generate coverage data (via grcov)
|
|
id: coverage
|
|
shell: bash
|
|
run: |
|
|
set -v
|
|
## 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}" --source-dir . --keep-only "src/*" | sort --unique
|
|
# generate coverage report
|
|
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --binary-path "${COVERAGE_REPORT_DIR}" --source-dir . --keep-only "src/*" --branch
|
|
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Upload coverage results (to Codecov.io)
|
|
uses: codecov/codecov-action@v7
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ${{ steps.coverage.outputs.report }}
|
|
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|