From 675dddcb55b7db77c26fc97b508615458a782740 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 14 Aug 2025 12:28:24 +0200 Subject: [PATCH] [CI] Update the action that creates issues on e2e errors --- .github/workflows/end_to_end_tests.yaml | 81 ++++++++++++++++++------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/.github/workflows/end_to_end_tests.yaml b/.github/workflows/end_to_end_tests.yaml index b41eb412d..c12422c2e 100644 --- a/.github/workflows/end_to_end_tests.yaml +++ b/.github/workflows/end_to_end_tests.yaml @@ -94,7 +94,7 @@ jobs: symfony server:stop notify-on-failure: - if: failure() + if: ${{ always() && contains(needs.*.result, 'failure') }} name: Notify on Failure needs: [test-symfony-cli-installation, test-composer-create-project, test-git-clone-installation] runs-on: ubuntu-latest @@ -105,28 +105,63 @@ jobs: steps: - name: Create Issue on Failure uses: actions/github-script@v7 + env: + NEEDS_CONTEXT: ${{ toJSON(needs) }} with: script: | - const title = `End to End Test Failed - ${new Date().toISOString().split('T')[0]}`; - const body = `The daily end to end test workflow has failed. - - This means users may be experiencing issues installing the Symfony Demo application. - - **Failed Jobs:** - - Check the workflow run for details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - - **Installation Methods Tested:** - - Symfony CLI installation - - Composer create-project - - Git clone + composer install - - Please investigate and fix the installation issues as soon as possible. - `; - - github.rest.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: title, - body: body, - labels: ['bug'] + const needsContext = JSON.parse(process.env.NEEDS_CONTEXT); + + // Map job ids to human-readable names used in the workflow UI + const jobNames = { + 'test-symfony-cli-installation': 'Test Symfony CLI Installation', + 'test-composer-create-project': 'Test Composer Create Project', + 'test-git-clone-installation': 'Test Git Clone Installation', + }; + + const failedJobs = Object.entries(needsContext) + .filter(([, v]) => v.result === 'failure') + .map(([id]) => `- **${jobNames[id] || id}**: failed`); + + const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; + const date = new Date().toISOString().split('T')[0]; + const title = `E2E Test Failure: ${date}`; + + const body = [ + 'The daily end-to-end test workflow has failed.', + '', + 'This may indicate users are experiencing issues installing the Symfony Demo application.', + '', + `**Run**: ${runUrl}`, + '', + '### Failed Jobs', + failedJobs.join('\n'), + '', + 'Please investigate and fix the installation issues as soon as possible.' + ].join('\n'); + + // Ensure label exists + const owner = context.repo.owner; + const repo = context.repo.repo; + const labelName = 'bug'; + try { + await github.rest.issues.getLabel({ owner, repo, name: labelName }); + } catch { + await github.rest.issues.createLabel({ + owner, repo, name: labelName, color: 'd73a4a', description: 'Something is broken' + }); + } + + // Reuse an open issue for today if it already exists to avoid duplicates + const { data: issues } = await github.rest.issues.listForRepo({ + owner, repo, state: 'open', labels: labelName, per_page: 100 }); + const existing = issues.find(i => i.title === title); + + if (existing) { + await github.rest.issues.createComment({ + owner, repo, issue_number: existing.number, + body: `Another failing run detected.\n\n${body}` + }); + } else { + await github.rest.issues.create({ owner, repo, title, body, labels: [labelName] }); + }