Files
discordeno/.github/workflows/benchmark.yml
Fleny 97a8016041 chore: Code changes & formatting and linting (#3552)
* Do some code changes & run prettier and eslint

* Fix test:test-type script

* Apply code review suggestions

* update heartbeat interval & add a reason for the specific value

* Fix husky error

* Update to TS 5.5

And use ${configDir}

* Fix test.json tsconfig base

---------

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
2024-07-08 15:11:41 -05:00

105 lines
3.4 KiB
YAML

name: Benchmark
on:
workflow_call:
inputs:
sha:
required: true
type: string
repo:
required: true
type: string
outputs:
cpuMatch:
value: ${{ jobs.benchmark.outputs.cpuMatch }}
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
outputs:
cpuMatch: ${{ steps.cpuCheck.outputs.match }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Check cpu model
id: cpuCheck
run: node ./scripts/checkCpuModel.js
- name: Get yarn cache directory path
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
- name: Build
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
run: yarn build
#
- name: Download db from benchmark repo
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
run: wget https://github.com/discordeno/benchmarks/raw/main/db.tar.gz
- name: Decompress db
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
run: tar -xzvf db.tar.gz
- name: Benchmark
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
run: node --expose-gc ./packages/benchmarks/dist/index.js | tee output.txt
- name: Download previous benchmark data
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
uses: actions/cache@v3
with:
path: ./benchmarksResult
key: ${{ github.ref }}-benchmark-${{ github.sha }}
restore-keys: |
${{ github.ref }}-benchmark-
- name: Store benchmark result to cache
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'benchmarkjs'
output-file-path: output.txt
external-data-json-path: benchmarksResult/data.json
- uses: actions/upload-artifact@v3
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
with:
name: benchmarkResults
path: benchmarksResult/data.json
- name: Save Commmit SHA
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
run: |
mkdir -p ./commitData
echo ${{ inputs.sha }} > ./commitData/sha
echo ${{ inputs.repo }} > ./commitData/repo
- uses: actions/upload-artifact@v3
if: ${{ steps.cpuCheck.outputs.match == 'true' }}
with:
name: commitData
path: commitData/
- name: remove changes
run: git reset --hard HEAD
- name: Store benchmark result (Main)
uses: benchmark-action/github-action-benchmark@v1
if: ${{ github.ref == 'refs/heads/main' && steps.cpuCheck.outputs.match == 'true' }}
with:
tool: 'benchmarkjs'
output-file-path: output.txt
gh-pages-branch: 'benchies'
benchmark-data-dir-path: benchmarksResult
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true