Run performance tests on all PR against base branch #856
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Performance tests | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
perf-tests: | |
runs-on: [ubuntu-latest] | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
# needed for integration & memory tests codecs support | |
- run: | |
sudo add-apt-repository multiverse && sudo apt update && sudo apt install -y | |
ubuntu-restricted-extras | |
- run: npm ci | |
- run: export DISPLAY=:99 | |
- run: sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional | |
- run: | |
node tests/performance/run.mjs --branch $GITHUB_BASE_REF --remote-git-url | |
https://github.com/canalplus/rx-player.git --report perf-report.md | |
- name: Post comment | |
if: always() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { readFileSync, existsSync } = require('fs'); | |
if (!existsSync("./perf-report.md")) { | |
return; | |
} | |
const fileContent = readFileSync("./perf-report.md").toString(); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
// TODO: generate comment header inside the report file instead of here for better portability? | |
// We should already have access to the sha1 through `git` and the destination branch through the command line arguments. | |
body: "Automated performance checks have found a sensible difference on commit \`${{github.event.pull_request.head.sha}}\` with the base branch \`${{github.base_ref}}\`:\n\n" + fileContent, | |
}) |