Skip to content

Commit a9c9dde

Browse files
committed
minor #1593 [CI] Update the action that creates issues on e2e errors (javiereguiluz)
This PR was squashed before being merged into the main branch. Discussion ---------- [CI] Update the action that creates issues on e2e errors This continues #1590 to update the action that creates issues on CI errors. The `rm -v ...` line was added on purpose to force an error to check that this is working. This was done entirely with AI. Commits ------- 675dddc [CI] Update the action that creates issues on e2e errors
2 parents c8ed0b6 + 675dddc commit a9c9dde

File tree

1 file changed

+58
-23
lines changed

1 file changed

+58
-23
lines changed

.github/workflows/end_to_end_tests.yaml

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
symfony server:stop
9595
9696
notify-on-failure:
97-
if: failure()
97+
if: ${{ always() && contains(needs.*.result, 'failure') }}
9898
name: Notify on Failure
9999
needs: [test-symfony-cli-installation, test-composer-create-project, test-git-clone-installation]
100100
runs-on: ubuntu-latest
@@ -105,28 +105,63 @@ jobs:
105105
steps:
106106
- name: Create Issue on Failure
107107
uses: actions/github-script@v7
108+
env:
109+
NEEDS_CONTEXT: ${{ toJSON(needs) }}
108110
with:
109111
script: |
110-
const title = `End to End Test Failed - ${new Date().toISOString().split('T')[0]}`;
111-
const body = `The daily end to end test workflow has failed.
112-
113-
This means users may be experiencing issues installing the Symfony Demo application.
114-
115-
**Failed Jobs:**
116-
- Check the workflow run for details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
117-
118-
**Installation Methods Tested:**
119-
- Symfony CLI installation
120-
- Composer create-project
121-
- Git clone + composer install
122-
123-
Please investigate and fix the installation issues as soon as possible.
124-
`;
125-
126-
github.rest.issues.create({
127-
owner: context.repo.owner,
128-
repo: context.repo.repo,
129-
title: title,
130-
body: body,
131-
labels: ['bug']
112+
const needsContext = JSON.parse(process.env.NEEDS_CONTEXT);
113+
114+
// Map job ids to human-readable names used in the workflow UI
115+
const jobNames = {
116+
'test-symfony-cli-installation': 'Test Symfony CLI Installation',
117+
'test-composer-create-project': 'Test Composer Create Project',
118+
'test-git-clone-installation': 'Test Git Clone Installation',
119+
};
120+
121+
const failedJobs = Object.entries(needsContext)
122+
.filter(([, v]) => v.result === 'failure')
123+
.map(([id]) => `- **${jobNames[id] || id}**: failed`);
124+
125+
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
126+
const date = new Date().toISOString().split('T')[0];
127+
const title = `E2E Test Failure: ${date}`;
128+
129+
const body = [
130+
'The daily end-to-end test workflow has failed.',
131+
'',
132+
'This may indicate users are experiencing issues installing the Symfony Demo application.',
133+
'',
134+
`**Run**: ${runUrl}`,
135+
'',
136+
'### Failed Jobs',
137+
failedJobs.join('\n'),
138+
'',
139+
'Please investigate and fix the installation issues as soon as possible.'
140+
].join('\n');
141+
142+
// Ensure label exists
143+
const owner = context.repo.owner;
144+
const repo = context.repo.repo;
145+
const labelName = 'bug';
146+
try {
147+
await github.rest.issues.getLabel({ owner, repo, name: labelName });
148+
} catch {
149+
await github.rest.issues.createLabel({
150+
owner, repo, name: labelName, color: 'd73a4a', description: 'Something is broken'
151+
});
152+
}
153+
154+
// Reuse an open issue for today if it already exists to avoid duplicates
155+
const { data: issues } = await github.rest.issues.listForRepo({
156+
owner, repo, state: 'open', labels: labelName, per_page: 100
132157
});
158+
const existing = issues.find(i => i.title === title);
159+
160+
if (existing) {
161+
await github.rest.issues.createComment({
162+
owner, repo, issue_number: existing.number,
163+
body: `Another failing run detected.\n\n${body}`
164+
});
165+
} else {
166+
await github.rest.issues.create({ owner, repo, title, body, labels: [labelName] });
167+
}

0 commit comments

Comments
 (0)