Skip to content
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

Changelog: Fix CI job and introduce verification CI job #278

Merged
merged 12 commits into from
Jul 1, 2024
24 changes: 23 additions & 1 deletion .github/changelog-processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,35 @@
help="Print the changelog from the last release.",
action="store_true"
)
group.add_argument(
"--validate-changelog",
dest="validate_changelog",
help="Validates that the changelog uses the correct syntax",
action="store_true"
)

args = parser.parse_args()

with open(args.changelog, "r") as changelog:
lines = changelog.readlines()

if args.validate_changelog:
for line in lines:
if line.startswith("##"):
if line.startswith("###"):
continue
elif not line.startswith("## ["):
print("Line starting with `##` needs to be followed by ` [`, e.g.: `## [Unreleased]`, `## [400.2.1]`")
print(line)
sys.exit(-1)
elif line.startswith("#"):
if line.strip() != "# Changelog":
print("Line starting with `#` is only allowed for `# Changelog`")
print(line)
sys.exit(-1)

sys.exit(0)

changelog_last_release = ""
found_last_version = False

Expand All @@ -53,7 +76,6 @@
else:
break


if args.changelog_last_release:
print(changelog_last_release, end = "")
sys.exit(0)
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Modify Changelog
name: Verify Changelog

on:
pull_request_target:
Expand All @@ -8,7 +8,7 @@ on:

jobs:

verifyChangelog:
verify-changelog-updated:
name: Verify that Changelog is Updated
runs-on: ubuntu-latest
env:
Expand All @@ -22,3 +22,12 @@ jobs:
- name: Set error
if: steps.changed.outputs.matched != 'true' && !contains(github.event.pull_request.body, '[x] Does not require a CHANGELOG entry')
run: echo "::error::CHANGELOG.md has not been modified. Either modify the file or check the checkbox in the body" && exit 1

verify-changelog-valid:
name: Verify that Changelog is valid
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: Verify
run: .github/changelog-processor.py CHANGELOG.md --validate-changelog
3 changes: 2 additions & 1 deletion .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
fi

# Disable the spec version check when we dont want to release.
if ! .github/changelog-processor.py CHANGELOG.md --should-release ; then
# The program prints either `1` or `0`.
if [ "$(.github/changelog-processor.py CHANGELOG.md --should-release)" = "0" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably typo here =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXTRA_FLAGS+=" --disable-spec-version-check"
echo "Disabling the spec version check since we are not releasing"
else
Expand Down
Loading