CI: Force changelog updates

Changelog updates are now required in MRs by default. If there is a
match for "\<skip.\?changelog\>" in the commit message, this will be
ignored.

$CI_COMMIT_MESSAGE mangles newlines so it's not possible to require the
string to be on its own line, that means it would also trigger within a
wall of text, which makes it less obvious.

Also, I wasn't able to find a CI variable which has the ref of the
branch the MR is set against, to build a tree-ish than spans over the
whole MR and not just HEAD.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2024-12-16 17:04:44 +01:00
commit bbbf522ca0
No known key found for this signature in database
GPG key ID: DEDA74AEECA9D0F2
3 changed files with 62 additions and 0 deletions

View file

@ -68,6 +68,26 @@ rustfmt:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
changelog-update:
stage: lint
image: alpine:latest
# Check in the commit message for "skip.?changelog", if not present
# then check for changes in changelogs.
# XXX: It looks like $CI_COMMIT_MESSAGE mangles newlines so it's not
# possible to require the "skip.?changelog" string to be on its own line,
# that means it would also trigger within a wall of text. Not so obvious.
# TODO: Check the whole MR for updates in changelogs, not just the last
# commit.
script:
- apk add --no-cache python3 git
- python3 --version
- git version
- git log --oneline "${CI_MERGE_REQUEST_DIFF_BASE_SHA}.." --
- python3 .forgejo/workflows/check-changelog.py
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_REF_NAME == 'main'
stable-test:
extends:
- .test