Skip to content

Commit 6d89c79

Browse files
committed
Sync auto-copilot-org-playwright-loopv2.yaml from .github repo
1 parent 5b67f0f commit 6d89c79

File tree

1 file changed

+116
-90
lines changed

1 file changed

+116
-90
lines changed
Lines changed: 116 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,150 @@
11
name: "Org-wide: Copilot Playwright Test, Review, Auto-fix, PR, Merge"
2-
uto-amazonq-review.properties.json
32

4-
uto-amazonq-review.properties.json
53
on:
6-
uto-amazonq-review.properties.json
74
push:
8-
uto-amazonq-review.properties.json
95
branches:
10-
uto-amazonq-review.properties.json
116
- main
12-
uto-amazonq-review.properties.json
137
- master
14-
uto-amazonq-review.properties.json
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
issues: write
14+
actions: read
1515

16-
uto-amazonq-review.properties.json
1716
jobs:
18-
uto-amazonq-review.properties.json
1917
playwright-review-fix:
20-
uto-amazonq-review.properties.json
21-
runs-on: self-hosted
22-
uto-amazonq-review.properties.json
18+
runs-on: ubuntu-latest
2319
steps:
24-
uto-amazonq-review.properties.json
2520
- name: Checkout code
26-
uto-amazonq-review.properties.json
27-
uses: actions/checkout@main
28-
uto-amazonq-review.properties.json
21+
uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
2924

30-
uto-amazonq-review.properties.json
3125
- name: Setup Python
32-
uto-amazonq-review.properties.json
33-
uses: actions/setup-python@main
34-
uto-amazonq-review.properties.json
26+
uses: actions/setup-python@v5
3527
with:
36-
uto-amazonq-review.properties.json
3728
python-version: "3.11"
38-
uto-amazonq-review.properties.json
3929

40-
uto-amazonq-review.properties.json
30+
- name: Check for requirements.txt
31+
id: check-requirements
32+
run: |
33+
if [ -f "requirements.txt" ]; then
34+
echo "requirements_exists=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "requirements_exists=false" >> $GITHUB_OUTPUT
37+
echo "No requirements.txt found, skipping dependency installation"
38+
fi
39+
4140
- name: Install dependencies
42-
uto-amazonq-review.properties.json
41+
if: steps.check-requirements.outputs.requirements_exists == 'true'
4342
run: |
44-
uto-amazonq-review.properties.json
4543
pip install -r requirements.txt
46-
uto-amazonq-review.properties.json
44+
continue-on-error: true
45+
46+
- name: Install Playwright and testing dependencies
47+
run: |
4748
pip install pytest playwright pytest-playwright
48-
uto-amazonq-review.properties.json
49+
continue-on-error: true
4950

50-
uto-amazonq-review.properties.json
5151
- name: Install Playwright browsers
52-
uto-amazonq-review.properties.json
5352
run: |
54-
uto-amazonq-review.properties.json
55-
python -m playwright install
56-
uto-amazonq-review.properties.json
53+
python -m playwright install --with-deps
54+
continue-on-error: true
5755

58-
uto-amazonq-review.properties.json
59-
- name: Run Playwright Tests
60-
uto-amazonq-review.properties.json
56+
- name: Check for tests directory
57+
id: check-tests
6158
run: |
62-
uto-amazonq-review.properties.json
63-
pytest tests/ || exit 1
64-
uto-amazonq-review.properties.json
65-
continue-on-error: true
66-
uto-amazonq-review.properties.json
59+
if [ -d "tests" ] || [ -d "test" ] || find . -name "*test*.py" -type f | head -1 | grep -q .; then
60+
echo "tests_exist=true" >> $GITHUB_OUTPUT
61+
echo "Tests found, proceeding with test execution"
62+
else
63+
echo "tests_exist=false" >> $GITHUB_OUTPUT
64+
echo "No tests found, skipping test execution"
65+
fi
6766
68-
uto-amazonq-review.properties.json
69-
- name: Copilot PR Agent Review
70-
uto-amazonq-review.properties.json
71-
uses: github/copilot-agent/pr@main
72-
uto-amazonq-review.properties.json
73-
with:
74-
uto-amazonq-review.properties.json
75-
github-token: ${{ secrets.GITHUB_TOKEN }}
76-
uto-amazonq-review.properties.json
67+
- name: Run Playwright Tests
68+
if: steps.check-tests.outputs.tests_exist == 'true'
69+
run: |
70+
# Try different test directory patterns
71+
if [ -d "tests" ]; then
72+
pytest tests/ -v --tb=short
73+
elif [ -d "test" ]; then
74+
pytest test/ -v --tb=short
75+
else
76+
pytest . -k "test" -v --tb=short
77+
fi
7778
continue-on-error: true
78-
uto-amazonq-review.properties.json
7979

80-
uto-amazonq-review.properties.json
81-
- name: Copilot Auto-fix Failing Playwright Tests
82-
uto-amazonq-review.properties.json
83-
uses: github/copilot-agent/fix@main
84-
uto-amazonq-review.properties.json
85-
with:
86-
uto-amazonq-review.properties.json
87-
github-token: ${{ secrets.GITHUB_TOKEN }}
88-
uto-amazonq-review.properties.json
89-
max_attempts: 3
90-
uto-amazonq-review.properties.json
80+
- name: Generate test report
81+
if: steps.check-tests.outputs.tests_exist == 'true'
82+
run: |
83+
echo "## Test Results" >> test_report.md
84+
echo "Playwright tests have been executed." >> test_report.md
85+
echo "Check the logs above for detailed results." >> test_report.md
9186
continue-on-error: true
92-
uto-amazonq-review.properties.json
9387

94-
uto-amazonq-review.properties.json
95-
- name: Create Pull Request for Automated Fixes
96-
uto-amazonq-review.properties.json
97-
uses: peter-evans/create-pull-request@main
98-
uto-amazonq-review.properties.json
88+
- name: Create Issue for Test Failures
89+
if: failure() && steps.check-tests.outputs.tests_exist == 'true'
90+
uses: actions/github-script@v7
9991
with:
100-
uto-amazonq-review.properties.json
101-
branch: "copilot/playwright-fixes"
102-
uto-amazonq-review.properties.json
103-
title: "Copilot: Auto-fix Playwright Tests"
104-
uto-amazonq-review.properties.json
105-
body: "Automated Playwright test fixes by Copilot Agent."
106-
uto-amazonq-review.properties.json
107-
commit-message: "Copilot agent Playwright bugfixes"
108-
uto-amazonq-review.properties.json
92+
github-token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
93+
script: |
94+
const title = `Playwright Tests Failed - ${new Date().toISOString().split('T')[0]}`;
95+
const body = `
96+
## Playwright Test Failure Report
97+
98+
**Repository:** ${{ github.repository }}
99+
**Branch:** ${{ github.ref_name }}
100+
**Commit:** ${{ github.sha }}
101+
**Workflow Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
102+
103+
The automated Playwright tests have failed. Please review the workflow logs for details.
104+
105+
### Next Steps:
106+
1. Review the test failures in the workflow logs
107+
2. Fix the failing tests locally
108+
3. Push the fixes to trigger a new test run
109+
110+
This issue was automatically created by the Playwright testing workflow.
111+
`;
112+
113+
// Check if similar issue already exists
114+
const issues = await github.rest.issues.listForRepo({
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
state: 'open',
118+
labels: ['playwright-failure', 'automated']
119+
});
120+
121+
const existingIssue = issues.data.find(issue =>
122+
issue.title.includes('Playwright Tests Failed') &&
123+
issue.created_at > new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
124+
);
125+
126+
if (!existingIssue) {
127+
await github.rest.issues.create({
128+
owner: context.repo.owner,
129+
repo: context.repo.repo,
130+
title: title,
131+
body: body,
132+
labels: ['playwright-failure', 'automated', 'bug']
133+
});
134+
}
109135
continue-on-error: true
110-
uto-amazonq-review.properties.json
111136

112-
uto-amazonq-review.properties.json
113-
- name: Automerge PR if checks pass
114-
uto-amazonq-review.properties.json
115-
uses: pascalgn/automerge-action@main
116-
uto-amazonq-review.properties.json
117-
with:
118-
uto-amazonq-review.properties.json
119-
merge-method: squash
120-
uto-amazonq-review.properties.json
121-
github-token: ${{ secrets.GITHUB_TOKEN }}
122-
uto-amazonq-review.properties.json
123-
continue-on-error: true
124-
uto-amazonq-review.properties.json
137+
- name: Summary
138+
run: |
139+
echo "## Playwright Workflow Summary" >> $GITHUB_STEP_SUMMARY
140+
echo "" >> $GITHUB_STEP_SUMMARY
141+
echo "**Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
142+
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
143+
echo "**Requirements found:** ${{ steps.check-requirements.outputs.requirements_exists }}" >> $GITHUB_STEP_SUMMARY
144+
echo "**Tests found:** ${{ steps.check-tests.outputs.tests_exist }}" >> $GITHUB_STEP_SUMMARY
145+
echo "" >> $GITHUB_STEP_SUMMARY
146+
if [ "${{ steps.check-tests.outputs.tests_exist }}" = "true" ]; then
147+
echo "✅ Playwright tests were executed. Check logs for results." >> $GITHUB_STEP_SUMMARY
148+
else
149+
echo "ℹ️ No tests found - workflow completed successfully without test execution." >> $GITHUB_STEP_SUMMARY
150+
fi

0 commit comments

Comments
 (0)