From 50e237759a0aa378b32393ba57d50eaaff5029e0 Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 22 Apr 2023 20:30:17 -0400 Subject: [PATCH 1/7] Use git diff to search for changelog entry --- .gitlab-ci.yml | 1 + tools/check-changelog | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e4897aa0..6e498bf89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,6 +49,7 @@ check-changelog: after_script: '' cache: {} script: + - apk add git - sh ./tools/check-changelog build: diff --git a/tools/check-changelog b/tools/check-changelog index b94b52755..0b57c4d1e 100644 --- a/tools/check-changelog +++ b/tools/check-changelog @@ -1,22 +1,15 @@ #!/bin/sh -echo "looking for change log of $CI_MERGE_REQUEST_IID" +echo "looking for change log" -count=0 -for i in add remove fix security skip; do - [ -f changelog.d/"$CI_MERGE_REQUEST_IID"."$i" ] - retcode=$? - if [ $retcode -eq 0 ]; then - echo "found $CI_MERGE_REQUEST_IID.$i" - count=$(( count + 1 )) - else - echo "no $CI_MERGE_REQUEST_IID.$i" - fi -done -if [ $count -gt 0 ]; then - echo "ok" +git diff --raw $CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \ + grep ' A\t' | grep '\.\(skip\|add\|remove\|fix\|security\)$' +ret=$? + +if [ $ret -eq 0 ]; then + echo "found a changelog entry" exit 0 else - echo "must have a changelog entry or explicitly skip it" + echo "changelog entry not found" exit 1 fi From e13b331762881933d66597b3145b4d20d6e51912 Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 22 Apr 2023 20:40:39 -0400 Subject: [PATCH 2/7] Fetch upstream in the repo --- tools/check-changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/check-changelog b/tools/check-changelog index 0b57c4d1e..1409be9f0 100644 --- a/tools/check-changelog +++ b/tools/check-changelog @@ -2,7 +2,10 @@ echo "looking for change log" -git diff --raw $CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \ +git remote add upstream https://git.pleroma.social/pleroma/pleroma.git +git fetch upstream ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}:refs/remotes/upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME + +git diff --raw upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \ grep ' A\t' | grep '\.\(skip\|add\|remove\|fix\|security\)$' ret=$? From c1aa83069daaa7df906f63b3417e14b7edbfae94 Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 22 Apr 2023 20:45:27 -0400 Subject: [PATCH 3/7] Skip changelog --- changelog.d/changelog-improve.skip | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 changelog.d/changelog-improve.skip diff --git a/changelog.d/changelog-improve.skip b/changelog.d/changelog-improve.skip new file mode 100644 index 000000000..e69de29bb From 30bc37c3cab8ebf7be667fb291f0d99c17d808ef Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 22 Apr 2023 21:02:13 -0400 Subject: [PATCH 4/7] Explain changelog.d in merge request templates --- .gitlab/merge_request_templates/Default.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .gitlab/merge_request_templates/Default.md diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md new file mode 100644 index 000000000..fdf219f99 --- /dev/null +++ b/.gitlab/merge_request_templates/Default.md @@ -0,0 +1,10 @@ +### Checklist +- [ ] Adding a changelog: In the `changelog.d` directory, create a file named `.`. + + `` can be anything, but we recommend using a more or less unique identifier to avoid collisions, such as the branch name. + + `` can be `add`, `remove`, `fix`, `security` or `skip`. `skip` is only used if there is no user-visible change in the MR (for example, only editing comments in the code). Otherwise, choose a type that corresponds to your change. + + In the file, write the changelog entry. For example, if an MR adds group functionality, we can create a file named `group.add` and write `Add group functionality` in it. + + If one changelog entry is not enough, you may add more. But that might mean you can split it into two MRs. Only use more than one changelog entry if you really need to (for example, when one change in the code fix two different bugs, or when refactoring). From ae8f359f22d8d02c2937df0a81052fc3504d4248 Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 22 Apr 2023 21:07:18 -0400 Subject: [PATCH 5/7] Skip changelog check for automated MRs --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e498bf89..2eee3bc68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,10 @@ check-changelog: stage: check-changelog image: alpine rules: + - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate-extract' + when: never + - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate' + when: never - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" before_script: '' after_script: '' From 99f157e2804327d4ad3f47b83638060f774a582b Mon Sep 17 00:00:00 2001 From: tusooa Date: Tue, 2 May 2023 22:12:15 -0400 Subject: [PATCH 6/7] Fix MR pipelines not having build and test jobs --- .gitlab-ci.yml | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2eee3bc68..b70415ac6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,24 +56,27 @@ check-changelog: - apk add git - sh ./tools/check-changelog +.build_changes_policy: + rules: + - changes: + - ".gitlab-ci.yml" + - "**/*.ex" + - "**/*.exs" + - "mix.lock" + build: + extends: .build_changes_policy stage: build - only: - changes: &build_changes_policy - - ".gitlab-ci.yml" - - "**/*.ex" - - "**/*.exs" - - "mix.lock" script: - mix compile --force spec-build: stage: test - only: - changes: - - ".gitlab-ci.yml" - - "lib/pleroma/web/api_spec/**/*.ex" - - "lib/pleroma/web/api_spec.ex" + rules: + - changes: + - ".gitlab-ci.yml" + - "lib/pleroma/web/api_spec/**/*.ex" + - "lib/pleroma/web/api_spec.ex" artifacts: paths: - spec.json @@ -95,9 +98,8 @@ benchmark: - mix pleroma.load_testing unit-testing: + extends: .build_changes_policy stage: test - only: - changes: *build_changes_policy cache: &testing_cache_policy <<: *global_cache_policy policy: pull @@ -118,11 +120,10 @@ unit-testing: path: coverage.xml unit-testing-erratic: + extends: .build_changes_policy stage: test retry: 2 allow_failure: true - only: - changes: *build_changes_policy cache: &testing_cache_policy <<: *global_cache_policy policy: pull @@ -153,9 +154,8 @@ unit-testing-erratic: # - mix test --trace --only federated unit-testing-rum: + extends: .build_changes_policy stage: test - only: - changes: *build_changes_policy cache: *testing_cache_policy services: - name: minibikini/postgres-with-rum:12 @@ -171,10 +171,9 @@ unit-testing-rum: - mix test --preload-modules lint: + extends: .build_changes_policy image: ¤t_elixir elixir:1.12-alpine stage: test - only: - changes: *build_changes_policy cache: *testing_cache_policy before_script: ¤t_bfr_script - apk update @@ -186,18 +185,16 @@ lint: - mix format --check-formatted analysis: + extends: .build_changes_policy stage: test - only: - changes: *build_changes_policy cache: *testing_cache_policy script: - mix credo --strict --only=warnings,todo,fixme,consistency,readability cycles: + extends: .build_changes_policy image: *current_elixir stage: test - only: - changes: *build_changes_policy cache: {} before_script: *current_bfr_script script: From 6a3fd8e01404f7fc4415626300d81c65c045a7d6 Mon Sep 17 00:00:00 2001 From: tusooa Date: Tue, 2 May 2023 22:16:00 -0400 Subject: [PATCH 7/7] Do not count for renames when diffing --- tools/check-changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check-changelog b/tools/check-changelog index 1409be9f0..60692033f 100644 --- a/tools/check-changelog +++ b/tools/check-changelog @@ -5,7 +5,7 @@ echo "looking for change log" git remote add upstream https://git.pleroma.social/pleroma/pleroma.git git fetch upstream ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}:refs/remotes/upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME -git diff --raw upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \ +git diff --raw --no-renames upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \ grep ' A\t' | grep '\.\(skip\|add\|remove\|fix\|security\)$' ret=$?