Skip to content

Commit 965faad

Browse files
committed
Sync auto-copilot-org-playwright-loopv2.yml from .github repo
1 parent dbdfcb1 commit 965faad

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: "Org-wide: Copilot Playwright Test, Review, Auto-fix, PR, Merge"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
issues: write
14+
actions: read
15+
16+
jobs:
17+
playwright-review-fix:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Check for requirements.txt
29+
id: check-requirements
30+
run: |
31+
if [ -f "requirements.txt" ]; then
32+
echo "requirements_exists=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "requirements_exists=false" >> $GITHUB_OUTPUT
35+
echo "No requirements.txt found, skipping dependency installation"
36+
fi
37+
38+
- name: Install dependencies
39+
if: steps.check-requirements.outputs.requirements_exists == 'true'
40+
run: |
41+
pip install -r requirements.txt
42+
continue-on-error: true
43+
44+
- name: Install Playwright and testing dependencies
45+
run: |
46+
pip install pytest playwright pytest-playwright
47+
continue-on-error: true
48+
49+
- name: Install Playwright browsers
50+
run: |
51+
python -m playwright install --with-deps
52+
continue-on-error: true
53+
54+
- name: Check for tests directory
55+
id: check-tests
56+
run: |
57+
if [ -d "tests" ] || [ -d "test" ] || find . -name "*test*.py" -type f | head -1 | grep -q .; then
58+
echo "tests_exist=true" >> $GITHUB_OUTPUT
59+
echo "Tests found, proceeding with test execution"
60+
else
61+
echo "tests_exist=false" >> $GITHUB_OUTPUT
62+
echo "No tests found, skipping test execution"
63+
fi
64+
65+
- name: Run Playwright Tests
66+
if: steps.check-tests.outputs.tests_exist == 'true'
67+
run: |
68+
# Try different test directory patterns
69+
if [ -d "tests" ]; then
70+
pytest tests/ -v --tb=short
71+
elif [ -d "test" ]; then
72+
pytest test/ -v --tb=short
73+
else
74+
pytest . -k "test" -v --tb=short
75+
fi
76+
continue-on-error: true
77+
78+
- name: Generate test report
79+
if: steps.check-tests.outputs.tests_exist == 'true'
80+
run: |
81+
echo "## Test Results" >> test_report.md
82+
echo "Playwright tests have been executed." >> test_report.md
83+
echo "Check the logs above for detailed results." >> test_report.md
84+
continue-on-error: true
85+
86+
- name: Create Issue for Test Failures
87+
if: failure() && steps.check-tests.outputs.tests_exist == 'true'
88+
uses: actions/github-script@v7
89+
with:
90+
github-token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
91+
script: |
92+
const title = `Playwright Tests Failed - ${new Date().toISOString().split('T')[0]}`;
93+
const body = `
94+
## Playwright Test Failure Report
95+
96+
**Repository:** ${{ github.repository }}
97+
**Branch:** ${{ github.ref_name }}
98+
**Commit:** ${{ github.sha }}
99+
**Workflow Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
100+
101+
The automated Playwright tests have failed. Please review the workflow logs for details.
102+
103+
### Next Steps:
104+
1. Review the test failures in the workflow logs
105+
2. Fix the failing tests locally
106+
3. Push the fixes to trigger a new test run
107+
108+
This issue was automatically created by the Playwright testing workflow.
109+
`;
110+
111+
// Check if similar issue already exists
112+
const issues = await github.rest.issues.listForRepo({
113+
owner: context.repo.owner,
114+
repo: context.repo.repo,
115+
state: 'open',
116+
labels: ['playwright-failure', 'automated']
117+
});
118+
119+
const existingIssue = issues.data.find(issue =>
120+
issue.title.includes('Playwright Tests Failed') &&
121+
issue.created_at > new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
122+
);
123+
124+
if (!existingIssue) {
125+
await github.rest.issues.create({
126+
owner: context.repo.owner,
127+
repo: context.repo.repo,
128+
title: title,
129+
body: body,
130+
labels: ['playwright-failure', 'automated', 'bug']
131+
});
132+
}
133+
continue-on-error: true
134+
135+
- name: Summary
136+
run: |
137+
echo "## Playwright Workflow Summary" >> $GITHUB_STEP_SUMMARY
138+
echo "" >> $GITHUB_STEP_SUMMARY
139+
echo "**Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
140+
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
141+
echo "**Requirements found:** ${{ steps.check-requirements.outputs.requirements_exists }}" >> $GITHUB_STEP_SUMMARY
142+
echo "**Tests found:** ${{ steps.check-tests.outputs.tests_exist }}" >> $GITHUB_STEP_SUMMARY
143+
echo "" >> $GITHUB_STEP_SUMMARY
144+
if [ "${{ steps.check-tests.outputs.tests_exist }}" = "true" ]; then
145+
echo "✅ Playwright tests were executed. Check logs for results." >> $GITHUB_STEP_SUMMARY
146+
else
147+
echo "ℹ️ No tests found - workflow completed successfully without test execution." >> $GITHUB_STEP_SUMMARY
148+
fi

0 commit comments

Comments
 (0)