rust.yml test on Windows, Mac OS #800
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rust.yml | |
# | |
# github workflows action file for super-speedy-syslog-searcher | |
# | |
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json | |
--- | |
name: Rust | |
on: | |
push: | |
paths: | |
- .github/** | |
- Cargo.toml | |
- src/**.rs | |
pull_request: | |
paths: | |
- .github/** | |
- Cargo.toml | |
- src/**.rs | |
- benches/** | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
# default rust version | |
# should match first value in matrix.msrv | |
MSRV_UPLOAD: "1.66.0" | |
# rust version for grcov job | |
# should be equal or greater than $MSRV_UPLOAD | |
VERSION_GRCOV: "1.67.0" | |
# rust version for llvm_cov job | |
# should be equal or greater than $MSRV_UPLOAD | |
VERSION_LLVM_COV: "1.70.0" | |
# run options for debug | |
S4_ARGSD: --blocksz 0x2 -s | |
# run options for release | |
S4_ARGSR: --blocksz 0x40 -s | |
# run files | |
S4_TEST_FILES: ./logs/other/tests/dtf2-2.log | |
./logs/other/tests/dtf3-2a.log | |
./logs/other/tests/dtf5-6a.log.gz | |
./logs/other/tests/dtf7-20-LEVELS.log.xz | |
./logs/other/tests/gen-2-1.tar | |
./logs/other/tests/gen-20-1-faces.log | |
./logs/other/tests/gen-20-1-⚀⚁⚂⚃⚄⚅.log | |
./logs/other/tests/gen-20-2-2-faces.log | |
./logs/programs/utmp/host-entry6.wtmp | |
./logs/programs/journal/RHE_91_system.journal | |
jobs: | |
job_rust_msrv_os: | |
# this job downloads and builds dependency crates | |
name: build ${{ matrix.msrv }} on ${{ matrix.os }} | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
# first `msrv` should match Cargo.toml:[package]:rust-version | |
# add a few more for sanity checks (you might be surprised) | |
# concise listing at https://releases.rs/ | |
msrv: ["1.66.0", "1.68.0", "1.70.0", "1.72.0"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Issue #62: `git config` to workaround `git checkout` error on Windows | |
- run: | | |
git config --global core.protectNTFS false | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
name: toolchain ${{ matrix.msrv }} minimal | |
with: | |
profile: minimal | |
toolchain: ${{ matrix.msrv }} | |
- name: Build using rust ${{ matrix.msrv }} on ${{ matrix.os }} | |
shell: bash | |
run: | | |
set -eux | |
rustc --print cfg | |
cargo --version | |
cargo build --verbose | |
cargo build --release | |
./target/release/s4 --help | |
- name: Upload release binary ${{ matrix.msrv }} for ${{ matrix.os }} | |
if: ${{ matrix.os == 'windows-latest' && matrix.msrv == env.MSRV_UPLOAD }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4.exe ${{ matrix.msrv }} ${{ matrix.os }} | |
path: ./target/release/s4.exe | |
- name: Upload release binary ${{ matrix.msrv }} for ${{ matrix.os }} | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.msrv == env.MSRV_UPLOAD }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4 ${{ matrix.msrv }} ${{ matrix.os }} | |
path: ./target/release/s4 | |
- name: Upload release binary ${{ matrix.msrv }} for ${{ matrix.os }} | |
if: ${{ matrix.os == 'macos-latest' && matrix.msrv == env.MSRV_UPLOAD }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4 ${{ matrix.msrv }} ${{ matrix.os }} | |
path: ./target/release/s4 | |
job_rust_release_channel: | |
# this job downloads and builds dependency crates | |
name: build release channel ${{ matrix.rust_version }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
rust_version: ["stable", "beta"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
name: toolchain ${{ matrix.rust_version }} minimal | |
with: | |
profile: minimal | |
toolchain: ${{ matrix.rust_version }} | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build using rust ${{ matrix.rust_version }} | |
run: | | |
set -eux | |
cargo --version | |
cargo build | |
cargo build --release | |
./target/release/s4 --help | |
job_build_debug_release: | |
# this job downloads and builds dependency crates | |
name: build debug and release, upload | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
# build & upload debug | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
name: toolchain ${{ env.MSRV_UPLOAD }} minimal | |
with: | |
profile: minimal | |
toolchain: ${{ env.MSRV_UPLOAD }} | |
- name: Build Debug | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
cargo build --verbose | |
cp -av ./target/debug/s4 ./s4_debug | |
- name: Upload debug binary for test | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4_debug | |
path: ./s4_debug | |
# build & upload release | |
- name: Build Release | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
cargo build --release --verbose | |
cp -av ./target/release/s4 ./s4_release | |
- name: Upload release binary for test | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4_release | |
path: ./s4_release | |
- name: Upload release binary (Ubuntu Linux) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: s4 | |
path: ./target/release/s4 | |
# - name: Run valgrind | |
# run: | | |
# set -eux | |
# sudo apt install -y valgrind g++ | |
# SCRIPT=./tools/valgrind-dhat.sh | |
# chmod -v +x -- "${PROGRAM}" "${SCRIPT}" | |
# "${SCRIPT}" | |
job_check: | |
# this job downloads and builds dependency crates | |
name: check | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Check | |
shell: bash | |
# `cargo check` builds dependences and other things but skips | |
# final code generation | |
run: | | |
set -eux | |
cargo --version | |
cargo check --all-targets | |
cargo check --all-targets --release | |
job_clippy: | |
# this job downloads and builds dependency crates | |
name: clippy | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Clippy | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
cargo clippy --version | |
cargo clippy --no-deps --verbose --all-targets --all-features | |
job_bench: | |
# this job downloads and builds dependency crates | |
name: bench | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Bench Dry Run | |
shell: bash | |
run: | | |
set -eux | |
cargo --version | |
cargo bench --no-run | |
job_test_linux: | |
# this job downloads and builds dependency crates | |
name: test linux | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Install libsystemd | |
shell: bash | |
run: | | |
set -eux | |
sudo apt update || true | |
(find / -xdev \ | |
\( -type f -o -type l \) \ | |
-name 'libsystemd*' 2>/dev/null || true) \ | |
| sort | |
sudo apt install --yes libsystemd0 | |
(find / -xdev \ | |
\( -type f -o -type l \) \ | |
-name 'libsystemd*' 2>/dev/null || true) \ | |
| sort | |
- name: test (limited) | |
# sanity check tests requiring libsystemd can run | |
shell: bash | |
run: | | |
set -eux | |
# can libsystemd be found? | |
(find / -xdev \ | |
\( -type f -o -type l \) \ | |
-name 'libsystemd*' 2>/dev/null || true) \ | |
| sort | |
# run tests that use libsystemd | |
cargo test journalreader_tests | |
- name: install cargo-binstall | |
uses: cargo-bins/cargo-binstall@main | |
- name: install nextest binary | |
run: cargo binstall -y --force cargo-nextest | |
- name: nextest (all) | |
shell: bash | |
run: | | |
set -eux | |
cargo nextest --version | |
export NEXTEST_TEST_THREADS="num-cpus" | |
cargo nextest run --bin s4 --lib --no-fail-fast --final-status-level=fail | |
job_test_macos: | |
name: test Mac OS | |
# TODO: uncomment `needs` | |
#needs: [job_rust_release_channel, job_rust_msrv_os] | |
strategy: | |
matrix: | |
os: [macos-latest, macos-11] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: install cargo-binstall | |
uses: cargo-bins/cargo-binstall@main | |
- name: install nextest binary | |
run: cargo binstall -y --force cargo-nextest | |
- name: create log.tgz | |
shell: bash | |
run: | | |
set -eux | |
uname -a | |
sudo -- tar -zcvf /tmp/log.tgz /var/log/ | |
- name: upload log.tgz | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }} log.tgz | |
path: /tmp/log.tgz | |
- name: nextest (all) | |
shell: bash | |
# TODO: add back --fail-fast | |
run: | | |
set -eux | |
cargo nextest --version | |
export NEXTEST_TEST_THREADS="num-cpus" | |
cargo nextest run --bin s4 --lib --no-fail-fast --final-status-level=fail | |
job_test_windows: | |
name: test Windows | |
# TODO: uncomment `needs` | |
#needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: windows-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: install cargo-binstall | |
uses: cargo-bins/cargo-binstall@main | |
- name: install nextest binary | |
run: cargo binstall -y --force cargo-nextest | |
- name: nextest (all) | |
shell: powershell | |
# TODO: add back --fail-fast | |
run: | | |
cargo.exe nextest --version | |
${env:NEXTEST_TEST_THREADS}="num-cpus" | |
cargo.exe nextest run --bin s4 --lib --no-fail-fast --final-status-level=fail | |
job_doc_publish: | |
# this job downloads and builds dependency crates | |
name: doc, publish | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Build Documentation | |
run: cargo doc --locked --release --no-deps -v | |
- name: Publish Dry Run | |
run: cargo publish --verbose --dry-run --allow-dirty | |
job_yamllint: | |
# this job installs Python PIP packages | |
name: yamllint | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Use Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
set -eux | |
python --version | |
python -m pip \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
--version | |
python -m pip install \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
--no-color \ | |
yamllint | |
python -m pip list \ | |
--disable-pip-version-check \ | |
--no-python-version-warning \ | |
-v -v | |
- name: Run yamllint.sh | |
run: PYTHON=python ./tools/yamllint.sh --format github | |
job_codecov_validate: | |
name: codecov validate | |
needs: [job_rust_release_channel, job_rust_msrv_os] | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Run codecov-validate.sh | |
run: ./tools/codecov-validate.sh -v | |
job_runs: | |
# all of these steps need the s4 binary and the git-committed logs | |
# with modified filesystem datetime | |
name: run s4 | |
needs: job_build_debug_release | |
runs-on: ubuntu-latest | |
steps: | |
# checkout for the log files | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: set log file filesystem Modified Time | |
shell: bash | |
run: | | |
set -eux | |
chmod -v +x ./tools/log-files-time-update.sh | |
./tools/log-files-time-update.sh | |
- name: Install libsystemd | |
shell: bash | |
run: | | |
set -eux | |
sudo apt update || true | |
sudo apt install --yes libsystemd0 | |
# download & run debug | |
- name: Download debug binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: s4_debug | |
- name: Run Program Debug | |
shell: bash | |
run: | | |
set -eux | |
(find / -xdev \ | |
\( -type f -o -type l \) \ | |
-name 'libsystemd*' 2>/dev/null || true) \ | |
| sort | |
S4=./s4_debug | |
chmod -v +x -- ${S4} | |
${S4} --version | |
${S4} --help | |
${S4} --color=never ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=never ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=never -l -n -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=never -l -p -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=never -u -n -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=never -u -p -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=always -l -n -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=always -l -p -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=always -u -n -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} ${S4_ARGSD} --color=always -u -p -w ${S4_TEST_FILES} 2>/dev/null | |
${S4} -s --color=never -l -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -l -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -u -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -u -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -l -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -l -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -u -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -u -p -w ${S4_TEST_FILES} &>/dev/null | |
# download & run release | |
- name: Download release binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: s4_release | |
- name: Run Program Release | |
shell: bash | |
run: | | |
set -eux | |
S4=./s4_release | |
chmod -v +x -- ${S4} | |
${S4} --version | |
${S4} --help | |
${S4} --color=never ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=never ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=never -l -n -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=never -l -p -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=never -u -n -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=never -u -p -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=always -l -n -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=always -l -p -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=always -u -n -w ${S4_TEST_FILES} | |
${S4} ${S4_ARGSR} --color=always -u -p -w ${S4_TEST_FILES} | |
${S4} -s --color=never ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -l -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -l -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -u -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=never -u -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -l -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -l -p -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -u -n -w ${S4_TEST_FILES} &>/dev/null | |
${S4} -s --color=always -u -p -w ${S4_TEST_FILES} &>/dev/null | |
- name: Run Script compare-debug-release.sh | |
shell: bash | |
# TODO: run compare-debug-release.sh instead of this manual thing | |
run: | | |
set -eu | |
export PROGRAMR=./s4_release | |
export PROGRAMD=./s4_debug | |
SCRIPT=./tools/compare-debug-release.sh | |
chmod -v +x -- "${PROGRAMR}" "${PROGRAMD}" | |
"${SCRIPT}" | |
- name: Run Script compare-grep-sort.sh | |
shell: bash | |
run: | | |
set -eux | |
export PROGRAM=./s4_release | |
SCRIPT=./tools/compare-grep-sort.sh | |
chmod -v +x -- "${PROGRAM}" "${SCRIPT}" | |
"${PROGRAM}" --version | |
"${SCRIPT}" | |
- name: Run Script compare-current-and-expected | |
shell: bash | |
run: | | |
set -eux | |
export PROGRAM=./s4_release | |
SCRIPT=./tools/compare-current-and-expected/compare.sh | |
chmod -v +x -- "${PROGRAM}" "${SCRIPT}" | |
"${PROGRAM}" --version | |
"${SCRIPT}" | |
# Run code coverage using cargo-llvm-cov then upload to coveralls.io | |
job_code_coverage_llvm: | |
name: llvm-cov | |
runs-on: ubuntu-latest | |
needs: job_runs | |
env: | |
COVERALLS_FILE: ./coveralls.lcov | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Install libsystemd | |
shell: bash | |
run: | | |
set -eux | |
sudo apt update || true | |
sudo apt install --yes libsystemd0 | |
- uses: actions-rs/toolchain@v1 | |
name: toolchain ${{ env.VERSION_LLVM_COV }} minimal | |
with: | |
profile: minimal | |
toolchain: ${{ env.VERSION_LLVM_COV }} | |
override: true | |
- name: install cargo-llvm-cov | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: -- cargo-llvm-cov | |
- name: add llvm-tools-preview | |
shell: bash | |
run: rustup component add llvm-tools-preview | |
- name: run llvm-cov | |
shell: bash | |
run: | | |
set -eux | |
cargo llvm-cov --version | |
cargo llvm-cov show-env | |
cargo llvm-cov --lcov --output-path "${COVERALLS_FILE}" | |
- name: upload coveralls | |
uses: coverallsapp/github-action@v2 | |
with: | |
file: ${{ env.COVERALLS_FILE }} | |
format: lcov | |
... |