tests: fail instead of pass when requirement not met #49
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: Push actions | |
on: | |
push: | |
pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: "-Dwarnings" | |
jobs: | |
rustfmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- name: Run Rustfmt | |
run: cargo fmt -- --check | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: clippy | |
- name: Run Clippy | |
run: cargo clippy --all-targets --all-features | |
stable-test: | |
name: Run tests on stable channel | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Install dependencies | |
run: sudo apt install bird2 | |
- name: Build | |
run: cargo build --verbose | |
- name: Run tests | |
run: cargo test --verbose # TODO: skip tests requiring root | |
- name: Run tests with unshare | |
run: | | |
sudo sh -c 'echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns' | |
sudo sysctl -p | |
cargo --config \ | |
"target.'cfg(target_os = \"linux\")'.runner = 'unshare -rn'" \ | |
test --verbose | |
nightly-test: | |
name: Run tests on nightly channel | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: Install dependencies | |
run: sudo apt install bird2 | |
- name: Build | |
run: cargo build --verbose | |
- name: Run tests | |
run: cargo test --verbose # TODO: skip tests requiring root | |
- name: Run tests with unshare | |
run: | | |
sudo sh -c 'echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns' | |
sudo sysctl -p | |
cargo --config \ | |
"target.'cfg(target_os = \"linux\")'.runner = 'unshare -rn'" \ | |
test --verbose | |
cross-test: | |
name: Build for ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- armv7-unknown-linux-gnueabihf | |
- x86_64-unknown-linux-musl | |
- aarch64-unknown-linux-musl | |
- armv7-unknown-linux-musleabihf | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cargo-bins/cargo-binstall@main | |
- name: Install cross-rs | |
run: cargo binstall cross | |
- name: Build debug binary | |
run: cross build --target=${{ matrix.target }} --verbose | |
- name: Run cross unit tests | |
run: cross test --target=${{ matrix.target }} --verbose -- --skip integration_tests | |
- name: Build release binary | |
run: cross build --release --target=${{ matrix.target }} --verbose | |
- name: Upload debug binary | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flow-debug-${{ matrix.target }} | |
path: target/${{ matrix.target }}/debug/flow | |
- name: Upload release binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flow-release-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/flow |