devops: post merged report URL to the PR (#23266)

Posting a comment to the PR using GITHUB_TOKEN requires elevated
permissions, see
https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
This commit is contained in:
Yury Semikhatsky 2023-05-24 14:43:36 -07:00 committed by GitHub
parent 70589c0113
commit 0a65a0b8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 0 deletions

View File

@ -64,6 +64,8 @@ jobs:
merge_test_linux: merge_test_linux:
if: ${{ always() && github.event_name != 'pull_request' }} if: ${{ always() && github.event_name != 'pull_request' }}
permissions:
pull-requests: write
needs: [test_linux] needs: [test_linux]
timeout-minutes: 10 timeout-minutes: 10
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -87,6 +89,27 @@ jobs:
run: | run: |
az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-test_linux' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}" az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-test_linux' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-test_linux/index.html" echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-test_linux/index.html"
- name: Comment on PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
...context.repo,
commit_sha: context.sha,
});
if (prs.length === 0) {
core.error('No pull request found for commit ' + context.sha);
return;
}
const reportUrl = `https://mspwblobreport.z1.web.core.windows.net/run-${context.runId}-${context.sha}-test_linux/index.html`;
core.notice('Report url: ' + reportUrl);
const { data: response } = await github.rest.issues.createComment({
...context.repo,
issue_number: prs[0].number,
body: 'Primary test results: ' + reportUrl,
});
core.info('Posted comment: ' + response.html_url);
test_linux_chromium_tot: test_linux_chromium_tot:
name: ${{ matrix.os }} (chromium tip-of-tree) name: ${{ matrix.os }} (chromium tip-of-tree)
@ -158,6 +181,8 @@ jobs:
merge_test_test_runner: merge_test_test_runner:
if: ${{ always() && github.event_name != 'pull_request' }} if: ${{ always() && github.event_name != 'pull_request' }}
permissions:
pull-requests: write
needs: [test_test_runner] needs: [test_test_runner]
timeout-minutes: 10 timeout-minutes: 10
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -181,6 +206,27 @@ jobs:
run: | run: |
az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-test_test_runner' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}" az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-test_test_runner' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-test_test_runner/index.html" echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-test_test_runner/index.html"
- name: Comment on PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
...context.repo,
commit_sha: context.sha,
});
if (prs.length === 0) {
core.error('No pull request found for commit ' + context.sha);
return;
}
const reportUrl = `https://mspwblobreport.z1.web.core.windows.net/run-${context.runId}-${context.sha}-test_test_runner/index.html`;
core.notice('Report url: ' + reportUrl);
const { data: response } = await github.rest.issues.createComment({
...context.repo,
issue_number: prs[0].number,
body: 'Test Runner test results: ' + reportUrl,
});
core.info('Posted comment: ' + response.html_url);
test_web_components: test_web_components:
name: Web Components name: Web Components

View File

@ -214,6 +214,8 @@ jobs:
merge_tracing_linux: merge_tracing_linux:
if: ${{ always() && github.event_name != 'pull_request' }} if: ${{ always() && github.event_name != 'pull_request' }}
permissions:
pull-requests: write
needs: [tracing_linux] needs: [tracing_linux]
timeout-minutes: 10 timeout-minutes: 10
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -237,6 +239,27 @@ jobs:
run: | run: |
az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-tracing_linux' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}" az storage blob upload-batch -s playwright-report -d '$web/run-${{ github.run_id }}-${{ github.sha }}-tracing_linux' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-tracing_linux/index.html" echo "Report url: https://mspwblobreport.z1.web.core.windows.net/run-${{ github.run_id }}-${{ github.sha }}-tracing_linux/index.html"
- name: Comment on PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
...context.repo,
commit_sha: context.sha,
});
if (prs.length === 0) {
core.error('No pull request found for commit ' + context.sha);
return;
}
const reportUrl = `https://mspwblobreport.z1.web.core.windows.net/run-${context.runId}-${context.sha}-tracing_linux/index.html`;
core.notice('Report url: ' + reportUrl);
const { data: response } = await github.rest.issues.createComment({
...context.repo,
issue_number: prs[0].number,
body: 'Tracing test results: ' + reportUrl,
});
core.info('Posted comment: ' + response.html_url);
chrome_stable_linux: chrome_stable_linux:
name: "Chrome Stable (Linux)" name: "Chrome Stable (Linux)"