Skip to content

CLOUDP-295785 - GitHub Actions workflow that checks for changelogs #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
65fd607
WIP: changelog and versioning methods
MaciejKaras Jun 10, 2025
993753e
WIP: generate_changelog func
MaciejKaras Jun 10, 2025
f41c9f3
Working release notes generation
MaciejKaras Jun 10, 2025
30d5b04
Added tests for release notes generation
MaciejKaras Jun 11, 2025
a8e6782
Release with breaking change test
MaciejKaras Jun 11, 2025
6de3703
Added more releases
MaciejKaras Jun 12, 2025
c353737
Added release branch test cases
MaciejKaras Jun 12, 2025
c220f2e
Get the previous version based on current HEAD
MaciejKaras Jun 12, 2025
891d821
Added tests, gitgraph, docs and cmd input
MaciejKaras Jun 13, 2025
a2cdcb4
Add main method in versioning.py
MaciejKaras Jun 15, 2025
5465b98
Move main method to calculate_next_version.py
MaciejKaras Jun 16, 2025
20fded0
Optimize imports
MaciejKaras Jun 16, 2025
df195d1
Lint fix
MaciejKaras Jun 16, 2025
aebd634
Add changelog entry frontmatter text
MaciejKaras Jul 11, 2025
371499a
Added frontmatter validation
MaciejKaras Jul 13, 2025
a7d7f60
Script for generating changelog file
MaciejKaras Jul 13, 2025
136a939
Review fixes
MaciejKaras Jul 13, 2025
5dfa8cd
Review fixes v2
MaciejKaras Jul 14, 2025
ce49927
Review fixes v3
MaciejKaras Jul 14, 2025
240f2c9
Review fixes v4
MaciejKaras Jul 14, 2025
4a97699
Using ChangeEntry type
MaciejKaras Jul 15, 2025
76f0f74
Making release a module
MaciejKaras Jul 15, 2025
c9b6857
Fixing other kind of change issue + missing tests
MaciejKaras Jul 15, 2025
e51357b
Adding quotes to error message variables
MaciejKaras Jul 15, 2025
896db65
remove venv from .gitignore
MaciejKaras Jul 16, 2025
d55f322
fix unit tests
MaciejKaras Jul 16, 2025
5b35ab0
Adding changelog file for testing
MaciejKaras Jul 15, 2025
6723380
Adding GHA workflow
MaciejKaras Jul 15, 2025
a723387
Adding GHA workflow
MaciejKaras Jul 15, 2025
16b1285
Adding GHA workflow
MaciejKaras Jul 15, 2025
48f2507
Fixing GHA workflow
MaciejKaras Jul 15, 2025
bf50605
Removing changelog file
MaciejKaras Jul 15, 2025
5d066f7
Adding release notes action
MaciejKaras Jul 15, 2025
fcd74d6
test
MaciejKaras Jul 15, 2025
35a904d
wip
MaciejKaras Jul 15, 2025
5d72a98
Change permissions
MaciejKaras Jul 16, 2025
8eae2aa
Fix summary
MaciejKaras Jul 16, 2025
3a79629
Add more changes
MaciejKaras Jul 16, 2025
c9850f1
Update activity types
MaciejKaras Jul 16, 2025
2b484ba
Remove test changelog file
MaciejKaras Jul 16, 2025
a6c3360
Fix missing pipefail
MaciejKaras Jul 16, 2025
d6e789d
Added documentation for changelogs
MaciejKaras Jul 16, 2025
8a5cd18
Remove unnecessary default value
MaciejKaras Jul 17, 2025
d956a13
Don't post PR comment on forks - the token has only read permissions
MaciejKaras Jul 17, 2025
0286ddf
Add disclaimer to PR comment
MaciejKaras Jul 17, 2025
4d81905
Merge branch 'master' into maciejk/ar-gha-integration
MaciejKaras Jul 28, 2025
b14bd5c
Review fixes
MaciejKaras Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/actions/setup-ubuntu-host/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Setup Ubuntu Runner Host'
inputs:
python-version:
description: 'Python version to use'
required: true
runs:
using: "composite"
steps:
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{inputs.python-version}}
cache: 'pip' # caching pip dependencies
- name: Install dependencies
shell: bash
run: |
sudo apt-get install libldap2-dev libsasl2-dev # Required for python-ldap
pip install --upgrade pip
pip install -r requirements.txt
23 changes: 15 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@
<!-- Enter your proof that it works here.-->

## Checklist

- [ ] Have you linked a jira ticket and/or is the ticket in the title?
- [ ] Have you checked whether your jira ticket required DOCSP changes?
- [ ] Have you checked for release_note changes?
- [ ] Have you added changelog file?
- use `skip-changelog` label if not needed
- refer
to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes)
section in CONTRIBUTING.md for more details

## Reminder (Please remove this when merging)

- Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible
- Our Short Guide for PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0)
- Our Short Guide for
PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0)
- Remember the following Communication Standards - use comment prefixes for clarity:
* **blocking**: Must be addressed before approval.
* **follow-up**: Can be addressed in a later PR or ticket.
* **q**: Clarifying question.
* **nit**: Non-blocking suggestions.
* **note**: Side-note, non-actionable. Example: Praise
* --> no prefix is considered a question
* **blocking**: Must be addressed before approval.
* **follow-up**: Can be addressed in a later PR or ticket.
* **q**: Clarifying question.
* **nit**: Non-blocking suggestions.
* **note**: Side-note, non-actionable. Example: Praise
* --> no prefix is considered a question
42 changes: 42 additions & 0 deletions .github/workflows/preview_release_notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Preview Release Notes
on:
push:
branches:
- master
- release-*
pull_request:
branches:
- master
- release-*

jobs:
preview_release_notes:
name: Preview Release Notes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Setup host
uses: ./.github/actions/setup-ubuntu-host
with:
python-version: '${{ vars.PYTHON_VERSION }}'
- name: Generate Release Notes
id: generate_release_notes
run: python -m scripts.release.release_notes -s $INITIAL_COMMIT_SHA -v $INITIAL_VERSION -o release_notes_tmp.md
env:
INITIAL_COMMIT_SHA: ${{ vars.RELEASE_INITIAL_COMMIT_SHA }}
INITIAL_VERSION: ${{ vars.RELEASE_INITIAL_VERSION }}
- name: Summarize results
run: cat release_notes_tmp.md >> $GITHUB_STEP_SUMMARY
- name: Update PR comment
# If the PR is from a fork, we cannot update the comment using read only permissions
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: gh issue comment $ISSUE --edit-last --create-if-none --body-file release_notes_tmp.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.pull_request.html_url }}
35 changes: 35 additions & 0 deletions .github/workflows/require_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Validate Changelog Requirement
on:
pull_request:
branches:
- master
- release-*
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled

jobs:
validate-changelog:
name: Check for valid changelog entry
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Setup host
uses: ./.github/actions/setup-ubuntu-host
with:
python-version: '${{ vars.PYTHON_VERSION }}'
- name: Check if changelog entry file was added in this PR
run: |
set -o pipefail
python -m scripts.release.check_changelog -b $BASE_SHA -f $FAIL_ON_NO_CHANGES | tee >> $GITHUB_STEP_SUMMARY
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
FAIL_ON_NO_CHANGES: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') }}
50 changes: 47 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
# Summary

Contributing to the Mongodb Controllers for Kubernetes (MCK) project
Pull requests are always welcome, and the MCK dev team appreciates any help the community can give to help make MongoDB better.
Pull requests are always welcome, and the MCK dev team appreciates any help the community can give to help make MongoDB
better.

## PR Prerequisites

# PR Prerequisites
* Please ensure you have signed our Contributor Agreement. You can find it [here](https://www.mongodb.com/legal/contributor-agreement).
* Please ensure you have signed our Contributor Agreement. You can find
it [here](https://www.mongodb.com/legal/contributor-agreement).
* Please ensure that all commits are signed.
* Create a changelog file that will describe the changes you made. Use the `skip-changelog` label if your changes do not
require a changelog entry.

## Changelog files and Release Notes

Each Pull Request usually has a changelog file that describes the changes made in the PR using Markdown syntax.
Changelog files are placed in the `changelog/` directory and used to generate the Release Notes for the
upcoming release. Preview of the Release Notes is automatically added as comment to each Pull Request.
The changelog file needs to follow the naming convention
`YYYYMMDD-<change_kind>-<short-description>.md`. To create changelog file please use the
`scripts/release/create_changelog.py` script. Example usage:

```console
python3 -m scripts.release.create_changelog --kind fix "Fix that I want to describe in the changelog"
```

For more options, run the script with `--help`:

```console
python3 -m scripts.release.create_changelog --help
usage: create_changelog.py [-h] [-c ] [-d ] [-e] -k title

Utility to easily create a new changelog entry file.

positional arguments:
title Title for the changelog entry

options:
-h, --help show this help message and exit
-c, --changelog-path
Path to the changelog directory relative to the repository root. Default is changelog/
-d, --date Date in 'YYYY-MM-DD' format to use for the changelog entry. Default is today's date
-e, --editor Open the created changelog entry in the default editor (if set, otherwise uses 'vi'). Default is True
-k, --kind Kind of the changelog entry:
- 'prelude' for prelude entries
- 'breaking, major' for breaking change entries
- 'feat, feature' for feature entries
- 'fix, bugfix, hotfix, patch' for bugfix entries
- everything else will be treated as other entries
```
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pytest-mock==3.14.1
wrapt==1.17.2
botocore==1.38.33
boto3==1.38.33
python-frontmatter==1.1.0

# from kubeobject
freezegun==1.5.2
Expand Down
1 change: 1 addition & 0 deletions scripts/release/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Makes 'release' a Python package.
60 changes: 60 additions & 0 deletions scripts/release/calculate_next_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import argparse
import pathlib

from git import Repo

from scripts.release.changelog import (
DEFAULT_CHANGELOG_PATH,
DEFAULT_INITIAL_GIT_TAG_VERSION,
)
from scripts.release.release_notes import calculate_next_version_with_changelog

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Calculate the next version based on the changes since the previous version tag.",
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"-p",
"--path",
default=".",
metavar="",
action="store",
type=pathlib.Path,
help="Path to the Git repository. Default is the current directory '.'",
)
parser.add_argument(
"-c",
"--changelog-path",
default=DEFAULT_CHANGELOG_PATH,
metavar="",
action="store",
type=str,
help=f"Path to the changelog directory relative to the repository root. Default is '{DEFAULT_CHANGELOG_PATH}'",
)
parser.add_argument(
"-s",
"--initial-commit-sha",
metavar="",
action="store",
type=str,
help="SHA of the initial commit to start from if no previous version tag is found.",
)
parser.add_argument(
"-v",
"--initial-version",
default=DEFAULT_INITIAL_GIT_TAG_VERSION,
metavar="",
action="store",
type=str,
help=f"Version to use if no previous version tag is found. Default is '{DEFAULT_INITIAL_GIT_TAG_VERSION}'",
)
args = parser.parse_args()

repo = Repo(args.path)

version, _ = calculate_next_version_with_changelog(
repo, args.changelog_path, args.initial_commit_sha, args.initial_version
)

print(version)
Loading