Skip to content

Commit

Permalink
Merge branch 'main' into fix-resend-more
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Sep 18, 2024
2 parents f60dfb7 + b780e53 commit 5524b1f
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 108 deletions.
66 changes: 51 additions & 15 deletions .github/actions/nss/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ runs:
- name: Use sccache
# Apparently the action can't be installed twice in the same workflow, so check if
# it's already installed by checking if the RUSTC_WRAPPER environment variable is set
# it's already installed by checking if the SCCACHE_ENABLED environment variable is set
# (which every "use" of this action needs to therefore set)
if: env.RUSTC_WRAPPER != 'sccache'
#
# Also, only enable sscache on our self-hosted runner, because the GitHub cache limit
# is too small for this to be effective there.
if: env.SCCACHE_ENABLED != '1' && env.BUILD_NSS == '1' && runner.environment != 'github-hosted'
uses: mozilla-actions/sccache-action@2e7f9ec7921547d4b46598398ca573513895d0bd # v0.0.4

- name: Enable sscache
if: env.BUILD_NSS == '1' && runner.environment != 'github-hosted'
shell: bash
run: |
echo "SCCACHE_ENABLED=1" >> "$GITHUB_ENV"
if [ "${{ runner.os }}" != "Windows" ]; then
# TODO: Figure out how to make this work on Windows
echo "SCCACHE_CC=sccache cc" >> "$GITHUB_ENV"
echo "SCCACHE_CXX=sccache c++" >> "$GITHUB_ENV"
fi
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
if [ "$GITHUB_WORKFLOW" ]; then
if [ "${{ runner.environment }}" == "github-hosted" ]; then
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
fi
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
- name: Checkout NSS
if: env.BUILD_NSS == '1'
Expand All @@ -96,6 +99,34 @@ runs:
repository: nss-dev/nspr
path: nspr

- name: Get head revisions
if: env.BUILD_NSS == '1'
shell: bash
run: |
NSS_HEAD=$(git -C nss rev-parse HEAD)
NSPR_HEAD=$(git -C nspr rev-parse HEAD)
echo "NSS_HEAD=$NSS_HEAD" >> "$GITHUB_ENV"
echo "NSPR_HEAD=$NSPR_HEAD" >> "$GITHUB_ENV"
- name: Cache NSS
id: cache
if: env.BUILD_NSS == '1' && runner.environment == 'github-hosted'
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: dist
key: nss-${{ runner.os }}-${{ inputs.type }}-${{ env.NSS_HEAD }}-${{ env.NSPR_HEAD }}

- name: Check if build is needed
if: env.BUILD_NSS == '1' && runner.environment == 'github-hosted'
shell: bash
run: |
if [ "${{ steps.cache.outputs.cache-hit }}" == "true" ]; then
echo "Using cached prebuilt NSS"
echo "BUILD_NSS=0" >> "$GITHUB_ENV"
else
echo "Building NSS from source"
fi
- name: Install build dependencies (Linux)
shell: bash
if: runner.os == 'Linux' && env.BUILD_NSS == '1' && runner.environment == 'github-hosted'
Expand Down Expand Up @@ -143,6 +174,21 @@ runs:
# See https://github.com/ilammy/msvc-dev-cmd#name-conflicts-with-shell-bash
rm /usr/bin/link.exe || true
- name: Set up environment
shell: bash
run: |
NSS_TARGET="${{ inputs.type }}"
echo "NSS_TARGET=$NSS_TARGET" >> "$GITHUB_ENV"
NSS_OUT="$NSS_DIR/../dist/$NSS_TARGET"
echo "LD_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "DYLD_FALLBACK_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "$NSS_OUT/lib" >> "$GITHUB_PATH"
echo "NSS_DIR=$NSS_DIR" >> "$GITHUB_ENV"
echo "NSS_PREBUILT=1" >> "$GITHUB_ENV"
env:
NSS_DIR: ${{ github.workspace }}/nss
NSPR_DIR: ${{ github.workspace }}/nspr

- name: Build
shell: bash
if: env.BUILD_NSS == '1'
Expand All @@ -154,15 +200,5 @@ runs:
OPT="-o"
[ "${{ runner.os }}" != "Windows" ] && export CFLAGS="-ggdb3 -fno-omit-frame-pointer"
fi
NSS_TARGET="${{ inputs.type }}"
echo "NSS_TARGET=$NSS_TARGET" >> "$GITHUB_ENV"
NSS_OUT="$NSS_DIR/../dist/$NSS_TARGET"
echo "LD_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "DYLD_FALLBACK_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "$NSS_OUT/lib" >> "$GITHUB_PATH"
echo "NSS_DIR=$NSS_DIR" >> "$GITHUB_ENV"
[ "$SCCACHE_CC" ] && [ "$SCCACHE_CXX" ] && export CC="$SCCACHE_CC" CXX="$SCCACHE_CXX"
$NSS_DIR/build.sh -g -Ddisable_tests=1 $OPT --static
env:
NSS_DIR: ${{ github.workspace }}/nss
NSPR_DIR: ${{ github.workspace }}/nspr
22 changes: 10 additions & 12 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ inputs:
runs:
using: composite
steps:
- name: Upgrade rustup (MacOS)
shell: bash
if: runner.os == 'MacOS'
run: brew update && brew upgrade rustup

- name: Install Rust
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # master
with:
Expand All @@ -35,21 +30,24 @@ runs:

- name: Use sccache
# Apparently the action can't be installed twice in the same workflow, so check if
# it's already installed by checking if the RUSTC_WRAPPER environment variable is set
# it's already installed by checking if the SCCACHE_ENABLED environment variable is set
# (which every "use" of this action needs to therefore set)
if: env.RUSTC_WRAPPER != 'sccache'
#
# Also, only enable sscache on our self-hosted runner, because the GitHub cache limit
# is too small for this to be effective there.
if: env.SCCACHE_ENABLED != '1' && runner.environment != 'github-hosted'
uses: mozilla-actions/sccache-action@2e7f9ec7921547d4b46598398ca573513895d0bd # v0.0.4

- name: Enable sscache
if: runner.environment != 'github-hosted'
shell: bash
run: |
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
if [ "$GITHUB_WORKFLOW" ]; then
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
fi
echo "SCCACHE_ENABLED=1" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
if [ "${{ runner.environment }}" == "github-hosted" ]; then
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
fi
- name: Set up MSVC (Windows)
if: runner.os == 'Windows'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:

- name: Build neqo
run: |
cargo "+$TOOLCHAIN" bench --features bench --no-run
cargo "+$TOOLCHAIN" build --release
cargo "+$TOOLCHAIN" bench --workspace --features bench --no-run
cargo "+$TOOLCHAIN" build --release --bin neqo-client --bin neqo-server
- name: Build msquic
run: |
Expand Down
66 changes: 15 additions & 51 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,36 +42,35 @@ 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: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools-preview' || '' }}
tools: ${{ matrix.rust-toolchain == 'stable' && 'cargo-llvm-cov, ' || '' }} cargo-nextest
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
- name: Check
run: |
# shellcheck disable=SC2086
cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --all-targets --features ci
cargo +${{ matrix.rust-toolchain }} check $BUILD_TYPE --all-targets --features ci
- name: Run tests and determine coverage
run: |
# shellcheck disable=SC2086
RUST_LOG=trace cargo +${{ matrix.rust-toolchain }} llvm-cov nextest $BUILD_TYPE --features ci --no-fail-fast --lcov --output-path lcov.info
cargo +${{ matrix.rust-toolchain }} bench --features bench --no-run
if [ "${{ matrix.rust-toolchain }}" == "stable" ]; then
RUST_LOG=trace cargo +${{ matrix.rust-toolchain }} llvm-cov nextest $BUILD_TYPE --features ci --no-fail-fast --lcov --output-path lcov.info
else
RUST_LOG=trace cargo +${{ matrix.rust-toolchain }} nextest run $BUILD_TYPE --features ci --no-fail-fast
fi
- name: Run client/server transfer
run: |
Expand All @@ -90,41 +89,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 +100,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
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"
39 changes: 39 additions & 0 deletions .github/workflows/fuzz-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Fuzz & Bench
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:
fuzz-bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/rust
with:
version: nightly
tools: 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 }}

# Check that the fuzz and bench targets build
- run: cargo fuzz check
- run: cargo bench --features bench --no-run
Loading

0 comments on commit 5524b1f

Please sign in to comment.