swc/.github/workflows/bench.yml
Donny/강동윤 154c315d91
chore(ci): Fix benchmark action (#6596)
**Description:**

It's broken due to the 6-hour time limit of GitHub actions. To fix it, this PR changes the machine type to `ubuntu-large`.
2022-12-08 11:05:53 +09:00

134 lines
4.2 KiB
YAML

name: Benchmark
on:
pull_request:
types: ["opened", "reopened", "synchronize"]
push:
branches:
- main
env:
RUST_LOG: "off"
jobs:
binary-size:
name: Binary size
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') && github.repository_owner == 'swc-project' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v1
with:
path: |
./cache
~/.cargo/
target
key: cargo-release-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-release-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build (release)
run: |
yarn
yarn build
- name: Print binary size
run: ls -al ./bindings/target/release/libbinding*
benchmark:
name: Performance regression check
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') && github.repository_owner == 'swc-project' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-large
steps:
- uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v1
with:
path: |
./cache
~/.cargo/
target
key: cargo-bench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-bench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
# toolchain: nightly-2021-09-30
override: true
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
- name: Install node dependencies
shell: bash
run: |
yarn
- name: Run benchmark
run: cargo bench --workspace --exclude swc_plugin --features plugin_transform_schema_vtest --features rkyv-impl -- --output-format bencher --sample-size 10 | tee 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
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"