summaryrefslogtreecommitdiffstats
path: root/.github/workflows/performance.yml
blob: eb7c3687d1a95b6a68da5793aef63894fc54f91b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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

          php -S localhost:8080 &
      - name: Apply blueprint
        uses: icewind1991/blueprint@v0.1.1
        with:
          blueprint: apps/blueprint/blueprints/small.toml

      - name: Run before measurements
        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

      - 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
        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
          path: |
            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 += `<details><summary>Show Output</summary>

            \`\`\`
            ${{ steps.compare.outputs.compare }}
            \`\`\`

            </details>`;

            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: comment
            })