From 7d35078afcb8aaa7aa7ebbb85bd99775f6ef2a9a Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Thu, 4 Jul 2024 10:26:52 -0700 Subject: [PATCH] Add more test workflow stuff --- .github/workflows/check_release_notes.yml | 7 +++++-- check_release_notes.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 check_release_notes.py diff --git a/.github/workflows/check_release_notes.yml b/.github/workflows/check_release_notes.yml index a9718eb..782a0fb 100644 --- a/.github/workflows/check_release_notes.yml +++ b/.github/workflows/check_release_notes.yml @@ -8,7 +8,7 @@ name: Labeler on: pull_request: - types: [labeled, unlabeled] + types: [labeled, unlabeled, edited] jobs: label: @@ -25,4 +25,7 @@ jobs: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" \ No newline at end of file + run: echo "$GITHUB_CONTEXT" + - name: Get env + id: pr-info + run: env \ No newline at end of file diff --git a/check_release_notes.py b/check_release_notes.py new file mode 100644 index 0000000..5fdec2b --- /dev/null +++ b/check_release_notes.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import re +import sys +import json + +input_data = json.loads(sys.stdin.read()) +pr_body = input_data['body'] + +if result := re.search("(?<=```release-note\n).*?(?=\n```)", pr_body, re.DOTALL): + release_note = result.group().strip() + if not release_note: + print('FAIL: Release note is empty', file=sys.stderr) + sys.exit(-1) + if release_note.lower() == "tbd": + print('FAIL: Release note contains "TBD"', file=sys.stderr) + sys.exit(-1) +else: + print('FAIL: No release notes found in PR body', file=sys.stderr) + sys.exit(-1) + +sys.exit(0) \ No newline at end of file