Skip to content

Commit

Permalink
ci: Run more things in parallel (#2125)
Browse files Browse the repository at this point in the history
* `cargo machete`
* `cargo fmt`
* `cargo clippy`
  • Loading branch information
larseggert authored Sep 18, 2024
1 parent b72b3ba commit 0e40d36
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 58 deletions.
59 changes: 12 additions & 47 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
merge_group:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
Expand All @@ -20,7 +21,6 @@ permissions:

jobs:
check:
name: Build & test
strategy:
fail-fast: false
matrix:
Expand All @@ -42,30 +42,30 @@ jobs:
shell: bash

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install Rust
uses: ./.github/actions/rust
- uses: ./.github/actions/rust
with:
version: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy, llvm-tools-preview
tools: cargo-llvm-cov, cargo-nextest, cargo-hack, cargo-fuzz, cargo-machete
components: clippy, llvm-tools-preview
tools: cargo-llvm-cov, cargo-nextest, cargo-hack, cargo-fuzz
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get minimum NSS version
id: nss-version
- id: nss-version
run: echo "minimum=$(cat neqo-crypto/min_version.txt)" >> "$GITHUB_OUTPUT"

- name: Install NSS
uses: ./.github/actions/nss
- uses: ./.github/actions/nss
with:
minimum-version: ${{ steps.nss-version.outputs.minimum }}

- name: Build
run: |
# shellcheck disable=SC2086
cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --all-targets --features ci
# Check that the fuzz targets also build
if [ ${{ startsWith(matrix.rust-toolchain, 'nightly') && 'nightly' }} == 'nightly' ]; then
cargo +${{ matrix.rust-toolchain }} fuzz check
fi
- name: Run tests and determine coverage
run: |
Expand All @@ -90,41 +90,7 @@ jobs:
RUST_LOG: warn
BUILD_DIR: ${{ matrix.type == 'release' && 'release' || 'debug' }}

- name: Check formatting
run: |
if [ "${{ startsWith(matrix.rust-toolchain, 'nightly') && 'nightly' }}" != "nightly" ]; then
CONFIG_PATH="--config-path=$(mktemp)"
fi
# shellcheck disable=SC2086
cargo +${{ matrix.rust-toolchain }} fmt --all -- --check $CONFIG_PATH
if: success() || failure()

- name: Check for unused dependencies
run: |
# --with-metadata has false positives, see https://github.com/bnjbvr/cargo-machete/issues/127
cargo +${{ matrix.rust-toolchain }} machete
- name: Clippy
run: |
# Use cargo-hack to run clippy on each crate individually with its
# respective default features only. Can reveal warnings otherwise
# hidden given that a plain cargo clippy combines all features of the
# workspace. See e.g. https://github.com/mozilla/neqo/pull/1695.
cargo +${{ matrix.rust-toolchain }} hack clippy --all-targets --feature-powerset --exclude-features gecko -- -D warnings || ${{ matrix.rust-toolchain == 'nightly' }}
# Check that the fuzz targets also build
if [ ${{ startsWith(matrix.rust-toolchain, 'nightly') && 'nightly' }} == 'nightly' ]; then
cargo +${{ matrix.rust-toolchain }} fuzz check
fi
if: success() || failure()

- name: Check rustdoc links
run: cargo +${{ matrix.rust-toolchain }} doc --workspace --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--deny rustdoc::broken_intra_doc_links --deny warnings"
if: success() || failure()

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
file: lcov.info
fail_ci_if_error: false
Expand All @@ -135,6 +101,5 @@ jobs:
if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable'

bench:
name: "Benchmark"
needs: [check]
uses: ./.github/workflows/bench.yml
47 changes: 47 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Clippy
on:
push:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
merge_group:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
contents: read

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/rust
with:
components: clippy
tools: cargo-hack, cargo-fuzz
token: ${{ secrets.GITHUB_TOKEN }}

- id: nss-version
run: echo "minimum=$(cat neqo-crypto/min_version.txt)" >> "$GITHUB_OUTPUT"

- uses: ./.github/actions/nss
with:
minimum-version: ${{ steps.nss-version.outputs.minimum }}

# Use cargo-hack to run clippy on each crate individually with its
# respective default features only. Can reveal warnings otherwise
# hidden given that a plain cargo clippy combines all features of the
# workspace. See e.g. https://github.com/mozilla/neqo/pull/1695.
- run: cargo hack clippy --all-targets --feature-powerset --exclude-features gecko -- -D warnings
- run: cargo doc --workspace --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--deny rustdoc::broken_intra_doc_links --deny warnings"
34 changes: 34 additions & 0 deletions .github/workflows/machete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Machete
on:
workflow_dispatch:
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
merge_group:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
contents: read

jobs:
machete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install Rust
uses: ./.github/actions/rust
with:
tools: cargo-machete
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check for unused dependencies
run: |
# --with-metadata has false positives, see https://github.com/bnjbvr/cargo-machete/issues/127
cargo machete
19 changes: 8 additions & 11 deletions .github/workflows/mutants.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Find mutants
on:
schedule:
- cron: '42 3 * * 2,5' # Runs at 03:42 UTC (m and h chosen arbitrarily) twice a week.
workflow_dispatch:
push:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
Expand All @@ -22,17 +23,14 @@ jobs:
with:
fetch-depth: 0

- name: Get minimum NSS version
id: nss-version
- id: nss-version
run: echo "minimum=$(cat neqo-crypto/min_version.txt)" >> "$GITHUB_OUTPUT"

- name: Install NSS
uses: ./.github/actions/nss
- uses: ./.github/actions/nss
with:
minimum-version: ${{ steps.nss-version.outputs.minimum }}

- name: Install Rust
uses: ./.github/actions/rust
- uses: ./.github/actions/rust
with:
tools: cargo-mutants
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -63,8 +61,7 @@ jobs:
echo '```'
} > "$GITHUB_STEP_SUMMARY"
- name: Archive mutants.out
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: always()
with:
name: mutants.out
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Format
on:
push:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "*.png", "*.svg", "LICENSE-*"]
merge_group:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
contents: read

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/rust
with:
version: nightly
components: rustfmt
token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo fmt --all -- --check

0 comments on commit 0e40d36

Please sign in to comment.