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/benchmark/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