From 0e40d362a94a106d60c43e08d7d9eef5ce2838d2 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Tue, 17 Sep 2024 23:28:13 -0700 Subject: [PATCH] ci: Run more things in parallel (#2125) * `cargo machete` * `cargo fmt` * `cargo clippy` --- .github/workflows/check.yml | 59 +++++++---------------------------- .github/workflows/clippy.yml | 47 ++++++++++++++++++++++++++++ .github/workflows/machete.yml | 34 ++++++++++++++++++++ .github/workflows/mutants.yml | 19 +++++------ .github/workflows/rustfmt.yml | 32 +++++++++++++++++++ 5 files changed, 133 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/clippy.yml create mode 100644 .github/workflows/machete.yml create mode 100644 .github/workflows/rustfmt.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e2861e3400..49dfb8ec80 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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 @@ -20,7 +21,6 @@ permissions: jobs: check: - name: Build & test strategy: fail-fast: false matrix: @@ -42,23 +42,19 @@ 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 }} @@ -66,6 +62,10 @@ jobs: 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: | @@ -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 @@ -135,6 +101,5 @@ jobs: if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable' bench: - name: "Benchmark" needs: [check] uses: ./.github/workflows/bench.yml diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 0000000000..a1ef1ed6ba --- /dev/null +++ b/.github/workflows/clippy.yml @@ -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" diff --git a/.github/workflows/machete.yml b/.github/workflows/machete.yml new file mode 100644 index 0000000000..3e7404bba1 --- /dev/null +++ b/.github/workflows/machete.yml @@ -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 diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index 202f53d652..e1e0314ea3 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -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 }} @@ -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 }} @@ -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 diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml new file mode 100644 index 0000000000..0f48b029a0 --- /dev/null +++ b/.github/workflows/rustfmt.yml @@ -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