Skip to content

[#210] Extend CI for FFI builds #10

[#210] Extend CI for FFI builds

[#210] Extend CI for FFI builds #10

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
# increment cache-N-${{}} if a new nextest version is required
cache-key: cache-2-${{ runner.os }}-cargo-nextest
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
x86_32:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [ubuntu-latest] # [windows-latest, ubuntu-latest, macos-latest]
toolchain: [stable] # [stable, 1.75.0, beta, nightly]
mode:
- name: "release"
arg: "--release"
cmake_build_type: "Release"
- name: "debug"
arg: ""
cmake_build_type: "Debug"
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 }}
targets: i686-unknown-linux-gnu
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
- if: ${{ matrix.os == 'windows-latest' }}
name: Prepare Windows
run: internal\scripts\ci_prepare_windows.bat
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: Prepare Linux
run: |
internal/scripts/ci_prepare_ubuntu.sh
uname -a
- name: Run cargo build
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
- name: Run cargo nextest
run: cargo nextest run --workspace --no-fail-fast ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
- name: Build language bindings
run: |
cmake -B target/ffi/build -H. -DCMAKE_INSTALL_PREFIX=target/ffi/install -DEXAMPLES=ON -DCMAKE_BUILD_TYPE=${{ matrix.mode.cmake_build_type }} -DRUST_TARGET_TRIPLET="i686-unknown-linux-gnu" -DCMAKE_C_FLAGS="-m32"
cmake --build target/ffi/build
cmake --install target/ffi/build
- name: Build language binding examples in out-of-tree configuration
if: false # out-of-tree cross-compilation is currently not supported
run: |
rm -rf target/ffi/build
cmake -B target/ffi/out-of-tree -Hexamples/c/ -DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install -DCMAKE_BUILD_TYPE=${{ matrix.mode.cmake_build_type }} -DCMAKE_C_FLAGS="-m32"
cmake --build target/ffi/out-of-tree
x86_64:

Check failure on line 158 in .github/workflows/build-test.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-test.yml

Invalid workflow file

You have an error in your yaml syntax on line 158
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, stable-gnu, 1.75.0]
mode:
- name: "release"
arg: "--release"
cmake_build_type: "Release"
- name: "debug"
arg: ""
cmake_build_type: "Debug"
timeout-minutes: 60
runs-on: ${{ matrix.os }}
- if: ${{ matrix.os == 'windows-latest' }}
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
- if: ${{ matrix.os == 'windows-latest' }}
name: Prepare Windows
run: internal\scripts\ci_prepare_windows.bat
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: Prepare Linux
run: |
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 }}
- name: Build language bindings
run: |
cmake -B target/ffi/build -H. -DCMAKE_INSTALL_PREFIX=target/ffi/install -DEXAMPLES=ON -DCMAKE_BUILD_TYPE=${{ matrix.mode.cmake_build_type }}
cmake --build target/ffi/build
cmake --install target/ffi/build
- name: Build language binding examples in out-of-tree configuration
run: |
rm -rf target/ffi/build
cmake -B target/ffi/out-of-tree -Hexamples/c/ -DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install -DCMAKE_BUILD_TYPE=${{ matrix.mode.cmake_build_type }}
cmake --build target/ffi/out-of-tree
x86_64_unstable:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' }}
continue-on-error: true
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
toolchain: [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
- if: ${{ matrix.os == 'windows-latest' }}
name: Prepare Windows
run: internal\scripts\ci_prepare_windows.bat
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: Prepare Linux
run: |
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.75.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.75.0" ] # [stable, 1.75.0, beta, nightly]
mode: [""] # ["--release", ""]
steps:
- uses: actions/checkout@v4
- uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.freebsd_version }}
mem: 8192
copyback: false
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
echo "###################"
echo "# Run cargo build #"
echo "###################"
cargo build --workspace --all-targets ${{ matrix.mode }}
echo "######################"
echo "# Run cargo nextest #"
echo "#####################"
cargo nextest run --workspace --no-fail-fast ${{ matrix.mode }}
echo "###########################"
echo "# Build language bindings #"
echo "###########################"
cmake -B target/ffi/build -H. -DCMAKE_INSTALL_PREFIX=target/ffi/install -DEXAMPLES=ON
cmake --build target/ffi/build
cmake --install target/ffi/build
echo "################################################################"
echo "# Build language binding examples in out-of-tree configuration #"
echo "################################################################"
rm -rf target/ffi/build
cmake -B target/ffi/out-of-tree -Hexamples/c/ -DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install
cmake --build target/ffi/out-of-tree
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 }}