From 5f4f3a5fd8e70e30ad6fe878359fa3e210251214 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Wed, 1 May 2024 15:22:41 -0400 Subject: [PATCH] feat: add CodSpeed to the project --- .github/workflows/audit.yml | 29 ----------------- .github/workflows/benchmark.yml | 31 ++++++++++++++++++ .github/workflows/build.yml | 53 ------------------------------- .github/workflows/docs.yml | 26 --------------- .github/workflows/mark-stale.yaml | 23 -------------- pingora-ketama/Cargo.toml | 2 +- 6 files changed, 32 insertions(+), 132 deletions(-) delete mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/mark-stale.yaml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml deleted file mode 100644 index b943e5d7..00000000 --- a/.github/workflows/audit.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Security Audit - -on: - push: - branches: - - master - paths: - - "**/Cargo.toml" - schedule: - - cron: "0 2 * * *" # run at 2 AM UTC - -permissions: - contents: read - -jobs: - security-audit: - permissions: - checks: write # for rustsec/audit-check to create check - contents: read # for actions/checkout to fetch code - issues: write # for rustsec/audit-check to create issues - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Audit Check - # https://github.com/rustsec/audit-check/issues/2 - uses: rustsec/audit-check@master - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..9bd3af6c --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,31 @@ +name: codspeed-benchmarks + +on: + # Run on pushes to the main branch + push: + branches: + - "main" + # Run on pull requests + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +jobs: + benchmarks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup rust toolchain, cache and cargo-codspeed binary + uses: moonrepo/setup-rust@v1 + with: + cache-target: release + bins: cargo-codspeed + + - name: Build the benchmark target(s) + run: cargo codspeed build -p pingora-ketama simple + + - name: Run the benchmarks + uses: CodSpeedHQ/action@v2 + with: + run: cargo codspeed run diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 9fa13903..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,53 +0,0 @@ -on: [push, pull_request] - -name: build - -jobs: - pingora: - strategy: - matrix: - toolchain: [nightly, 1.72, 1.80.0] - runs-on: ubuntu-latest - # Only run on "pull_request" event for external PRs. This is to avoid - # duplicate builds for PRs created from internal branches. - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Install build dependencies - run: | - sudo apt update - sudo apt install -y cmake libclang-dev wget gnupg ca-certificates lsb-release --no-install-recommends - # openresty is used for convenience in tests as a server. - wget -O - https://openresty.org/package/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null - sudo apt update - sudo apt install -y openresty --no-install-recommends - - - name: Install toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - components: rustfmt, clippy - - - name: Run cargo fmt - run: cargo fmt --all -- --check - - - name: Run cargo test - run: cargo test --verbose --lib --bins --tests --no-fail-fast - - # Need to run doc tests separately. - # (https://github.com/rust-lang/cargo/issues/6669) - - name: Run cargo doc test - run: cargo test --verbose --doc - - - name: Run cargo clippy - run: | - [[ ${{ matrix.toolchain }} == nightly ]] || cargo clippy --all-targets --all -- --allow=unknown-lints --deny=warnings - - - name: Run cargo audit - run: | - [[ ${{ matrix.toolchain }} != 1.80.0 ]] || (cargo install cargo-audit && cargo audit) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 59e85bed..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - push: - branches: - - master - -name: Docs - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Install build dependencies - run: | - sudo apt update - sudo apt install -y cmake libclang-dev - - - name: Install stable toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Run cargo doc - run: cargo doc --no-deps --all-features diff --git a/.github/workflows/mark-stale.yaml b/.github/workflows/mark-stale.yaml deleted file mode 100644 index 4a95853c..00000000 --- a/.github/workflows/mark-stale.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: 'Close stale questions' -on: - schedule: - - cron: '30 1 * * *' - workflow_dispatch: - -permissions: - issues: write - pull-requests: write - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - stale-issue-message: 'This question has been stale for a week. It will be closed in an additional day if not updated.' - close-issue-message: 'This issue has been closed because it has been stalled with no activity.' - days-before-stale: -1 - days-before-issue-stale: 7 - days-before-issue-close: 1 - stale-issue-label: 'stale' - only-issue-labels: 'question' diff --git a/pingora-ketama/Cargo.toml b/pingora-ketama/Cargo.toml index f3956a14..6c528d15 100644 --- a/pingora-ketama/Cargo.toml +++ b/pingora-ketama/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["hash", "hashing", "consistent", "pingora"] crc32fast = "1.3" [dev-dependencies] -criterion = "0.4" +criterion = { package="codspeed-criterion-compat", version = "2.6.0" } csv = "1.2" dhat = "0.3" env_logger = "0.9"