From 6378a186abb11f9a5fb0e7489ee3f83a90c70164 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 27 May 2022 18:38:30 +0200 Subject: [PATCH 1/3] run performance comparisons in ci Signed-off-by: Robin Appelman --- .github/workflows/performance.yml | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/performance.yml diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml new file mode 100644 index 00000000000..f6707087349 --- /dev/null +++ b/.github/workflows/performance.yml @@ -0,0 +1,111 @@ +name: Performance testing +on: + pull_request: + +jobs: + performance-testing: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-versions: ['8.0'] + + name: performance-${{ matrix.php-versions }} + + steps: + - name: Checkout server before PR + uses: actions/checkout@v3 + with: + submodules: true + ref: ${{ github.event.pull_request.base.ref }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd + + - 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 + + cd apps + git clone https://github.com/icewind1991/blueprint + cd blueprint + composer install + cd .. + + git clone -b cli https://github.com/nextcloud/profiler + cd .. + + ./occ app:enable --force blueprint + ./occ app:enable --force profiler + + ./occ profiler:enable + ./occ blueprint:enable + ./occ blueprint:apply apps/blueprint/blueprints/small.toml + + php -S localhost:8080 & + - name: Run warmup + run: | + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + - name: Run before measurements + run: | + rm -rf data/profiler + + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + + ./occ profiler:list + ./occ profiler:export > before.json + - name: Apply PR + run: | + git fetch origin ${{ github.event.pull_request.head.ref }} + git checkout ${{ github.event.pull_request.head.ref }} + git submodule update + + ./occ upgrade + - name: Run after measurements + run: | + rm -rf data/profiler + + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + + ./occ profiler:list + ./occ profiler:export > after.json + + - name: Upload profiles + uses: actions/upload-artifact@v2 + with: + name: profiles + path: | + before.json + after.json + + - name: Compare measurements + uses: mathiasvr/command-output@v1 + id: compare + with: + run: ./occ profiler:compare before.json after.json + - uses: actions/github-script@v5 + if: failure() && steps.compare.outcome == 'failure' + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + let comment = `Possible performance regression detected\n`; + comment += `
Show Output + + \`\`\` + ${{ steps.compare.outputs.stdout }} + \`\`\` + +
`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }) From 5d3e86a1c63fe4cdd09b0877076e21a056d74155 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 31 May 2022 17:54:03 +0200 Subject: [PATCH 2/3] use profiler action Signed-off-by: Robin Appelman --- .github/workflows/performance.yml | 60 ++++++++++++------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f6707087349..eb7c3687d1a 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -32,34 +32,20 @@ jobs: 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 - cd apps - git clone https://github.com/icewind1991/blueprint - cd blueprint - composer install - cd .. - - git clone -b cli https://github.com/nextcloud/profiler - cd .. - - ./occ app:enable --force blueprint - ./occ app:enable --force profiler - - ./occ profiler:enable - ./occ blueprint:enable - ./occ blueprint:apply apps/blueprint/blueprints/small.toml - php -S localhost:8080 & - - name: Run warmup - run: | - curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + - name: Apply blueprint + uses: icewind1991/blueprint@v0.1.1 + with: + blueprint: apps/blueprint/blueprints/small.toml + - name: Run before measurements - run: | - rm -rf data/profiler + uses: nextcloud/profiler@44befceb459ca489ba17a14c3f17683ab7206660 + 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 + output: before.json - curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test - - ./occ profiler:list - ./occ profiler:export > before.json - name: Apply PR run: | git fetch origin ${{ github.event.pull_request.head.ref }} @@ -67,16 +53,19 @@ jobs: git submodule update ./occ upgrade + - name: Run after measurements - run: | - rm -rf data/profiler - - curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test - - ./occ profiler:list - ./occ profiler:export > after.json + id: compare + uses: nextcloud/profiler@44befceb459ca489ba17a14c3f17683ab7206660 + 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 + output: after.json + compare-with: before.json - name: Upload profiles + if: always() uses: actions/upload-artifact@v2 with: name: profiles @@ -84,11 +73,6 @@ jobs: before.json after.json - - name: Compare measurements - uses: mathiasvr/command-output@v1 - id: compare - with: - run: ./occ profiler:compare before.json after.json - uses: actions/github-script@v5 if: failure() && steps.compare.outcome == 'failure' with: @@ -98,7 +82,7 @@ jobs: comment += `
Show Output \`\`\` - ${{ steps.compare.outputs.stdout }} + ${{ steps.compare.outputs.compare }} \`\`\`
`; From d6e35dfe2cb792d13fc25a8d527369143fea4a6e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jun 2022 17:45:23 +0200 Subject: [PATCH 3/3] use blueprint from repo Signed-off-by: Robin Appelman --- .github/workflows/performance.yml | 16 +++++++++++----- tests/blueprints/basic.toml | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 tests/blueprints/basic.toml diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index eb7c3687d1a..e5cbac5fe8f 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -34,16 +34,19 @@ jobs: php -S localhost:8080 & - name: Apply blueprint - uses: icewind1991/blueprint@v0.1.1 + uses: icewind1991/blueprint@v0.1.2 with: - blueprint: apps/blueprint/blueprints/small.toml - + blueprint: tests/blueprints/basic.toml + ref: ${{ github.event.pull_request.head.ref }} - name: Run before measurements - uses: nextcloud/profiler@44befceb459ca489ba17a14c3f17683ab7206660 + uses: nextcloud/profiler@fa03a1e6864fcb63fb92b8940fa72f5191baffbe 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 - name: Apply PR @@ -56,11 +59,14 @@ jobs: - name: Run after measurements id: compare - uses: nextcloud/profiler@44befceb459ca489ba17a14c3f17683ab7206660 + uses: nextcloud/profiler@fa03a1e6864fcb63fb92b8940fa72f5191baffbe 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 compare-with: before.json diff --git a/tests/blueprints/basic.toml b/tests/blueprints/basic.toml new file mode 100644 index 00000000000..28902fd5708 --- /dev/null +++ b/tests/blueprints/basic.toml @@ -0,0 +1,20 @@ +[[user]] +id = "test" +groups = ["test_group"] +files = [ + "test.txt", + "foo/sub.png", + "empty", +] + +[[user]] +id = "test2" +groups = ["test"] +files = [ + "many_files/file_[1..100].txt" +] + +[[share]] +from = "test2" +to = "test" +file = "many_files"