perf(gateway): optimize CommandRatelimiter
size
#2505
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Checks performed on our common library crates. | |
name: Library | |
on: | |
push: | |
branches: | |
- main | |
- next | |
- 0.* | |
pull_request: | |
merge_group: | |
env: | |
# Use `haswell` instead of `native` due to some GitHub Actions runners not | |
# supporting some `avx512` instructions. | |
RUSTFLAGS: -C target-cpu=haswell -D warnings | |
jobs: | |
# Run MSRV first to save Actions time if the code doesn't compile at all. | |
MSRV: | |
name: Minimum supported Rust version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Retrieve rust-version | |
run: echo rust-version=$(awk '/rust-version/{print $NF}' Cargo.toml | tr -d '"') >> $GITHUB_ENV | |
- name: Install toolchain (${{ env.rust-version }}) | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.rust-version }} | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Output processor info | |
run: cat /proc/cpuinfo | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- run: cargo check --all-features --workspace --exclude book | |
# Check documentation | |
build-docs: | |
name: Build docs | |
needs: [MSRV] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Install nightly toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Build docs | |
env: | |
RUSTDOCFLAGS: --cfg docsrs | |
run: cargo doc --no-deps --all-features --workspace --exclude book | |
# Lints | |
clippy: | |
name: Clippy | |
needs: [MSRV] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Run clippy | |
run: cargo clippy --all-features --all-targets | |
codespell: | |
name: Spelling | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Run Codespell | |
uses: codespell-project/actions-codespell@master | |
rustfmt: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install nightly toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
components: rustfmt | |
toolchain: nightly | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Check code formatting | |
run: cargo fmt --all -- --check --unstable-features --config format_code_in_doc_comments=true | |
min-vers: | |
name: Minimal crate versions | |
needs: [MSRV] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install nightly toolchain | |
uses: dtolnay/rust-toolchain@nightly | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Install cargo-hack | |
uses: taiki-e/install-action@cargo-hack | |
- name: Install cargo-minimal-versions | |
uses: taiki-e/install-action@cargo-minimal-versions | |
- name: Work around old serde_derive version error | |
run: cargo add -p twilight-model [email protected] | |
- name: Check minimal versions | |
run: cargo minimal-versions check | |
# Tests | |
test: | |
name: Test | |
needs: [MSRV] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Install nextest | |
uses: taiki-e/install-action@nextest | |
- name: Run tests with nextest | |
run: cargo nextest --config-file ${{ github.workspace }}/nextest.toml run --profile ci --workspace --exclude book | |
- name: Run doctests | |
run: cargo test --doc --workspace --exclude book | |
feature-combinations: | |
name: Feature combinations | |
needs: [MSRV] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Add problem matchers | |
run: echo "::add-matcher::.github/rust.json" | |
- name: Install cargo-hack | |
uses: taiki-e/install-action@cargo-hack | |
- name: Check feature combinations | |
run: cargo hack check --feature-powerset |