|
73 | 73 | runs-on: ubuntu-latest |
74 | 74 | if: always() |
75 | 75 | permissions: |
| 76 | + actions: read |
76 | 77 | contents: write |
77 | 78 | pull-requests: write |
78 | 79 | checks: write |
@@ -111,9 +112,61 @@ jobs: |
111 | 112 | - name: Build project |
112 | 113 | run: yarn build |
113 | 114 | - name: Generate report |
| 115 | + env: |
| 116 | + ALLURE_PERF_METRICS: "1" |
114 | 117 | run: yarn allure generate --config=./allurerc.mjs --dump="allure-results-*.zip" --output=./allure-report |
| 118 | + - name: Write perf metrics summary |
| 119 | + if: always() |
| 120 | + run: | |
| 121 | + node ./scripts/allure-perf-summary.mjs ./allure-report/allure-perf-metrics.json --output ./allure-report/allure-perf-metrics.md |
| 122 | + cat ./allure-report/allure-perf-metrics.md >> "$GITHUB_STEP_SUMMARY" |
| 123 | + - name: Upload perf metrics |
| 124 | + uses: actions/upload-artifact@v5 |
| 125 | + if: always() |
| 126 | + with: |
| 127 | + name: allure-perf-metrics |
| 128 | + path: | |
| 129 | + ./allure-report/allure-perf-metrics.json |
| 130 | + ./allure-report/allure-perf-metrics.md |
| 131 | + if-no-files-found: ignore |
115 | 132 | - name: Allure Report Official |
116 | 133 | uses: allure-framework/allure-action@v0 |
117 | 134 | with: |
118 | 135 | report-directory: "./allure-report" |
119 | 136 | github-token: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + |
| 138 | + perf-metrics-comment: |
| 139 | + needs: report |
| 140 | + name: Comment perf metrics |
| 141 | + runs-on: ubuntu-latest |
| 142 | + if: always() && github.event_name == 'pull_request' |
| 143 | + permissions: |
| 144 | + actions: read |
| 145 | + pull-requests: write |
| 146 | + steps: |
| 147 | + - name: Download perf metrics |
| 148 | + uses: actions/download-artifact@v6 |
| 149 | + continue-on-error: true |
| 150 | + with: |
| 151 | + name: allure-perf-metrics |
| 152 | + path: ./allure-perf-metrics |
| 153 | + - name: Comment perf metrics on pull request |
| 154 | + uses: actions/github-script@v9 |
| 155 | + with: |
| 156 | + script: | |
| 157 | + const fs = require("node:fs"); |
| 158 | + const marker = "<!-- allure-perf-metrics -->"; |
| 159 | + const summaryPath = "./allure-perf-metrics/allure-perf-metrics.md"; |
| 160 | + const { owner, repo } = context.repo; |
| 161 | + const artifactsUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`; |
| 162 | + const summary = fs.existsSync(summaryPath) ? fs.readFileSync(summaryPath, "utf8") : "### Allure perf metrics\n\nMetrics file was not generated.\n"; |
| 163 | + const body = `${marker}\n${summary}\nArtifacts: [allure-perf-metrics](${artifactsUrl})`; |
| 164 | + const issue_number = context.payload.pull_request.number; |
| 165 | + const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 }); |
| 166 | + const previous = comments.data.find((comment) => comment.user.type === "Bot" && comment.body?.includes(marker)); |
| 167 | +
|
| 168 | + if (previous) { |
| 169 | + await github.rest.issues.updateComment({ owner, repo, comment_id: previous.id, body }); |
| 170 | + } else { |
| 171 | + await github.rest.issues.createComment({ owner, repo, issue_number, body }); |
| 172 | + } |
0 commit comments