fix(ci): run performance tests against fetched PR changes #62053
This file contains hidden or 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
| # SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors | |
| # SPDX-License-Identifier: MIT | |
| name: Performance testing | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: performance-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| performance-testing: | |
| runs-on: ubuntu-latest | |
| # Skip entirely on fork PRs so the job result is 'skipped' rather than | |
| # 'failure'. The profiler action uses github.event.pull_request.head.repo.clone_url | |
| # and GITHUB_TOKEN in ways that do not work reliably from forks, and a | |
| # clean skip is far less confusing for contributors than a mid-run error. | |
| if: >- | |
| github.repository_owner != 'nextcloud-gmbh' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| permissions: | |
| pull-requests: write | |
| name: performance | |
| steps: | |
| # Check out the PR base branch first so the initial measurements provide | |
| # a baseline for comparison with the PR changes measured below. | |
| - name: Check out PR base branch | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| submodules: true | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| - name: Set up php | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 | |
| timeout-minutes: 5 | |
| with: | |
| php-version: '8.3' | |
| extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Nextcloud | |
| run: | | |
| mkdir data | |
| ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password | |
| php -S localhost:8080 & | |
| - name: Apply blueprint | |
| uses: icewind1991/blueprint@00504403f76cb2a09efd0d16793575055e6f63cb # v0.1.2 | |
| with: | |
| blueprint: tests/blueprints/basic.toml | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: Run before measurements | |
| uses: nextcloud/profiler@6a74c915048285b35b8e1cd96c0835a635945044 | |
| with: | |
| run: | | |
| curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test | |
| curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt | |
| curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files | |
| curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt | |
| curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt | |
| output: before.json | |
| profiler-branch: master | |
| - name: Check out PR changes and apply upgrade | |
| # Switch from the base branch used for the baseline measurements to the | |
| # fetched PR commit so the after measurements run against the PR changes. | |
| # | |
| # Use FETCH_HEAD explicitly so the local branch points to the fetched PR | |
| # commit rather than the currently checked-out base commit. | |
| env: | |
| PR_HEAD_REPO_URL: ${{ github.event.pull_request.head.repo.clone_url }} | |
| PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| run: | | |
| git remote add pr-source "$PR_HEAD_REPO_URL" | |
| git fetch pr-source "$PR_HEAD_REF" | |
| git checkout -B "pr/$PR_HEAD_REF" FETCH_HEAD | |
| git submodule update | |
| ./occ upgrade | |
| - name: Run after measurements | |
| id: compare | |
| uses: nextcloud/profiler@6a74c915048285b35b8e1cd96c0835a635945044 | |
| with: | |
| run: | | |
| curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test | |
| curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt | |
| curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files | |
| curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt | |
| curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt | |
| output: after.json | |
| profiler-branch: master | |
| compare-with: before.json | |
| - name: Upload profiles | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: profiles | |
| path: | | |
| before.json | |
| after.json | |
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v7 | |
| if: failure() && steps.compare.outcome == 'failure' | |
| env: | |
| COMPARE_OUTPUT: ${{ steps.compare.outputs.compare }} | |
| with: | |
| github-token: ${{secrets.GITHUB_TOKEN}} | |
| script: | | |
| let comment = `Possible performance regression detected\n`; | |
| comment += `<details><summary>Show Output</summary> | |
| \`\`\` | |
| ${process.env.COMPARE_OUTPUT} | |
| \`\`\` | |
| </details>`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }) |