From 30f9ba04c6ca44a077ae48e99f43469cdba84ede Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Thu, 17 Aug 2023 18:11:45 -0500 Subject: [PATCH] ci: add empty test-plan check --- .github/workflows/pr-validation.yml | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/pr-validation.yml diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 00000000000..dfc78f687bc --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,45 @@ +--- +name: "PR Validation" + +on: # yamllint disable-line rule:truthy + #pull_request_target: + pull_request: + types: + - opened + - edited + # - synchronize + +jobs: + validate-test-plan: + runs-on: ubuntu-latest + env: + # both used by create-file-action + FILE_NAME: pr_body + FILE_DATA: ${{ github.event.pull_request.body }} + steps: + - name: get body into file + uses: finnp/create-file-action@2.0.0 + - name: extract test plan + uses: sean0x42/markdown-extract@v2 + id: testplan-with-comment + with: + file: ${{ env.FILE_NAME }} + pattern: "Test Plan" + no-print-matched-heading: true + - name: validate test plan + id: validate + shell: python + env: + DATA: ${{ steps.testplan-with-comment.outputs.markdown }} + run: | + import re + from os import env + from sys import exit + comment = re.compile(r"", flags=re.DOTALL) + body = comment.sub("", env["DATA"]).strip() + print(f"plan='{body}'") + exit(0 if body else 1) +# continue-on-error: true +# - name: comment on failure +# if: steps.validate.outcome != 'success' +