From b3dcda411e9b702408e9d9a23995644280fb8a94 Mon Sep 17 00:00:00 2001 From: Tomer Keshet Date: Thu, 4 Jul 2024 13:07:05 +0300 Subject: [PATCH] verify description contains tests performed --- .github/workflows/pr-description-check.yaml | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/pr-description-check.yaml diff --git a/.github/workflows/pr-description-check.yaml b/.github/workflows/pr-description-check.yaml new file mode 100644 index 0000000..378e8ca --- /dev/null +++ b/.github/workflows/pr-description-check.yaml @@ -0,0 +1,34 @@ +name: Check PR Description contains tests performed + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + check-pr-description: + runs-on: ubuntu-latest + + steps: + - name: Check out the code + uses: actions/checkout@v2 + + - name: Validate PR description + id: validate + run: | + if [[ ! "${{ github.event.pull_request.body }}" =~ "## Tests performed" ]]; then + echo "PR description does not contain the section 'Tests performed'." + exit 1 + fi + + # Extract the "Tests performed" section + tests_performed_section=$(sed -n '/## Tests performed/,/##/p' <<< "${{ github.event.pull_request.body }}") + + # Check if there is at least one test description in the "Tests performed" section + if [[ ! "$tests_performed_section" =~ "- " ]]; then + echo "The 'Tests performed' section does not contain a list of tests." + exit 1 + fi + + - name: Success message + if: success() + run: echo "PR description contains the 'Tests performed' section with a list of tests."