Skip to content

format

format #8

Workflow file for this run

name: 'Watch Benchmarks'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'bench/**'
permissions:
issues: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.changes.outputs.benchmarks_files }}
changes: ${{ steps.changes.outputs.benchmarks }}
steps:
- uses: actions/checkout@v3
- name: 'Detect File Changes'
uses: dorny/paths-filter@v2
id: changes
with:
list-files: json
base: ${{ github.ref }}
working-directory: bench
filters: |
benchmarks:
- added|modified: 'bench/*.js'
benchmark:
needs: changes
if: needs.changes.outputs.files != '[]'
strategy:
fail-fast: true
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['add-property.js', 'array-append.js'] if both bench files contains changes
bench-file: ${{ fromJSON(needs.changes.outputs.files) }}
node-version: [18.0.0, 18.18.0, 18.19.0, 20.0.0, 20.10.0, 20.11.1, 21.0.0, 21.6.0, 21.7.1]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: NPM Install
run: npm install
- name: Correct Bench file
run: |-
export SAFE_BENCH_FILE=$(basename ${{ matrix.bench-file }})
echo "BENCH_FILE=$SAFE_BENCH_FILE" >> "$GITHUB_ENV"
- name: Report Filename
run: echo "BENCH_REPORT_FILE=report-${{github.run_id}}-${{ matrix.node-version }}-${{ env.BENCH_FILE }}.md" >> $GITHUB_ENV
- name: Run Benchmark
run: node bench/${{ env.BENCH_FILE }} > ./${{ env.BENCH_REPORT_FILE }}
env:
CI: true
- name: Notify on Error
if: ${{ failure() }}
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
title: Benchmark ${{ env.BENCH_FILE }} failed on v${{ matrix.node-version }}
body: |
### Context
[Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
[Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }})
Workflow name - `${{ github.workflow }}`
Job - `${{ github.job }}`
status - `${{ job.status }}`
assignees: RafaelGSS
labels: bug
- name: Add Job Summary
run: |
result=$(cat ./${{ env.BENCH_REPORT_FILE }})
echo "$result" >> $GITHUB_STEP_SUMMARY
- name: Upload Bench Result
uses: actions/upload-artifact@v3
with:
name: benchmark-artifacts-${{github.run_id}}
retention-days: 1
if-no-files-found: error
path: ./${{ env.BENCH_REPORT_FILE }}
## Write for matrix outputs workaround
- uses: cloudposse/github-action-matrix-outputs-write@main
id: out
with:
matrix-step-name: benchmark
matrix-key: ${{ env.BENCH_FILE }}:${{ matrix.node-version }}
outputs: |-
result: ${{ env.BENCH_REPORT_FILE }}
## Read matrix outputs
read:
runs-on: ubuntu-latest
needs: [benchmark]
steps:
- uses: cloudposse/github-action-matrix-outputs-read@main
id: read
with:
matrix-step-name: benchmark
outputs:
result: '${{ steps.read.outputs.result }}'
commit:
runs-on: ubuntu-latest
needs: [read]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: Use Node.js v20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Create temporary report folder
run: mkdir ./temp-reports
- uses: actions/download-artifact@v3
with:
name: benchmark-artifacts-${{github.run_id}}
path: ./temp-reports
- name: Write Benchmark Results
run: |
node scripts/write-bench-results.mjs
node scripts/generate-reports.mjs
env:
BENCH_ARTIFACTS: ${{ needs.read.outputs.result }}
- name: Clean temporary report folder
run: rm -r ./temp-reports
- name: Commit and Push Updated Results
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: 'main'
commit_message: 'chore(bench): update benchmark results'