Skip to content

Commit

Permalink
chore(ci): Configure codspeed (#9189)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Jul 10, 2024
1 parent 3ddf63c commit e7b9c55
Show file tree
Hide file tree
Showing 46 changed files with 293 additions and 263 deletions.
175 changes: 69 additions & 106 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
pull_request:
types: ["opened", "reopened", "synchronize"]

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
Expand All @@ -22,33 +24,63 @@ env:
SKIP_YARN_COREPACK_CHECK: 1

jobs:
list-crates:
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
name: List crates
# list-crates:
# if: >-
# ${{ !contains(github.event.head_commit.message, 'chore: ') }}
# name: List crates
# runs-on: ubuntu-latest
# outputs:
# crates: ${{ steps.list-crates.outputs.crates }}
# steps:
# - uses: actions/checkout@v4

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal

# - name: List crates
# id: list-crates
# run: echo "crates=$(./scripts/cargo/get-crates.sh)" >> $GITHUB_OUTPUT

# bench-crate:
# name: Bench ${{ matrix.crate }}
# runs-on: ubuntu-latest
# needs:
# - list-crates
# strategy:
# fail-fast: false
# matrix:
# crate: ${{fromJson(needs.list-crates.outputs.crates)}}
# steps:
# - uses: actions/checkout@v4

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal

# - uses: ./.github/actions/setup-node

# - name: Setup rust toolchain, cache and cargo-codspeed binary
# uses: moonrepo/setup-rust@v0
# with:
# channel: stable
# cache-target: release
# bins: cargo-codspeed

# - name: Build the benchmark target(s)
# run: cargo codspeed build -p ${{ matrix.crate }}

# - name: Run the benchmarks
# uses: CodSpeedHQ/action@v2
# with:
# run: cargo codspeed run -p ${{ matrix.crate }}
# token: ${{ secrets.CODSPEED_TOKEN }}

bench-all:
name: Bench everything
runs-on: ubuntu-latest
outputs:
crates: ${{ steps.list-crates.outputs.crates }}
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal

- name: List crates
id: list-crates
run: echo "crates=$(./scripts/cargo/get-crates.sh)" >> $GITHUB_OUTPUT

bench-crate:
name: Bench ${{ matrix.crate }}
runs-on: ubuntu-latest
needs:
- list-crates
strategy:
matrix:
crate: ${{fromJson(needs.list-crates.outputs.crates)}}
steps:
- uses: actions/checkout@v4

Expand All @@ -59,87 +91,18 @@ jobs:

- uses: ./.github/actions/setup-node

- name: Run benchmark
run: cargo bench -p ${{ matrix.crate }} -- --output-format bencher --sample-size 10 | tee output-${{ matrix.crate }}.txt

- name: List outputs
run: ls -l output-*.txt

- name: Upload benchmark result
uses: actions/upload-artifact@v2
# We need to merge output.txt for each crates
- name: Setup rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
name: output
path: output-*

process-result:
name: Process result
runs-on: ubuntu-latest
needs:
- bench-crate
steps:
- uses: actions/checkout@v4
channel: stable
cache-target: release
bins: cargo-codspeed

- name: Download benchmark results
uses: actions/download-artifact@v2
with:
name: output
- name: Build the benchmark target(s)
run: cargo codspeed build

- name: List outputs
run: ls -l output-*.txt

- name: Merge outputs
run: cat output-*.txt > output.txt

- name: Download previous benchmark results
run: mkdir raw-data && curl -o raw-data/benchmark-data.json https://raw.githubusercontent.com/swc-project/raw-data/gh-pages/benchmark-data.json

- name: Analyze benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
# What benchmark tool the output.txt came from
tool: "cargo"
# Where the output from the benchmark tool is stored
output-file-path: output.txt
external-data-json-path: ./raw-data/${{ github.sha }}/benchmark-data.json
# Workflow will fail when an alert happens
fail-on-alert: true
# GitHub API token to make a commit comment
github-token: ${{ secrets.GITHUB_TOKEN }}
# Enable alert commit comment
comment-on-alert: true
comment-always: true
skip-fetch-gh-pages: true

- name: Analyze benchmark result (root)
if: ${{ github.event_name == 'push' }}
uses: benchmark-action/github-action-benchmark@v1
with:
# What benchmark tool the output.txt came from
tool: "cargo"
# Where the output from the benchmark tool is stored
output-file-path: output.txt
external-data-json-path: ./raw-data/benchmark-data.json
# Workflow will fail when an alert happens
# fail-on-alert: true
# GitHub API token to make a commit comment
github-token: ${{ secrets.GITHUB_TOKEN }}
# Enable alert commit comment
comment-on-alert: true
comment-always: true
alert-comment-cc-users: "@kdy1"
skip-fetch-gh-pages: true
max-items-in-chart: 250

- name: Deploy
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@4.1.0
- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.GH_TOKEN }}
branch: gh-pages
folder: raw-data
clean: false
single-commit: false
git-config-email: github-bot@swc.rs
repository-name: swc-project/raw-data
commit-message: "Update"
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
46 changes: 46 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e7b9c55

Please sign in to comment.