From 70d34add9bfba5f30c21ceeb0f8a9a562ce9cc5a Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Tue, 7 Jan 2025 11:54:17 +0100 Subject: [PATCH 1/2] Fixed returning of 0 where 1 is expected. --- .../release_notes_presence_check_action.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release_notes_presence_check/release_notes_presence_check_action.py b/release_notes_presence_check/release_notes_presence_check_action.py index a604ad9..d277b0f 100644 --- a/release_notes_presence_check/release_notes_presence_check_action.py +++ b/release_notes_presence_check/release_notes_presence_check_action.py @@ -70,12 +70,12 @@ def run(self) -> None: pr_body = pr_data.get("body", "") if len(pr_body.strip()) == 0: logger.error("Error: Pull request description is empty.") - sys.exit(0) + sys.exit(1) # Check if release notes tag is present if not re.search(self.title, pr_body): logger.error("Error: Release notes title '%s' not found in pull request body.", self.title) - sys.exit(0) + sys.exit(1) # Get line index of the release notes tag lines = pr_body.split("\n") From dac8eeca2e56d6787f09eb662b09acc49cabc6f9 Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Tue, 7 Jan 2025 11:56:34 +0100 Subject: [PATCH 2/2] Removed old script based solution of Release Notes check. --- .github/workflows/check_pr_release_notes.yml | 66 +++----------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/.github/workflows/check_pr_release_notes.yml b/.github/workflows/check_pr_release_notes.yml index 0ce19ed..b4d1419 100644 --- a/.github/workflows/check_pr_release_notes.yml +++ b/.github/workflows/check_pr_release_notes.yml @@ -21,67 +21,19 @@ on: types: [opened, synchronize, reopened, edited, labeled, unlabeled] branches: [ master ] -env: - SKIP_LABEL: 'no RN' - RLS_NOTES_TAG_REGEX: 'Release Notes:' - jobs: check-release-notes: runs-on: ubuntu-latest steps: - - name: Get Pull Request Info - id: pr_info - uses: actions/github-script@v7 + - uses: actions/setup-python@v5.1.1 with: - script: | - const pr_number = context.payload.pull_request.number; - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr_number - }); - const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : []; - - if (labels.includes("${{ env.SKIP_LABEL }}")) { - console.log("Skipping release notes check because '${{ env.SKIP_LABEL }}' label is present."); - core.setOutput("skip_check", 'true'); - core.setOutput("pr_body", ""); - return; - } - - const pr_body = pr.data.body; - if (!pr_body) { - core.setFailed("Pull request description is empty."); - core.setOutput("pr_body", ""); - core.setOutput("skip_check", 'false'); - return; - } - core.setOutput("pr_body", pr_body); - core.setOutput("skip_check", 'false'); - return; - - - name: Skip check if SKIP_LABEL is present - if: steps.pr_info.outputs.skip_check == 'true' - run: echo "Skipping release notes validation." + python-version: '3.11' - - name: Check for 'Release Notes:' and bullet list - if: steps.pr_info.outputs.skip_check == 'false' - run: | - # Extract the body from the previous step - PR_BODY="${{ steps.pr_info.outputs.pr_body }}" - - # Check if "Release Notes:" exists - if ! echo "$PR_BODY" | grep -q '${{ env.RLS_NOTES_TAG_REGEX }}'; then - echo "Error: release notes tag not found in pull request description. Has to adhere to format '${{ env.RLS_NOTES_TAG_REGEX }}'." - exit 1 - fi - - # Extract text after "Release Notes:" line - TEXT_BELOW_RELEASE_NOTES_TAG=$(echo "$PR_BODY" | sed -n '/${{ env.RLS_NOTES_TAG_REGEX }}/,$p' | tail -n +2) - - # Check if there's a bullet list (lines starting with '-', '+' or '*') - if ! echo "$TEXT_BELOW_RELEASE_NOTES_TAG" | grep -qE '^\s*[-+*]\s+.+$'; then - echo "Error: No bullet list found under release notes tag." - exit 1 - fi + - name: Check presence of release notes in PR description + uses: AbsaOSS/release-notes-presence-check@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + github-repository: ${{ github.repository }} + pr-number: ${{ github.event.number }}