chore: small refactoring #5
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
name: Lint Test and Benchmark | ||
on: [push, pull_request] | ||
jobs: | ||
check-unix: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
rust: [stable, nightly] | ||
os: [ubuntu-latest, macos-latest] | ||
env: | ||
GTFSORT_TEST_FEATURES_MINIMUM: "testing" | ||
GTFSORT_TEST_FEATURES_FULL: "testing mmap all_ffi" | ||
GTFSORT_TEST_FEATURES_RELEASE: "mmap all_ffi" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- name: Cargo Check with Minimum Feature Flags | ||
run: cargo check --manifest-path ./gtfsort/Cargo.toml --no-default-features --features "$GTFSORT_TEST_FEATURES_MINIMUM" | ||
- name: Cargo Check with Full Feature Flags | ||
run: cargo check --manifest-path ./gtfsort/Cargo.toml --features "$GTFSORT_TEST_FEATURES_FULL" | ||
- name: Cargo Clippy with Minimum Feature Flags | ||
run: cargo clippy --manifest-path ./gtfsort/Cargo.toml --no-default-features --features "$GTFSORT_TEST_FEATURES_MINIMUM" -- -D warnings | ||
- name: Cargo Clippy with Full Feature Flags | ||
run: cargo clippy --manifest-path ./gtfsort/Cargo.toml --features "$GTFSORT_TEST_FEATURES_FULL" -- -D warnings | ||
- name: Cargo Test with Minimum Feature Flags | ||
# saves time on more expensive machines | ||
if: ${{ startsWith(matrix.os, 'ubuntu') }} | ||
run: RUST_BACKTRACE=full cargo test --manifest-path ./gtfsort/Cargo.toml --no-default-features --features "$GTFSORT_TEST_FEATURES_MINIMUM" -- --nocapture | ||
- name: Cargo Build Release | ||
run: cargo build --manifest-path ./gtfsort/Cargo.toml --release --features "$GTFSORT_TEST_FEATURES_FULL" | ||
- name: Cargo Test with Full Feature Flags | ||
run: RUST_BACKTRACE=full cargo test --manifest-path ./gtfsort/Cargo.toml --features "$GTFSORT_TEST_FEATURES_FULL" -- --nocapture | ||
- name: Check C headers are up-to-date | ||
if: ${{ startsWith(matrix.os, 'ubuntu') }} | ||
run: git diff --exit-code ./gtfsort/include/gtfsort.h ./gtfsort/include/gtfsort.hxx | ||
- name: Cargo Clean | ||
if: ${{ matrix.rust == 'stable' }} | ||
run: cargo clean --manifest-path ./gtfsort/Cargo.toml | ||
- name: Build Release | ||
if: ${{ matrix.rust == 'stable' }} | ||
run: cargo build --manifest-path ./gtfsort/Cargo.toml --release --features "$GTFSORT_TEST_FEATURES_RELEASE" | ||
- name: Upload Build Artifacts | ||
if: ${{ startsWith(matrix.os, 'macos') != true && matrix.rust == 'stable' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts-${{ matrix.os }} | ||
path: | | ||
./gtfsort/target/release/gtfsort | ||
./gtfsort/target/release/libgtfsort.so | ||
- name: Upload Build Artifacts (macOS) | ||
if: ${{ startsWith(matrix.os, 'macos') && matrix.rust == 'stable' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts-${{ matrix.os }} | ||
path: | | ||
./gtfsort/target/release/gtfsort | ||
./gtfsort/target/release/libgtfsort.dylib | ||
./gtfsort/include/gtfsort.h | ||
./gtfsort/include/gtfsort.hxx | ||
check-windows: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
rust: [stable, nightly] | ||
env: | ||
GTFSORT_TEST_FEATURES_MINIMUM: "testing" | ||
GTFSORT_TEST_FEATURES_FULL: "testing mmap all_ffi" | ||
GTFSORT_TEST_FEATURES_RELEASE: "mmap all_ffi" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up MSYS2 for Windows | ||
uses: msys2/setup-msys2@v2 | ||
with: | ||
msystem: MINGW64 | ||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
target: x86_64-pc-windows-gnu | ||
- name: Cargo Check with Minimum Feature Flags | ||
run: cargo check --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --no-default-features --features $env:GTFSORT_TEST_FEATURES_MINIMUM | ||
- name: Cargo Check with Full Feature Flags | ||
run: cargo check --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --features $env:GTFSORT_TEST_FEATURES_FULL | ||
- name: Cargo Clippy with Minimum Feature Flags | ||
run: cargo clippy --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --no-default-features --features $env:GTFSORT_TEST_FEATURES_MINIMUM -- -D warnings | ||
- name: Cargo Clippy with Full Feature Flags | ||
run: cargo clippy --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --features $env:GTFSORT_TEST_FEATURES_FULL -- -D warnings | ||
- name: Cargo Test with Minimum Feature Flags | ||
run: $env:RUST_BACKTRACE="full"; cargo test --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --no-default-features --features $env:GTFSORT_TEST_FEATURES_MINIMUM -- --nocapture | ||
- name: Cargo Build Release | ||
run: cargo build --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --release --features $env:GTFSORT_TEST_FEATURES_FULL | ||
- name: Cargo Test with Full Feature Flags | ||
run: $env:RUST_BACKTRACE="full"; cargo test --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --features $env:GTFSORT_TEST_FEATURES_FULL -- --nocapture | ||
- name: Cargo Clean | ||
if: ${{ matrix.rust == 'stable' }} | ||
run: cargo clean --manifest-path ./gtfsort/Cargo.toml | ||
- name: Build Release | ||
if: ${{ matrix.rust == 'stable' }} | ||
run: cargo build --manifest-path ./gtfsort/Cargo.toml --target x86_64-pc-windows-gnu --release --features $env:GTFSORT_TEST_FEATURES_RELEASE | ||
- name: Upload Build Artifacts | ||
if: ${{ matrix.rust == 'stable' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts-windows | ||
path: | | ||
./gtfsort/target/x86_64-pc-windows-gnu/release/gtfsort.exe | ||
./gtfsort/target/x86_64-pc-windows-gnu/release/gtfsort.dll | ||
./gtfsort/include/gtfsort.h | ||
./gtfsort/include/gtfsort.hxx | ||
py_port: | ||
needs: [check-unix, check-windows] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: '3.9' | ||
target: [x86_64, aarch64] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --features test --out dist --find-interpreter --manifest-path py-gtfsort/Cargo.toml | ||
sccache: 'true' | ||
manylinux: auto | ||
- name: Install built package | ||
run: | | ||
pip install gtfsortpy --no-index --find-links dist --force-reinstall | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: dist | ||
benchmark: | ||
needs: [check-unix, check-windows] | ||
if: ${{ needs.check-unix.result == 'success' && contains(github.event.head_commit.message, '[ci benchmark]') }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
- name: Install Hyperfine | ||
run: cargo install hyperfine --force --locked | ||
- name: Set Upstream | ||
run: git remote add upstream https://github.com/alejandrogzi/gtfsort.git | ||
- name: Fetch Upstream | ||
run: git fetch upstream | ||
- name: Build Benchmark | ||
run: cargo build --manifest-path ./gtfsort/Cargo.toml --release --bin gtfsort-benchmark --features "mmap benchmark" | ||
- name: Run Benchmark | ||
env: | ||
GITHUB_REPO_OWNER: ${{ github.event.repository.owner.login }} | ||
GITHUB_REPO_NAME: ${{ github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./gtfsort/target/release/gtfsort-benchmark -r upstream/master -- --show-output | ||
- name: Upload Benchmark Results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: benchmark-results-${{ matrix.os }} | ||
path: | | ||
./gtfsort/tests/benchmark_*.csv | ||
./gtfsort/tests/benchmark_*.md | ||
./gtfsort/tests/benchmark-output.txt |