Skip to content

Check if cargo-semver-checks can now accept "" features #551

Check if cargo-semver-checks can now accept "" features

Check if cargo-semver-checks can now accept "" features #551

Workflow file for this run

# There are two kinds of continuous integration jobs in this project:
#
# - Every code submission or master push passes continuous integration on the
# minimal supported Rust version and the current stable Rust version.
# - Two times a month, a scheduled job makes sure that the code remains
# compatible and lint-free on upcoming Rust toolchains (beta and nightly).
on:
push:
pull_request:
schedule:
- cron: '0 0 5,19 * *'
name: Continuous Integration
# Cancel existing jobs on new pushes to the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
RUSTFLAGS: '-D warnings'
HWLOC_VERSION: '2.9.3'
HWLOC_VERSION_SHORT: '2.9' # Used in URL to official tarball/binaries
MINIMAL_RUST: '1.71.0' # Minimal supported Rust version
CARGO_NET_GIT_FETCH_WITH_CLI: false # Workaround that can go once we bump
# MINIMAL_RUST to 1.72+ in the future.
# https://github.com/dtolnay/rust-toolchain/pull/94
jobs:
# Formatter output doesn't depend on cargo features, and only needs to be
# tested on the latest supported release of each CI run.
format:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up stable toolchain
if: github.event_name != 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Set up nightly toolchain
if: github.event_name == 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Check format
run: cargo fmt --all -- --check
# Clippy and rustc lints depend on cfg(), of which we currently use "feature"
# and "target_os". So far, hwlocality has Linux- and Windows-specific code,
# but nothing macOS-specific, so we can cover all configurations by testing on
# Linux and Windows.
#
# We don't care about warnings on the minimum supported Rust version, only
# about building and running correctly, so we can get away with only testing
# on the latest rustc release.
lints:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-latest,bundled'
- 'hwloc-latest,proptest'
env:
JOB_FLAGS: '--workspace --features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up stable toolchain
if: github.event_name != 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Set up nightly toolchain
if: github.event_name == 'schedule'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: clippy
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'bundled') == false
- name: Check clippy lints
run: cargo clippy ${{ env.JOB_FLAGS }} --all-targets -- -D warnings
- name: Build docs
run: cargo doc ${{ env.JOB_FLAGS }}
- name: Check semver compliance
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
package: hwlocality-sys # TODO: Extend once hwlocality is released
feature-group: default-features
features: ${{ matrix.features }}
rust-toolchain: manual
# Run the tests and examples on all supported OSes and Rust versions (main CI)
#
# FIXME: In an ideal world, it would be enough to test on the first and last
# version of each major hwloc series, as within each series versions
# are additive and almost solely (*cough cough* add_distances *cough
# cough*) add new features to test without removing any.
#
# Unfortunately, `cargo check` does not currently check doctests
# (see https://github.com/rust-lang/cargo/issues/6424 ), so we need to
# test each version individually to make sure that doctests for a
# feature coming from one hwloc version do not use features from newer
# hwloc versions (which would force people to needlessly up their hwloc
# version requirements if they want to follow the doc examples).
test-contrib-debug:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- stable
- $MINIMAL_RUST
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-latest,bundled'
- 'hwloc-latest,proptest'
env:
FEATURES_FLAG: '--features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'bundled') == false
- name: Set up hwloc build dependencies (macOS)
run: brew install automake
if: contains(matrix.features, 'bundled') && startsWith(matrix.os, 'macos')
- name: Collect system information
uses: ./.github/actions/system-information
if: contains(matrix.features, 'bundled') == false
- name: Run unit and doc tests
run: cargo test --workspace ${{ env.FEATURES_FLAG }}
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-examples
- name: Run all examples
run: cargo examples ${{ env.FEATURES_FLAG }}
# Run the tests and examples on all supported OSes and Rust versions,
# in release mode
#
# Some things like UB or arithmetic overflow differ between debug and release
# builds, so it's a good idea to run the tests in release mode too.
#
# We do not do this in the test-contrib-debug job because switching between
# debug and release builds trashes the cargo cache.
#
# We restrict this to the latest supported hwloc release because the
# test-contrib-debug job is already testing for basic consistency, so our only
# goal here is to run as many tests as possible, and running on the latest
# hwloc release (for all supported compilers and OSes) gives us that.
test-contrib-release:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- stable
- $MINIMAL_RUST
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Run unit and doc tests
run: cargo test --workspace --release --features=hwloc-latest
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-examples
- name: Run all examples
run: cargo examples --features=hwloc-latest -- --release
# Run the tests with extra stdlib checks and the ASAN sanitizer
#
# Here, our goal is only code coverage. We noticeably don't need...
#
# - Full version coverage (there's test-contrib-debug for that)
# - Release build coverage (it shouldn't change stdlib usage or turn code with
# valid memory accesses into code with invalid ones)
# - Full OS coverage (we don't test what happens inside of hwloc, so as with
# lints, only testing OSes that have specific Rust code associated with them
# in the bindings is fine)
#
# Also, as a cargo-careful constraint we can only test nightly.
test-contrib-careful:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
env:
JOB_FLAGS: '--workspace --features=hwloc-latest'
# cargo-careful uses the nightly compiler, but runs in the stable CI, so
# we must disable warnings-as-error to avoid breaking submitted PRs when
# a new lint gets added to nightly rustc
RUSTFLAGS: ''
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rust-src
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Install cargo-careful
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-careful
- name: Run unit and doc tests under cargo careful, with ASAN (Unices)
run: |
# By default, cargo-careful disables LeakChecker, but I actually like it
export ASAN_OPTIONS=''
cargo careful test -Zcareful-sanitizer=address ${{ env.JOB_FLAGS }}
if: runner.os != 'Windows'
- name: Run unit and doc tests under cargo careful, w/o ASAN (Windows)
run: cargo careful test ${{ env.JOB_FLAGS }}
if: runner.os == 'Windows'
# Test current code coverage
#
# It is okay to measure coverage for the latest hwloc release only: it is the
# one with the most features to test, as no hwloc release has removed
# significant features so far. However, we must test both linux and windows as
# they each have os-specific code.
coverage:
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
- name: Collect system information
uses: ./.github/actions/system-information
- name: Install cargo-tarpaulin
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-tarpaulin
- name: Measure code coverage
run: cargo tarpaulin --verbose --timeout 120 --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS
flags: ${{ matrix.os }}
fail_ci_if_error: true
verbose: true
# Check compatibility with newer Rust/deps versions (scheduled CI)
#
# We aren't concerned about trashing the cargo cache here since these jobs
# only run occasionally, so the extra convenience and maintainability of
# grouping debug and release tests trumps other considerations.
#
# FIXME: There should be a way to use conditional build matrices without
# duplicating the whole job recipe...
#
test-scheduled:
if: github.event_name == 'schedule'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- beta
- nightly
- $MINIMAL_RUST # Can be broken by deps
features:
- '""'
- 'hwloc-2_0_4'
- 'hwloc-2_1_0'
- 'hwloc-2_2_0'
- 'hwloc-2_3_0'
- 'hwloc-2_4_0'
- 'hwloc-2_5_0'
- 'hwloc-2_8_0'
- 'hwloc-latest,bundled'
- 'hwloc-latest,proptest'
env:
FEATURES_FLAG: '--features=${{ matrix.features }}'
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- name: Set up hwloc
uses: ./.github/actions/setup-hwloc-dependencies
with:
hwloc-version: ${{ env.HWLOC_VERSION }}
hwloc-version-short: ${{ env.HWLOC_VERSION_SHORT }}
if: contains(matrix.features, 'bundled') == false
- name: Set up hwloc build dependencies (macOS)
run: brew install automake
if: contains(matrix.features, 'bundled') && startsWith(matrix.os, 'macos')
- name: Collect system information
uses: ./.github/actions/system-information
if: contains(matrix.features, 'bundled') == false
- name: Run basic tests (debug build)
run: cargo test --workspace ${{ env.FEATURES_FLAG }}
- name: Run basic tests (release build)
run: cargo test --workspace --release ${{ env.FEATURES_FLAG }}
- name: Install cargo-examples
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-examples
- name: Run all examples (debug build)
run: cargo examples ${{ env.FEATURES_FLAG }}
- name: Run all examples (release build)
run: cargo examples ${{ env.FEATURES_FLAG }} -- --release