From 315df97c343801281af1db8d113f9d906e1f1b51 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Thu, 1 May 2025 17:16:20 -0700 Subject: [PATCH 1/7] CSHARP-4918: Release notes automation --- .github/workflows/pr.yml | 38 ++++++++++++++++++++++++++++++++++++++ evergreen/release-notes.py | 7 ++++--- 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000000..254306a0ea1 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,38 @@ +name: Pull Request validation + +on: + pull_request: + types: + - opened + - reopened + - edited + - labeled + - unlabeled + +jobs: + release-notes-check-labels: + name: Check assigned labels. + runs-on: ubuntu-latest + steps: + - if: github.event.pull_request.labels[0] == null + run: | + echo "Pull Request should have label assigned." + exit 2 + + release-notes-check-jira-ticket: + name: Check title to contains Jira ticket. + runs-on: ubuntu-latest + steps: + - if: ${{ !(contains(github.event.pull_request.title, 'CSHARP-')) }} + run: | + echo "Title should contains Jira ticket." + exit 2 + + release-notes-check-title: + name: Title should not ends with period or elipses + runs-on: ubuntu-latest + steps: + - if: ${{ endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…') }} + run: | + echo "Title should not ends with period or elipses." + exit 2 diff --git a/evergreen/release-notes.py b/evergreen/release-notes.py index 5d5d5367a10..ff388d8da5d 100644 --- a/evergreen/release-notes.py +++ b/evergreen/release-notes.py @@ -37,7 +37,7 @@ def load_config(opts): def mapPullRequest(pullRequest, opts): - title = pullRequest["title"] + title = pullRequest["title"].encode('ascii', 'backslashreplace').decode().replace("<", "\<") for regex in opts.template["autoformat"]: title = re.sub(regex["match"], regex["replace"], title) @@ -91,7 +91,9 @@ def load_pull_requests(opts): github_api_base_url=opts.github_api_base_url, repo=opts.repo, commit_sha=commit["sha"]) - pullrequests = requests.get(pullrequests_url, headers=opts.github_headers).json() + pullrequests_response = requests.get(pullrequests_url, headers=opts.github_headers) + pullrequests_response.raise_for_status() + pullrequests = pullrequests_response.json() for pullrequest in pullrequests: mapped = mapPullRequest(pullrequest, opts) if is_in_section(mapped, ignore_section): @@ -140,7 +142,6 @@ def publish_release_notes(opts, title, content): print("Publishing release notes...") url = '{github_api_base_url}{repo}/releases/tags/{tag}'.format(github_api_base_url=opts.github_api_base_url, repo=opts.repo, tag=opts.version_tag) response = requests.get(url, headers=opts.github_headers) - response.raise_for_status() if response.status_code != 404: raise SystemExit("Release with the tag already exists") From e35f50a73f40a9fafc6645c7e095dcae3baa38c3 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 2 May 2025 12:57:32 -0700 Subject: [PATCH 2/7] PR --- .github/workflows/pr.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 254306a0ea1..c9f8e3689c1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,29 +10,24 @@ on: - unlabeled jobs: - release-notes-check-labels: - name: Check assigned labels. + pull-request-validation: + name: Pull Request validation. runs-on: ubuntu-latest steps: - - if: github.event.pull_request.labels[0] == null + - name: Validate label. + if: ${{ always() && github.event.pull_request.labels[0] == null }} run: | echo "Pull Request should have label assigned." - exit 2 + exit 1 - release-notes-check-jira-ticket: - name: Check title to contains Jira ticket. - runs-on: ubuntu-latest - steps: - - if: ${{ !(contains(github.event.pull_request.title, 'CSHARP-')) }} + - name: Title should contain Jira ticket. + if: ${{ always() && !(contains(github.event.pull_request.title, 'CSHARP-')) }} run: | echo "Title should contains Jira ticket." - exit 2 + exit 1 - release-notes-check-title: - name: Title should not ends with period or elipses - runs-on: ubuntu-latest - steps: - - if: ${{ endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…') }} + - name: Title should not end with period or elipses + if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} run: | - echo "Title should not ends with period or elipses." - exit 2 + echo "Title should not end with a period or ellipses." + exit 1 From a72617c34a294d5e711bed671b5dd8069ebacd99 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 2 May 2025 13:01:00 -0700 Subject: [PATCH 3/7] PR --- .github/workflows/pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c9f8e3689c1..e802d2499aa 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,11 +23,11 @@ jobs: - name: Title should contain Jira ticket. if: ${{ always() && !(contains(github.event.pull_request.title, 'CSHARP-')) }} run: | - echo "Title should contains Jira ticket." + echo "Title should contain Jira ticket." exit 1 - name: Title should not end with period or elipses - if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} + if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} run: | echo "Title should not end with a period or ellipses." exit 1 From 8a3f00e655bdd35b00f1c999354b4a63d52433ca Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 9 May 2025 15:45:11 -0700 Subject: [PATCH 4/7] PR --- .github/workflows/pr.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e802d2499aa..119e0b2ffc4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,20 +14,17 @@ jobs: name: Pull Request validation. runs-on: ubuntu-latest steps: - - name: Validate label. + - name: Pull Request should have a label assigned. if: ${{ always() && github.event.pull_request.labels[0] == null }} run: | - echo "Pull Request should have label assigned." exit 1 - - name: Title should contain Jira ticket. - if: ${{ always() && !(contains(github.event.pull_request.title, 'CSHARP-')) }} + - name: Title should mention Jira ticket. + if: ${{ always() && !(startsWith(github.event.pull_request.title, 'CSHARP-')) }} run: | - echo "Title should contain Jira ticket." exit 1 - name: Title should not end with period or elipses - if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} + if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '�')) }} run: | - echo "Title should not end with a period or ellipses." exit 1 From 4f6e1f9a24e1b39d0a7508b73aab8b0eb9c0d0b2 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 9 May 2025 15:47:16 -0700 Subject: [PATCH 5/7] pr --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 119e0b2ffc4..d38ce1f2fb8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,6 +25,6 @@ jobs: exit 1 - name: Title should not end with period or elipses - if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '�')) }} + if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} run: | exit 1 From aa3229fae2c9b2fcbd22e866a3146ddfdb1a5782 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 9 May 2025 16:00:24 -0700 Subject: [PATCH 6/7] PR --- .github/workflows/pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d38ce1f2fb8..714b2c6cd1b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,12 +19,12 @@ jobs: run: | exit 1 - - name: Title should mention Jira ticket. + - name: Title should start with with a Jira ticket. if: ${{ always() && !(startsWith(github.event.pull_request.title, 'CSHARP-')) }} run: | exit 1 - - name: Title should not end with period or elipses + - name: Title should not end with period or ellipses. if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }} run: | exit 1 From 171f3122f95252572f4743ec512a8f4d9db4fc36 Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Fri, 9 May 2025 16:01:36 -0700 Subject: [PATCH 7/7] pr --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 714b2c6cd1b..0faa7e70dbe 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,7 @@ jobs: run: | exit 1 - - name: Title should start with with a Jira ticket. + - name: Title should start with a Jira ticket. if: ${{ always() && !(startsWith(github.event.pull_request.title, 'CSHARP-')) }} run: | exit 1