Skip to content

Commit

Permalink
Merge pull request #1630 from canalplus/misc/performance-tests-all-pr
Browse files Browse the repository at this point in the history
Run performance tests on all PR against base branch
  • Loading branch information
peaBerberian authored Jan 28, 2025
2 parents f2aafd5 + b75076e commit 9cf989f
Show file tree
Hide file tree
Showing 7 changed files with 1,089 additions and 495 deletions.
40 changes: 36 additions & 4 deletions .github/workflows/perfs.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
name: Performance tests

on:
pull_request:
types: [labeled]
types: [opened, synchronize, reopened]

# Abort if new commit since then
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
perf-tests:
if: ${{ github.event.label.name == 'Performance checks' }}
if:
${{ !contains(github.event.pull_request.labels.*.name, 'skip-performance-checks') }}
runs-on: [ubuntu-latest]
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
Expand All @@ -21,4 +30,27 @@ jobs:
- 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
- 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 been performed on commit " +
"\`${{github.event.pull_request.head.sha}}\` with the base branch \`${{github.base_ref}}\`.\n\n" +
fileContent +
"\n\n If you want to skip performance checks for latter commits, add the `skip-performance-checks` label to this Pull Request.",
})
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/demo/worker.js

/tests/performance/node_modules
/tests/performance/bundle1.js
/tests/performance/bundle2.js
/tests/performance/previous.js
/tests/performance/current.js
/tests/performance/package.json
/tests/performance/package-lock.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script type="text/javascript" src="./bundle1.js" charset="utf-8"></script>
<script type="text/javascript" src="./current.js" charset="utf-8"></script>
<title>RxPlayer - Performance tests</title>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script type="text/javascript" src="./bundle2.js" charset="utf-8"></script>
<script type="text/javascript" src="./previous.js" charset="utf-8"></script>
<title>RxPlayer - Performance tests</title>
</head>
<body>
Expand Down
Loading

0 comments on commit 9cf989f

Please sign in to comment.