Skip to content

Merge pull request #1306 from coreos/dependabot/cargo/nmstate-2.2.16 #2276

Merge pull request #1306 from coreos/dependabot/cargo/nmstate-2.2.16

Merge pull request #1306 from coreos/dependabot/cargo/nmstate-2.2.16 #2276

Workflow file for this run

name: Rust
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
# s390x tests are expensive; don't waste job slots on superseded code
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CONTAINER: registry.fedoraproject.org/fedora:latest
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Pinned toolchain for linting
ACTIONS_LINTS_TOOLCHAIN: 1.71.0
defaults:
run:
# Created by env-setup early in the job
shell: 'wrap-container {0}'
jobs:
tests-stable:
name: "Tests, stable toolchain"
runs-on: ubuntu-latest
strategy:
# Keep x86_64 jobs alive if s390x jobs fail
fail-fast: false
matrix:
arch:
- x86_64
- s390x
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up environment
run: .github/workflows/env-setup
shell: bash
env:
ARCH: ${{ matrix.arch }}
TOOLCHAIN: stable
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
with:
# rust-cache creates a separate cache key for each job definition,
# but bases it on the Rust version in the host, not the container.
# Specify additional fields not implied by the job name.
key: ${{ matrix.arch }}
- name: Install dependencies
run: dnf install -y gcc git-core libzstd-devel openssl-devel cpio diffutils jq xz
- name: Configure cargo
run: |
# Avoid OOM on emulated s390x
# https://github.com/rust-lang/cargo/issues/10583
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[net]
git-fetch-with-cli = true
EOF
- name: cargo build
run: cargo build --all-targets
- name: cargo test
run: cargo test --all-targets
- name: cargo build (rdcore)
run: cargo build --all-targets --features rdcore
- name: cargo test (rdcore)
run: cargo test --all-targets --features rdcore
- name: Image tests
if: ${{ matrix.arch == 'x86_64' }}
run: tests/images.sh
tests-msrv:
name: "Tests, minimum supported toolchain"
runs-on: ubuntu-latest
strategy:
# Keep x86_64 jobs alive if s390x jobs fail
fail-fast: false
matrix:
arch:
- x86_64
- s390x
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Detect crate MSRV
shell: bash
run: |
msrv=$(cargo metadata --format-version 1 --no-deps | \
jq -r '.packages | .[].rust_version')
echo "Crate MSRV: $msrv"
echo "MSRV=$msrv" >> $GITHUB_ENV
- name: Set up environment
run: .github/workflows/env-setup
shell: bash
env:
ARCH: ${{ matrix.arch }}
TOOLCHAIN: ${{ env.MSRV }}
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
with:
# rust-cache creates a separate cache key for each job definition,
# but bases it on the Rust version in the host, not the container.
# Specify additional fields not implied by the job name, plus the
# numeric MSRV as an optimization to ignore the old cache after the
# MSRV changes.
key: ${{ matrix.arch }}-${{ env.MSRV }}
- name: Install dependencies
run: dnf install -y gcc git-core libzstd-devel openssl-devel cpio diffutils jq xz
- name: Configure cargo
run: |
# Avoid OOM on emulated s390x
# https://github.com/rust-lang/cargo/issues/10583
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[net]
git-fetch-with-cli = true
EOF
- name: cargo build
run: cargo build --all-targets
- name: cargo test
run: cargo test --all-targets
- name: cargo build (rdcore)
run: cargo build --all-targets --features rdcore
- name: cargo test (rdcore)
run: cargo test --all-targets --features rdcore
- name: Image tests
if: ${{ matrix.arch == 'x86_64' }}
run: tests/images.sh
lints:
name: "Lints, pinned toolchain"
runs-on: ubuntu-latest
strategy:
# Keep x86_64 jobs alive if s390x jobs fail
fail-fast: false
matrix:
arch:
- x86_64
- s390x
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up environment
run: .github/workflows/env-setup
shell: bash
env:
ARCH: ${{ matrix.arch }}
TOOLCHAIN: ${{ env.ACTIONS_LINTS_TOOLCHAIN }}
COMPONENTS: rustfmt,clippy
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
with:
# rust-cache creates a separate cache key for each job definition,
# but bases it on the Rust version in the host, not the container.
# Specify additional fields not implied by the job name, plus the
# numeric version as an optimization to ignore the old cache after
# the lint toolchain changes.
key: ${{ matrix.arch }}-${{ env.ACTIONS_LINTS_TOOLCHAIN }}
- name: Install dependencies
run: dnf install -y gcc git-core libzstd-devel openssl-devel
- name: Configure cargo
run: |
# Avoid OOM on emulated s390x
# https://github.com/rust-lang/cargo/issues/10583
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[net]
git-fetch-with-cli = true
EOF
- name: cargo fmt (check)
run: cargo fmt -- --check -l
- name: cargo clippy (warnings)
run: cargo clippy --all-targets -- -D warnings
- name: cargo clippy (rdcore, warnings)
run: cargo clippy --all-targets --features rdcore -- -D warnings
tests-other-channels:
name: "Tests, unstable toolchain"
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
channel:
- "beta"
- "nightly"
arch:
- x86_64
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up environment
run: .github/workflows/env-setup
shell: bash
env:
ARCH: ${{ matrix.arch }}
TOOLCHAIN: ${{ matrix.channel }}
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
with:
# rust-cache creates a separate cache key for each job definition,
# but bases it on the Rust version in the host, not the container.
# Specify additional fields not implied by the job name.
key: ${{ matrix.arch }}-${{ matrix.channel }}
- name: Install dependencies
run: dnf install -y gcc git-core libzstd-devel openssl-devel cpio diffutils jq xz
- name: Configure cargo
run: |
# Avoid OOM on emulated s390x
# https://github.com/rust-lang/cargo/issues/10583
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[net]
git-fetch-with-cli = true
EOF
- name: cargo build
run: cargo build --all-targets
- name: cargo test
run: cargo test --all-targets
- name: cargo build (rdcore)
run: cargo build --all-targets --features rdcore
- name: cargo test (rdcore)
run: cargo test --all-targets --features rdcore
- name: Image tests
if: ${{ matrix.arch == 'x86_64' }}
run: tests/images.sh
docs:
name: "Docs"
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up environment
run: .github/workflows/env-setup
shell: bash
env:
ARCH: x86_64
TOOLCHAIN: stable
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: dnf install -y gcc git-core libzstd-devel openssl-devel util-linux
- name: cargo build
run: cargo build
- name: Help text line length
run: tests/help.sh
- name: Config file docs
run: tests/docs-config-file.sh
- name: Command-line docs
run: |
rm man/*.8
make docs
if [ -n "$(git status --porcelain data docs man)" ]; then
echo "Found local changes after regenerating docs:"
git --no-pager diff --color=always docs man
echo "Rerun 'make docs'."
exit 1
fi