Skip to content

CI-Rust

CI-Rust #9

Workflow file for this run

# ==----------------------------------------------------------------== #
# SPDX-FileCopyrightText: © 2024-2025 Nayan Patil <nayantsg@proton.me>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# ==----------------------------------------------------------------== #
# Do not modify!
# This file was generated from a template using the necronux internal pkl package.
# Any changes should be made to the template, not this file.
name: CI-Rust
'on':
pull_request:
branches:
- develop
- stable
- release
- hotfix
paths:
- '*.rs'
- '**/*.rs'
- src/**
- crates/**
- Cargo.toml
- Cargo.lock
- deny.toml
push:
paths:
- '*.rs'
- '**/*.rs'
- src/**
- crates/**
- Cargo.toml
- Cargo.lock
- deny.toml
workflow_dispatch:
inputs:
trigger_event:
description: Specify which event to simulate
required: false
default: push
type: choice
options:
- pull_request
- push
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
CARGO_HACK_DENY_WARNINGS: 1
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
conclusion-pr:
if: ${{ (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_event == 'pull_request')) && !cancelled() }}
needs:
- test-full
- check-version-bump
- clippy
- docs
- lockfile
- msrv
- rustfmt
permissions:
contents: none
runs-on: ubuntu-latest
steps:
- name: Conclusion
shell: bash
run: |-
jq -C <<< '${{ toJson(needs) }}'
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
conclusion-push:
if: ${{ (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_event == 'push')) && !cancelled() }}
needs:
- test-minimal
- check-version-bump
- clippy
- docs
- lockfile
- msrv
- rustfmt
permissions:
contents: none
runs-on: ubuntu-latest
steps:
- name: Conclusion
shell: bash
run: |-
jq -C <<< '${{ toJson(needs) }}'
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- name: Run cargo fmt
shell: bash
run: cargo fmt --all --check
clippy:
name: Clippy
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- windows-latest
- macos-latest
- macos-13
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
- name: Run cargo clippy
shell: bash
run: cargo clippy --workspace --all-targets --all-features --no-deps -- -D clippy::all
lockfile:
name: Cargo Lockfile
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Ensure Cargo.lock is up-to-date
shell: bash
run: cargo update -p necronux --locked
check-version-bump:
name: Check Version Bump
runs-on: ubuntu-latest
timeout-minutes: 30
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-semver-checks
uses: taiki-e/install-action@cargo-semver-checks
- name: Run cargo semver-checks
shell: bash
run: |-
set -euo pipefail
base_sha=$(git rev-parse "${BASE_SHA:-HEAD~1}")
head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}")
echo "Base revision is $base_sha"
echo "Head revision is $head_sha"
cargo semver-checks --baseline-rev "$base_sha" --workspace
test-minimal:
name: Minimal Tests (${{ matrix.name }})
if: ${{ (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_event == 'push')) && !cancelled() }}
strategy:
matrix:
include:
- name: Linux x86_64 stable
os: ubuntu-latest
rust: stable
other: i686-unknown-linux-gnu
- name: Linux x86_64 beta
os: ubuntu-latest
rust: beta
other: i686-unknown-linux-gnu
- name: Linux x86_64 nightly
os: ubuntu-latest
rust: nightly
other: i686-unknown-linux-gnu
- name: Linux aarch64 stable
os: ubuntu-24.04-arm
rust: stable
- name: Linux aarch64 nightly
os: ubuntu-24.04-arm
rust: nightly
- name: Windows x86_64 MSVC stable
os: windows-latest
rust: stable-msvc
other: i686-pc-windows-msvc
- name: Windows x86_64 gnu nightly
os: windows-latest
rust: nightly-gnu
other: i686-pc-windows-gnu
- name: macOS aarch64 stable
os: macos-latest
rust: stable
other: x86_64-apple-darwin
- name: macOS aarch64 nightly
os: macos-latest
rust: nightly
other: x86_64-apple-darwin
- name: macOS x86_64 nightly
os: macos-13
rust: nightly
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 30
env:
CARGO_PROFILE_DEV_DEBUG: 1
CARGO_PROFILE_TEST_DEBUG: 1
RUSTUP_WINDOWS_PATH_ADD_BIN: 0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.rust }}-${{ matrix.name }}
- name: Setup rustup stable
shell: bash
run: rustup update --no-self-update stable
- name: Update rustup and set default version
shell: bash
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Add rustup targets
if: ${{ matrix.other != null }}
shell: bash
run: rustup target add ${{ matrix.other }}
- name: Configure extra test environment
if: matrix.os == 'ubuntu-latest'
shell: bash
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
- name: Run cargo test with default features in debug mode
shell: bash
run: cargo test --lib --bins --workspace
- name: Run cargo test with all features in debug mode
shell: bash
run: cargo test --lib --bins --workspace --all-features
test-full:
name: Full Tests (${{ matrix.name }})
if: ${{ (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_event == 'pull_request')) && !cancelled() }}
strategy:
matrix:
include:
- name: Linux x86_64 stable
os: ubuntu-latest
rust: stable
other: i686-unknown-linux-gnu
- name: Linux x86_64 beta
os: ubuntu-latest
rust: beta
other: i686-unknown-linux-gnu
- name: Linux x86_64 nightly
os: ubuntu-latest
rust: nightly
other: i686-unknown-linux-gnu
- name: Linux aarch64 stable
os: ubuntu-24.04-arm
rust: stable
- name: Linux aarch64 nightly
os: ubuntu-24.04-arm
rust: nightly
- name: Windows x86_64 MSVC stable
os: windows-latest
rust: stable-msvc
other: i686-pc-windows-msvc
- name: Windows x86_64 gnu nightly
os: windows-latest
rust: nightly-gnu
other: i686-pc-windows-gnu
- name: macOS aarch64 stable
os: macos-latest
rust: stable
other: x86_64-apple-darwin
- name: macOS aarch64 nightly
os: macos-latest
rust: nightly
other: x86_64-apple-darwin
- name: macOS x86_64 nightly
os: macos-13
rust: nightly
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 30
env:
CARGO_PROFILE_DEV_DEBUG: 1
CARGO_PROFILE_TEST_DEBUG: 1
RUSTUP_WINDOWS_PATH_ADD_BIN: 0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.rust }}-${{ matrix.name }}
- name: Setup rustup stable
shell: bash
run: rustup update --no-self-update stable
- name: Update rustup and set default version
shell: bash
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Add rustup targets
if: ${{ matrix.other != null }}
shell: bash
run: rustup target add ${{ matrix.other }}
- name: Configure extra test environment
if: matrix.os == 'ubuntu-latest'
shell: bash
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
- name: Run cargo test with default features in debug mode
shell: bash
run: cargo test --all-targets --workspace
- name: Run cargo test with all features in debug mode
shell: bash
run: cargo test --all-targets --workspace --all-features
- name: Run cargo test with default features in release mode
shell: bash
run: cargo test --all-targets --workspace --release
- name: Run cargo test with all features in release mode
shell: bash
run: cargo test --all-targets --workspace --all-features --release
docs:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -C debuginfo=0 -D warnings
RUSTUP_MAX_RETRIES: 10
CARGO_HACK_DENY_WARNINGS: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Run cargo doc
env:
RUSTDOCFLAGS: -D warnings
shell: bash
run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going
- name: Run cargo test with all features in debug mode
shell: bash
run: cargo test --doc --workspace --all-features
msrv:
name: MSRV
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo hack
uses: taiki-e/install-action@cargo-hack
- name: Run cargo hack check
shell: bash
run: cargo hack check --all-targets --rust-version --locked