-
Notifications
You must be signed in to change notification settings - Fork 13
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
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 993753e
WIP: generate_changelog func
MaciejKaras f41c9f3
Working release notes generation
MaciejKaras 30d5b04
Added tests for release notes generation
MaciejKaras a8e6782
Release with breaking change test
MaciejKaras 6de3703
Added more releases
MaciejKaras c353737
Added release branch test cases
MaciejKaras c220f2e
Get the previous version based on current HEAD
MaciejKaras 891d821
Added tests, gitgraph, docs and cmd input
MaciejKaras a2cdcb4
Add main method in versioning.py
MaciejKaras 5465b98
Move main method to calculate_next_version.py
MaciejKaras 20fded0
Optimize imports
MaciejKaras df195d1
Lint fix
MaciejKaras aebd634
Add changelog entry frontmatter text
MaciejKaras 371499a
Added frontmatter validation
MaciejKaras a7d7f60
Script for generating changelog file
MaciejKaras 136a939
Review fixes
MaciejKaras 5dfa8cd
Review fixes v2
MaciejKaras ce49927
Review fixes v3
MaciejKaras 240f2c9
Review fixes v4
MaciejKaras 4a97699
Using ChangeEntry type
MaciejKaras 76f0f74
Making release a module
MaciejKaras c9b6857
Fixing other kind of change issue + missing tests
MaciejKaras e51357b
Adding quotes to error message variables
MaciejKaras 896db65
remove venv from .gitignore
MaciejKaras d55f322
fix unit tests
MaciejKaras 5b35ab0
Adding changelog file for testing
MaciejKaras 6723380
Adding GHA workflow
MaciejKaras a723387
Adding GHA workflow
MaciejKaras 16b1285
Adding GHA workflow
MaciejKaras 48f2507
Fixing GHA workflow
MaciejKaras bf50605
Removing changelog file
MaciejKaras 5d066f7
Adding release notes action
MaciejKaras fcd74d6
test
MaciejKaras 35a904d
wip
MaciejKaras 5d72a98
Change permissions
MaciejKaras 8eae2aa
Fix summary
MaciejKaras 3a79629
Add more changes
MaciejKaras c9850f1
Update activity types
MaciejKaras 2b484ba
Remove test changelog file
MaciejKaras a6c3360
Fix missing pipefail
MaciejKaras d6e789d
Added documentation for changelogs
MaciejKaras 8a5cd18
Remove unnecessary default value
MaciejKaras d956a13
Don't post PR comment on forks - the token has only read permissions
MaciejKaras 0286ddf
Add disclaimer to PR comment
MaciejKaras 4d81905
Merge branch 'master' into maciejk/ar-gha-integration
MaciejKaras b14bd5c
Review fixes
MaciejKaras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
m1kola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE: ${{ github.event.pull_request.html_url }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
viveksinghggits marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Makes 'release' a Python package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.