Skip to content

Commit

Permalink
feat: track metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jun 9, 2024
1 parent e0749fd commit 58ed12d
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 59 deletions.
146 changes: 101 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Transform CI
name: CI

on:
workflow_dispatch:
Expand All @@ -11,6 +11,7 @@ on:
push:
branches:
- main
- stats
paths-ignore:
- '**/*.md'

Expand All @@ -19,6 +20,8 @@ jobs:
name: Build
timeout-minutes: 10
runs-on: ubuntu-latest
outputs:
size: ${{ steps.run.outputs.BINARY_SIZE }}
steps:
- name: Checkout Repository
uses: taiki-e/checkout-action@v1
Expand All @@ -35,68 +38,121 @@ jobs:
- name: Install Rust
uses: Boshen/setup-rust@main
with:
save-cache: ${{ github.ref_name == 'main' }}
save-cache: true # ${{ github.ref_name == 'main' }}

- name: Build
run: cargo build --release

- id: run
run: |
BINARY_SIZE=$(ls -l ./target/release/transform-ci | awk '{print $5}')
echo "BINARY_SIZE=$BINARY_SIZE" >> $GITHUB_OUTPUT
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: transform-ci
path: ./target/release/transform-ci

checkout:
name: Read repos.json
needs: build
# checkout:
# name: Read repos.json
# needs: build
# runs-on: ubuntu-latest
# outputs:
# matrix: ${{ steps.setmatrix.outputs.content }}
# steps:
# - uses: taiki-e/checkout-action@v1
# - id: setmatrix
# uses: jaywcjlove/github-action-read-file@main
# with:
# localfile: ./matrix.json

# test:
# needs: checkout
# timeout-minutes: 30
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# include: ${{ fromJson(needs.checkout.outputs.matrix) }}
# name: ${{ matrix.repository }}
# steps:
# - name: Clone ${{ matrix.repository }}
# uses: actions/checkout@v4
# with:
# repository: ${{ matrix.repository }}
# ref: ${{ matrix.ref }}

# - name: Download Transform Binary
# uses: actions/download-artifact@v4
# with:
# name: transform-ci

# - name: chmod +x transform-ci
# run: chmod +x ./transform-ci

# - name: Transform
# run: ./transform-ci ${{ matrix.transform_directories }}

# - name: Install pnpm
# run: corepack enable

# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# cache: pnpm

# - name: Install packages
# run: pnpm install

# - name: Check
# run: ${{ matrix.command }}

compile-time:
name: Compile Time
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setmatrix.outputs.content }}
time: ${{ steps.run.outputs.COMPILE_TIME }}
steps:
- uses: taiki-e/checkout-action@v1
- id: setmatrix
uses: jaywcjlove/github-action-read-file@main
- name: Checkout oxc
uses: actions/checkout@v4
with:
localfile: ./matrix.json

test:
needs: checkout
timeout-minutes: 30
repository: oxc-project/oxc
ref: main
path: oxc
- run: mv oxc ../oxc
- uses: Boshen/setup-rust@main
- run: cargo clean # build from scatch using cache
- id: run
run: |
TIMEFORMAT="%e"
/usr/bin/time -o output cargo build --release
cat output
COMPILE_TIME=${cat output}
echo "COMPILE_TIME=$COMPILE_TIME" >> $GITHUB_OUTPUT
monitor:
name: Monitor Metrics
needs: [build, compile-time]
# if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.checkout.outputs.matrix) }}
name: ${{ matrix.repository }}
steps:
- name: Clone ${{ matrix.repository }}
uses: actions/checkout@v4
with:
repository: ${{ matrix.repository }}
ref: ${{ matrix.ref }}

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: transform-ci

- name: chmod +x transform-ci
run: chmod +x ./transform-ci

- name: Transform
run: ./transform-ci ${{ matrix.transform_directories }}
- uses: taiki-e/checkout-action@v1

- name: Install pnpm
run: corepack enable
- name: Create Data
run: |
jq ".[0].value = ${{ needs.compile-time.outputs.time }}" metrics.json > metrics.json
jq ".[1].value = ${{ needs.build.outputs.size }}" metrics.json > metrics.json
- name: Setup Node.js
uses: actions/setup-node@v4
- uses: benchmark-action/github-action-benchmark@v1
with:
cache: pnpm

- name: Install packages
run: pnpm install

- name: Check
run: ${{ matrix.command }}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: Oxc Metrics
tool: customSmallerIsBetter
output-file-path: metrics.json
gh-pages-branch: gh-pages
benchmark-data-dir-path: metrics
auto-push: true
save-data-file: true
45 changes: 31 additions & 14 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions metrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "Compile Time",
"unit": "Seconds",
"value": 0
},
{
"name": "Binary Size",
"unit": "Bytes",
"value": 0
}
]

0 comments on commit 58ed12d

Please sign in to comment.