From 07c53452f6a58cbba067e89f2515231705137e01 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Tue, 25 May 2021 13:23:31 +0200 Subject: [PATCH] ci: improve changelog check - ignore master branch - treat secfix/ same as release/ branches - allow skiping check with [no changelog] in commit message --- ci/check_changelog.sh | 18 ++++++++++++++++-- ci/prebuild.yml | 2 ++ docs/misc/changelog.md | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ci/check_changelog.sh b/ci/check_changelog.sh index d89d4a4bc..c50db30d2 100755 --- a/ci/check_changelog.sh +++ b/ci/check_changelog.sh @@ -4,13 +4,27 @@ base_branch=master fail=0 subdirs="core python legacy/firmware legacy/bootloader" +changed_files=$(mktemp) +trap 'rm -- $changed_files' EXIT + git fetch origin "$base_branch" check_feature_branch () { + + for commit in $(git rev-list origin/$base_branch..) + do + if git log -n1 --format=%B "$commit" | grep -iFq "[no changelog]"; then + echo "Found [no changelog] in $commit, skipping." + continue + fi + + git show --pretty=format: --name-only "$commit" >> "$changed_files" + done + for subdir in $subdirs do echo "Checking $subdir" - files=$(git diff --name-only "origin/$base_branch..." -- "$subdir") + files=$(grep "^$subdir/" "$changed_files") if echo "$files" | grep . | grep -Fq -v .changelog.d; then if ! echo "$files" | grep -Fq .changelog.d; then @@ -29,7 +43,7 @@ check_release_branch () { fi } -if echo "$CI_COMMIT_BRANCH" | grep -q "^release/"; then +if echo "$CI_COMMIT_BRANCH" | grep -Eq "^(release|secfix)/"; then check_release_branch else check_feature_branch diff --git a/ci/prebuild.yml b/ci/prebuild.yml index bc1d3c159..11ba42bba 100644 --- a/ci/prebuild.yml +++ b/ci/prebuild.yml @@ -44,6 +44,8 @@ release commit messages prebuild: changelog prebuild: stage: prebuild + except: + - master before_script: [] # nothing needed variables: GIT_SUBMODULE_STRATEGY: "none" diff --git a/docs/misc/changelog.md b/docs/misc/changelog.md index 0ca50bcf8..f92a03bac 100644 --- a/docs/misc/changelog.md +++ b/docs/misc/changelog.md @@ -41,6 +41,13 @@ type you can add numeral suffix, e.g. `1234.fixed.1`, `1234.fixed.2`, etc. You can also add this entry using your `$VISUAL` editor by running `towncrier create --edit 1234.fixed` in the `core` directory. +## Not adding changelog entry + +If you don't add an entry for changes in your branch, the `changelog prebuild` +CI job will remind you by failing. Sometimes adding an entry does not really make +sense, in that case you can include `[no changelog]` anywhere in the commit +message to exclude that commit from the check. + ## Generating changelog at the time of release When it's time to release new version of a repository component the formatted