Skip to content

Merge pull request #203 from elfenpiff/iox2-195-add-sliced-api #2

Merge pull request #203 from elfenpiff/iox2-195-add-sliced-api

Merge pull request #203 from elfenpiff/iox2-195-add-sliced-api #2

Workflow file for this run

name: Unit-Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main, release* ]
env:
RUSTFLAGS: "-C debug-assertions"
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
source-code: ${{ steps.filter.outputs.source-code }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Check for source-code changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
source-code:
- '!**/*.md'
preflight-check:
needs: changes
if: ${{ needs.changes.outputs.source-code == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Check format of all commit messages
run: ./internal/scripts/ci_test_commit_msg.sh
- name: Check license header
run: ./internal/scripts/ci_test_spdx_license_header.sh
static-code-analysis:
needs: preflight-check
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macOS-latest]
timeout-minutes: 10
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
# TODO iox2-172: cargo clippy receives a SIGABRT with macOS-latest x64 but
# works in this version
# toolchain: stable
toolchain: 1.76.0
components: rustfmt, clippy
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy -- -D warnings
- name: Run code examples in documentation
run: cargo test --workspace --doc
- name: Build documentation
run: cargo doc
cargo-nextest:
needs: preflight-check
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Build and cache cargo-nextest
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: stable
check-and-install-cmd: cargo-nextest --version > /dev/null || cargo install cargo-nextest --locked
print-version-cmd: cargo-nextest --version
cache-key: cache-1-${{ runner.os }}-cargo-nextest
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
x86_64:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
toolchain: [stable, 1.73.0, beta, nightly]
mode:
- name: "release"
arg: "--release"
- name: "debug"
arg: ""
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Download artifact cargo-nextest
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
- name: Prepare system
run: ${{ matrix.os == 'windows-latest' && 'internal\scripts\ci_prepare_windows.bat' || ( matrix.os == 'ubuntu-latest' && './internal/scripts/ci_prepare_ubuntu.sh' || 'uname -a' ) }}
- name: Run cargo build
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }}
- name: Run cargo nextest
run: cargo nextest run --workspace --no-fail-fast ${{ matrix.mode.arg }}
### TODO: does not work yet reliable on the GitHub CI, seems to end up in an infinite loop
### current alternative is a cirrus.yml aarch64 target
# arm:
# runs-on: ubuntu-latest
# if: ${{ needs.changes.outputs.source-code == 'true' }}
# strategy:
# matrix:
# architecture: ["aarch64"] # ["aarch64", "armv7"]
# toolchain: [ stable ] # [stable, 1.73.0, beta, nightly]
# mode: ["--release", ""]
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v4
# - uses: uraimo/run-on-arch-action@v2
# name: Run commands
# with:
# arch: ${{ matrix.architecture }}
# distro: archarm_latest
# run: |
# ./internal/scripts/ci_prepare_archlinux.sh
# rustup default ${{ matrix.toolchain }}
# cargo fmt --all -- --check
# cargo clippy -- -D warnings
# cargo build --workspace --all-targets ${{ matrix.mode }}
# cargo test --workspace --no-fail-fast ${{ matrix.mode }}
freebsd:
needs: [preflight-check, static-code-analysis]
if: ${{ needs.changes.outputs.source-code == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
freebsd_version: [ "14.0" ]
toolchain: [ "stable", "1.73.0" ] # [stable, 1.73.0, beta, nightly]
mode: [""] # ["--release", ""]
steps:
- uses: actions/checkout@v4
- uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.freebsd_version }}
run: |
./internal/scripts/ci_prepare_freebsd.sh
export PATH=$PATH:$HOME/.cargo/bin
export LIBCLANG_PATH=/usr/local/llvm15/lib/
rustup default ${{ matrix.toolchain }}
export RUSTFLAGS="-C debug-assertions"
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo build --workspace --all-targets ${{ matrix.mode }}
cargo install cargo-nextest --locked
cargo nextest run --workspace --no-fail-fast ${{ matrix.mode }}
grcov:
needs: [preflight-check, static-code-analysis]
if: ${{ needs.changes.outputs.source-code == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and cache grcov
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: stable
rust-components: llvm-tools-preview
check-and-install-cmd: grcov --version > /dev/null || cargo install grcov
print-version-cmd: grcov --version
cache-key: cache-1-${{ runner.os }}-grcov
artifact-bin-name: grcov
artifact-upload-name: ${{ runner.os }}-grcov
coverage:
needs: grcov
if: ${{ needs.changes.outputs.source-code == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get -y install libacl1-dev llvm
- name: Create test users and groups
run: |
sudo useradd testuser1
sudo useradd testuser2
sudo groupadd testgroup1
sudo groupadd testgroup2
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
- name: Download artifact grcov
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: grcov
artifact-upload-name: ${{ runner.os }}-grcov
- name: Generate raw coverage results
run: ./internal/scripts/generate-cov-report.sh --generate
- name: Generate coverage results for html artifacts
run: ./internal/scripts/generate-cov-report.sh --html
- name: Archive coverage-html artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: target/debug/coverage/html/*
retention-days: 90
- name: Generate coverage report for Codecov
run: ./internal/scripts/generate-cov-report.sh --lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: target/debug/coverage/lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}