name: run-benchmark
on:
workflow_call:
inputs:
pull_request_json:
description: String that contain JSON payload for `pull_request` event.
required: true
type: string
permissions: {}
jobs:
benchmark:
name: Run benchmark
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ fromJSON(inputs.pull_request_json).merge_commit_sha }}
- name: Deepen cloned repo
env:
BASE_SHA: ${{ fromJSON(inputs.pull_request_json).base.sha }}
run: 'git fetch --depth=1 origin "$BASE_SHA:refs/tags/BASE"'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: npm
node-version-file: '.node-version'
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Run Benchmark
run: |
npm run benchmark -- --revs HEAD BASE
- name: Create replyMessage
uses: actions/github-script@v6
with:
script: |
const fs = require('node:fs');
// GH doesn't expose job's id so we need to get it through API, see
// https://github.community/t/job-id-is-string-in-github-job-but-integer-in-actions-api/139060
const result = await github.rest.actions.listJobsForWorkflowRun({
...context.repo,
run_id: context.runId,
filter: 'latest',
})
const currentJob = result.data.jobs.find(
(job) => job.name === 'cmd-run-benchmark / Run benchmark',
);
fs.writeFileSync(
'./replyMessage.txt',
`Please, see benchmark results here: ${currentJob.html_url}#step:6:1`,
);
- name: Upload replyMessage
uses: actions/upload-artifact@v3
with:
name: replyMessage
path: ./replyMessage.txt