Repository navigation
132 lines (126 loc) · 6.08 KB
/
Copy pathrevision.yml
File metadata and controls
132 lines (126 loc) · 6.08 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Copilot addresses the maintainers' review comments on a draft PR that the triage workflow opened,
# without write credentials. A fresh job pushes the new commit to the PR's branch using the app, so
# CI runs on it. The steps that are the same for every Playwright repo are actions in
# microsoft/playwright, and the shared guide they carry says how to revise; the prompt below has
# what is specific to this repo.
name: PR revision
on:
# Apply needs-revision, needs-revision-mac or needs-revision-win; re-apply it to trigger another pass.
# pull_request_target always runs this file from main; the jobs only accept the triage app's own PRs.
pull_request_target:
types: [labeled]
permissions: {}
jobs:
prepare:
name: Collect the maintainers' comments
if: >-
github.repository == 'microsoft/playwright-python' &&
contains(fromJSON('["needs-revision","needs-revision-mac","needs-revision-win"]'), github.event.label.name) &&
github.event.pull_request.state == 'open' &&
github.event.pull_request.user.login == 'microsoft-playwright-automation[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
PLATFORM: ${{ fromJSON('{"needs-revision":"linux","needs-revision-mac":"mac","needs-revision-win":"windows"}')[github.event.label.name] }}
outputs:
head: ${{ steps.collect.outputs.head }}
base: ${{ steps.collect.outputs.base }}
branch: ${{ steps.collect.outputs.branch }}
platform: ${{ env.PLATFORM }}
steps:
- name: Collect the PR and the maintainers' comments
id: collect
uses: microsoft/playwright/.github/actions/collect-review@main
with:
pull-request: ${{ github.event.pull_request.number }}
- name: Post the run link
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
PLATFORM_NAME: ${{ fromJSON('{"linux":"Linux","mac":"macOS","windows":"Windows"}')[env.PLATFORM] }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
body=$(printf "Hi, I'm the Playwright bot. I started to address the review comments on %s: [agent run](%s)\n<!-- playwright-revision-started -->" "$PLATFORM_NAME" "$RUN_URL")
gh pr comment "$PR" --body "$body" || echo "::warning::Could not post the run link"
revise:
name: Revise PR ${{ github.event.pull_request.number }} (${{ needs.prepare.outputs.platform }})
needs: prepare
runs-on: ${{ fromJSON('{"linux":"playwright-x64-ubuntu24-64-core","mac":"macos-15-xlarge","windows":"playwright-x64-server2025-64-core"}')[needs.prepare.outputs.platform] }}
timeout-minutes: 240
concurrency:
group: revision-${{ github.event.pull_request.number }}
cancel-in-progress: false
defaults:
run:
shell: bash
env:
PR: ${{ github.event.pull_request.number }}
HEAD_SHA: ${{ needs.prepare.outputs.head }}
BASE_SHA: ${{ needs.prepare.outputs.base }}
TRIAGE_PLATFORM: ${{ needs.prepare.outputs.platform }}
permissions:
copilot-requests: write
outputs:
has_revision: ${{ steps.agent.outputs.has-result }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.head }}
persist-credentials: false
- name: Fetch the base and record the directories
run: |
git fetch --no-tags --depth=1 origin "$BASE_SHA"
echo "OUTPUT_DIR=${RUNNER_TEMP//\\//}/revision" >> "$GITHUB_ENV"
echo "REVIEW_DIR=${RUNNER_TEMP//\\//}/review" >> "$GITHUB_ENV"
echo "SCRATCH_DIR=${RUNNER_TEMP//\\//}/scratch" >> "$GITHUB_ENV"
echo "REPO_DIR=${GITHUB_WORKSPACE//\\//}" >> "$GITHUB_ENV"
mkdir -p "${RUNNER_TEMP//\\//}/revision" "${RUNNER_TEMP//\\//}/scratch"
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: review
path: ${{ runner.temp }}/review
- name: Set up the runner
uses: ./.github/actions/setup-triage-runner
- name: Revise with Copilot CLI
id: agent
# No GitHub tools and no URL access: the agent reads the PR only from the review the prepare job filtered.
uses: microsoft/playwright/.github/actions/run-agent@main
with:
prompt: |
Follow the shared guide revision.md and this repo's AGENTS.md. Read both in full before starting. $PLAYWRIGHT_DIR is the .upstream/ checkout of microsoft/playwright at the commit in DRIVER_VERSION; do not edit, commit or switch branches in it.
Pull request: https://github.com/microsoft/playwright-python/pull/${{ github.event.pull_request.number }}
output-dir: ${{ env.OUTPUT_DIR }}
result-file: commit/commit.json
artifact-name: revision
exec: ${{ env.CI_ENV_EXEC }}
push:
name: Push the revision
needs: [prepare, revise]
# commit.json is written last, so a finished revision is pushed even when the job failed later.
if: ${{ !cancelled() && needs.revise.outputs.has_revision == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
id: app-token
with:
app-id: ${{ vars.PLAYWRIGHT_APP_ID }}
private-key: ${{ secrets.PLAYWRIGHT_PRIVATE_KEY }}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.prepare.outputs.head }}
token: ${{ steps.app-token.outputs.token }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: revision
path: ${{ runner.temp }}/revision
# Never execute code or scripts from the proposed changes in the app job.
- name: Validate and push
uses: microsoft/playwright/.github/actions/publish-patch@main
with:
token: ${{ steps.app-token.outputs.token }}
dir: ${{ runner.temp }}/revision/commit
patch: revision.patch
metadata: commit.json
branch: ${{ needs.prepare.outputs.branch }}