From 30b39ee37f0217c70d0da718d274d0296ab52061 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 16 Sep 2026 14:40:08 +0200 Subject: [PATCH] release note now triggered after detector labels, removed no relaes note checkbox, also checking if its developing detector label only, then also release note not required, adding a fake ai assisted releae note if found locally, removing adding release notelabel --- .github/workflows/pr_edit_trigger.yaml | 22 +++---- .github/workflows/pr_release_notes.yaml | 88 ++++++++++++------------- 2 files changed, 53 insertions(+), 57 deletions(-) diff --git a/.github/workflows/pr_edit_trigger.yaml b/.github/workflows/pr_edit_trigger.yaml index 20e0d9ec0..fd847b133 100644 --- a/.github/workflows/pr_edit_trigger.yaml +++ b/.github/workflows/pr_edit_trigger.yaml @@ -1,4 +1,4 @@ -# This workflow is triggered when opening/reopening PR, editing the PR description or changing labels. It ignores unrelated label changes. It runs PR type validation and if it succeeds, it runs PR milestone and detector labels workflow in parallel. +# This workflow is triggered when opening/reopening PR, editing the PR description or changing labels. It ignores unrelated label changes. It runs PR type validation and if it succeeds, it runs PR milestone, release notes, file version and detector labels workflow in parallel. name: PR Edit Trigger on: @@ -110,16 +110,6 @@ jobs: pull-requests: write contents: read - release-notes: - needs: validate-pr-type - uses: ./.github/workflows/pr_release_notes.yaml - with: - pr_number: ${{ github.event.pull_request.number }} - permissions: - pull-requests: write - contents: read - issues: write - detector-labels: needs: validate-pr-type uses: ./.github/workflows/pr_detector_labels.yaml @@ -129,6 +119,16 @@ jobs: pull-requests: write issues: read + release-notes: + needs: detector-labels + uses: ./.github/workflows/pr_release_notes.yaml + with: + pr_number: ${{ github.event.pull_request.number }} + permissions: + pull-requests: write + contents: read + issues: write + file-version: needs: - check-pr-trigger diff --git a/.github/workflows/pr_release_notes.yaml b/.github/workflows/pr_release_notes.yaml index 49a843e60..4a8747ece 100644 --- a/.github/workflows/pr_release_notes.yaml +++ b/.github/workflows/pr_release_notes.yaml @@ -1,10 +1,9 @@ # This reusable workflow validates the PR release notes. It ignores comments and -#
blocks, checks for notes under the "## Release notes" section,. If -# release notes are not found and it is not an Infrastructure PR, it should find +#
blocks, checks for notes under the "## Release notes" section. If +# it is not an Infrastructure PR and release notes are not found, it should find # them in an equivalent PR or referenced PR, else validation fails. If it is an -# Infrastructure PR or release notes are not found in an equivalent or -# referenced PR, it should add label 'No Release Note'. -. +# Infrastructure PR and release notes are found, validation fails. If release # notes are found, it should add AI assisted notes as part of a details section. + name: PR Release Notes on: @@ -37,14 +36,13 @@ jobs: } /** - * Strips ignored content such as comments,
blocks - * and "No Release Note" checkbox from the given text. + * Strips ignored content such as comments and
blocks + * from the given text. */ const stripIgnoredContent = (text = '') => { return (text || '') .replace(//gs, '\n') .replace(//gi, '\n') - .replace(/\n\s*[-*]\s*\[[ xX]\]\s*No\s*Release\s*Note\s*\n/gi, '\n') .trim(); }; @@ -126,64 +124,66 @@ jobs: repo: context.repo.repo, issue_number: prNumber }); - const labelNames = labels.map(label => label.name); + const hasInfrastructure = labelNames.includes('Infrastructure'); + core.info('Infrastructure label present: ' + hasInfrastructure); + + /** check that it has only developing detector labels (Ctb, Xilinx Ctb, Matterhorn) and does not have Eiger, Mythen3, Gotthard2, Jungfrau, Moench labels */ + const developingDetectorLabels = ['Ctb', 'Xilinx Ctb', 'Matterhorn']; + const otherDetectorLabels = ['Eiger', 'Mythen3', 'Gotthard2', 'Jungfrau', 'Moench']; + const hasDevelopingDetectorLabel = labelNames.some( + label => developingDetectorLabels.includes(label) + ); + const hasOtherDetectorLabel = labelNames.some( + label => otherDetectorLabels.includes(label) + ); + const hasOnlyDevelopingDetectors = + hasDevelopingDetectorLabel && !hasOtherDetectorLabel; + core.info('Only developing detector labels present: ' + hasOnlyDevelopingDetectors); + const releaseNotes = findReleaseNotesSection(pr.body || ''); - const hasNoReleaseNoteLabel = labelNames.includes('No release note'); + core.info('Release notes found in current PR: ' + (releaseNotes ? 'Yes' : 'No')); - - if (releaseNotes) { - core.info(`Release notes found in the PR body: ${releaseNotes}`); - - if (hasNoReleaseNoteLabel) { + if (hasInfrastructure || hasOnlyDevelopingDetectors) { + if (releaseNotes) { core.setFailed( - 'The PR has a "## Release notes" section but is also labeled "No release note". Remove the label or remove the release notes section.' + 'Infrastructure PRs or only developing Detector PRs cannot include release notes. Remove the "## Release notes" section or change the PR type.' ); return; } - - if (hasInfrastructure) { - core.setFailed( - 'Infrastructure PRs cannot include release notes. Remove the "## Release notes" section or change the PR type.' - ); - return; - } - - core.info(`Confirm no further action required for release notes.`); return; } - core.info('No release notes found in the current PR body.'); /** - * Function to add the "No Release Note" label to the current PR. + * Add AI assisted release notes and return */ - const addNoReleaseNoteLabel = async () => { - await github.rest.issues.addLabels({ + if (releaseNotes) { + // Remove any existing details section with heading "AI Assisted Release Notes" + const updatedBody = pr.body.replace( + /(^|\n)#{1,6}\s*AI Assisted Release Notes\s*\n([\s\S]*?)(?=\n#{1,6}\s+\S|\s*$)/gi, + '' + ).trim(); + // Add a new section with heading "AI Assisted Release Notes" and placeholder text + const newBody = `${updatedBody}\n\n## AI Assisted Release Notes\n\n**This section will be populated with AI-assisted release notes.**\n\n`; + + await github.rest.pulls.update({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: prNumber, - labels: ['No Release Note'] + pull_number: prNumber, + body: newBody }); - - core.info('Added label: No Release Note'); - }; - - if (hasInfrastructure) { - await addNoReleaseNoteLabel(); - - core.info('Infrastructure PR with no release notes is permitted. Added label: No Release Note'); + core.info('AI Assisted Release Notes section added to PR body.'); return; } + /* Find release notes in equivalent or referenced PRs */ const equivalentAndReferencedPrNumbers = findReferencedPrNumbers(pr.body || ''); - for (const referencedPrNumber of equivalentAndReferencedPrNumbers) { if (referencedPrNumber === prNumber) { continue; } - try { const { data: referencedPr } = await github.rest.pulls.get({ @@ -191,16 +191,12 @@ jobs: repo: context.repo.repo, pull_number: referencedPrNumber }); - const referencedNotes = findReleaseNotesSection(referencedPr.body || ''); - if (referencedNotes) { core.info( - `Release notes found in equivalent/referenced PR #${referencedPrNumber}. ` + + `Release notes found: In equivalent/referenced PR #${referencedPrNumber}. ` + `Using that as the source for this PR.` ); - - await addNoReleaseNoteLabel(); return; } } catch (error) {