mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(devops): pass pr number in a file (#23456)
For some reason pull_requests field on workflow_run is empty for pull requests created from branches in forked repositories, see https://github.com/orgs/community/discussions/25220. As a workaround we store triggering pull request number in a file.
This commit is contained in:
parent
b99c214b29
commit
2719f408b2
24
.github/workflows/create_test_report.yml
vendored
24
.github/workflows/create_test_report.yml
vendored
@ -30,6 +30,13 @@ jobs:
|
|||||||
name: 'blob-report-${{ github.event.workflow_run.run_attempt }}'
|
name: 'blob-report-${{ github.event.workflow_run.run_attempt }}'
|
||||||
path: 'blob-report'
|
path: 'blob-report'
|
||||||
|
|
||||||
|
- name: Read pull request number
|
||||||
|
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
|
||||||
|
uses: ./.github/actions/download-artifact
|
||||||
|
with:
|
||||||
|
name: 'pull-request'
|
||||||
|
path: './'
|
||||||
|
|
||||||
- name: Download blob report from Azure
|
- name: Download blob report from Azure
|
||||||
if: ${{ always() && github.event.workflow_run.event == 'push' }}
|
if: ${{ always() && github.event.workflow_run.event == 'push' }}
|
||||||
uses: ./.github/actions/download-blob-report-from-azure
|
uses: ./.github/actions/download-blob-report-from-azure
|
||||||
@ -59,20 +66,27 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
let prs = [];
|
let prNumber;
|
||||||
if (context.payload.workflow_run.event === 'pull_request') {
|
if (context.payload.workflow_run.event === 'pull_request') {
|
||||||
prs = context.payload.workflow_run.pull_requests;
|
const prs = context.payload.workflow_run.pull_requests;
|
||||||
|
if (prs.length) {
|
||||||
|
prNumber = prs[0].number;
|
||||||
|
} else {
|
||||||
|
const fs = require('fs');
|
||||||
|
prNumber = parseInt(fs.readFileSync('pull_request_number.txt').toString());
|
||||||
|
console.log('Read pull request number from file: ' + prNumber);
|
||||||
|
}
|
||||||
} else if (context.payload.workflow_run.event === 'push') {
|
} else if (context.payload.workflow_run.event === 'push') {
|
||||||
const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
commit_sha: context.sha,
|
commit_sha: context.sha,
|
||||||
});
|
});
|
||||||
prs = data;
|
prNumber = data[0].number;
|
||||||
} else {
|
} else {
|
||||||
core.error('Unsupported workflow trigger event: ' + context.payload.workflow_run.event);
|
core.error('Unsupported workflow trigger event: ' + context.payload.workflow_run.event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prs.length === 0) {
|
if (!prNumber) {
|
||||||
core.error('No pull request found for commit ' + context.sha + ' and workflow triggered by: ' + context.payload.workflow_run.event);
|
core.error('No pull request found for commit ' + context.sha + ' and workflow triggered by: ' + context.payload.workflow_run.event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,7 +95,7 @@ jobs:
|
|||||||
core.notice('Report url: ' + reportUrl);
|
core.notice('Report url: ' + reportUrl);
|
||||||
const { data: response } = await github.rest.issues.createComment({
|
const { data: response } = await github.rest.issues.createComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
issue_number: prs[0].number,
|
issue_number: prNumber,
|
||||||
body: `"${{ github.event.workflow_run.name }}" [report](${reportUrl}).`,
|
body: `"${{ github.event.workflow_run.name }}" [report](${reportUrl}).`,
|
||||||
});
|
});
|
||||||
core.info('Posted comment: ' + response.html_url);
|
core.info('Posted comment: ' + response.html_url);
|
||||||
|
18
.github/workflows/tests_primary.yml
vendored
18
.github/workflows/tests_primary.yml
vendored
@ -71,6 +71,15 @@ jobs:
|
|||||||
name: blob-report-${{ github.run_attempt }}
|
name: blob-report-${{ github.run_attempt }}
|
||||||
path: test-results/blob-report
|
path: test-results/blob-report
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
- name: Write the pull request number in an file
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
run: echo '${{ github.event.number }}' > pull_request_number.txt;
|
||||||
|
- name: Upload artifact with pull request number
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
with:
|
||||||
|
name: pull-request
|
||||||
|
path: pull_request_number.txt
|
||||||
|
|
||||||
test_linux_chromium_tot:
|
test_linux_chromium_tot:
|
||||||
name: ${{ matrix.os }} (chromium tip-of-tree)
|
name: ${{ matrix.os }} (chromium tip-of-tree)
|
||||||
@ -152,6 +161,15 @@ jobs:
|
|||||||
name: blob-report-${{ github.run_attempt }}
|
name: blob-report-${{ github.run_attempt }}
|
||||||
path: test-results/blob-report
|
path: test-results/blob-report
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
- name: Write the pull request number in an file
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
run: echo '${{ github.event.number }}' > pull_request_number.txt;
|
||||||
|
- name: Upload artifact with pull request number
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
with:
|
||||||
|
name: pull-request
|
||||||
|
path: pull_request_number.txt
|
||||||
|
|
||||||
test_web_components:
|
test_web_components:
|
||||||
name: Web Components
|
name: Web Components
|
||||||
|
9
.github/workflows/tests_secondary.yml
vendored
9
.github/workflows/tests_secondary.yml
vendored
@ -218,6 +218,15 @@ jobs:
|
|||||||
name: blob-report-${{ github.run_attempt }}
|
name: blob-report-${{ github.run_attempt }}
|
||||||
path: test-results/blob-report
|
path: test-results/blob-report
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
- name: Write the pull request number in an file
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
run: echo '${{ github.event.number }}' > pull_request_number.txt;
|
||||||
|
- name: Upload artifact with pull request number
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always() && github.event_name == 'pull_request'
|
||||||
|
with:
|
||||||
|
name: pull-request
|
||||||
|
path: pull_request_number.txt
|
||||||
|
|
||||||
chrome_stable_linux:
|
chrome_stable_linux:
|
||||||
name: "Chrome Stable (Linux)"
|
name: "Chrome Stable (Linux)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user