Merge branch 'tusooa/changelog-improve' into 'develop'

Use git diff to search for changelog entry

See merge request pleroma/pleroma!3875
This commit is contained in:
Haelwenn 2023-05-17 15:49:54 +00:00
commit b8b15cec9e
4 changed files with 46 additions and 38 deletions

View File

@ -45,31 +45,39 @@ check-changelog:
stage: check-changelog stage: check-changelog
image: alpine image: alpine
rules: 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" - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
before_script: '' before_script: ''
after_script: '' after_script: ''
cache: {} cache: {}
script: script:
- apk add git
- sh ./tools/check-changelog - sh ./tools/check-changelog
.build_changes_policy:
rules:
- changes:
- ".gitlab-ci.yml"
- "**/*.ex"
- "**/*.exs"
- "mix.lock"
build: build:
extends: .build_changes_policy
stage: build stage: build
only:
changes: &build_changes_policy
- ".gitlab-ci.yml"
- "**/*.ex"
- "**/*.exs"
- "mix.lock"
script: script:
- mix compile --force - mix compile --force
spec-build: spec-build:
stage: test stage: test
only: rules:
changes: - changes:
- ".gitlab-ci.yml" - ".gitlab-ci.yml"
- "lib/pleroma/web/api_spec/**/*.ex" - "lib/pleroma/web/api_spec/**/*.ex"
- "lib/pleroma/web/api_spec.ex" - "lib/pleroma/web/api_spec.ex"
artifacts: artifacts:
paths: paths:
- spec.json - spec.json
@ -91,9 +99,8 @@ benchmark:
- mix pleroma.load_testing - mix pleroma.load_testing
unit-testing: unit-testing:
extends: .build_changes_policy
stage: test stage: test
only:
changes: *build_changes_policy
cache: &testing_cache_policy cache: &testing_cache_policy
<<: *global_cache_policy <<: *global_cache_policy
policy: pull policy: pull
@ -114,11 +121,10 @@ unit-testing:
path: coverage.xml path: coverage.xml
unit-testing-erratic: unit-testing-erratic:
extends: .build_changes_policy
stage: test stage: test
retry: 2 retry: 2
allow_failure: true allow_failure: true
only:
changes: *build_changes_policy
cache: &testing_cache_policy cache: &testing_cache_policy
<<: *global_cache_policy <<: *global_cache_policy
policy: pull policy: pull
@ -149,9 +155,8 @@ unit-testing-erratic:
# - mix test --trace --only federated # - mix test --trace --only federated
unit-testing-rum: unit-testing-rum:
extends: .build_changes_policy
stage: test stage: test
only:
changes: *build_changes_policy
cache: *testing_cache_policy cache: *testing_cache_policy
services: services:
- name: minibikini/postgres-with-rum:12 - name: minibikini/postgres-with-rum:12
@ -167,10 +172,9 @@ unit-testing-rum:
- mix test --preload-modules - mix test --preload-modules
lint: lint:
extends: .build_changes_policy
image: &current_elixir elixir:1.12-alpine image: &current_elixir elixir:1.12-alpine
stage: test stage: test
only:
changes: *build_changes_policy
cache: *testing_cache_policy cache: *testing_cache_policy
before_script: &current_bfr_script before_script: &current_bfr_script
- apk update - apk update
@ -182,18 +186,16 @@ lint:
- mix format --check-formatted - mix format --check-formatted
analysis: analysis:
extends: .build_changes_policy
stage: test stage: test
only:
changes: *build_changes_policy
cache: *testing_cache_policy cache: *testing_cache_policy
script: script:
- mix credo --strict --only=warnings,todo,fixme,consistency,readability - mix credo --strict --only=warnings,todo,fixme,consistency,readability
cycles: cycles:
extends: .build_changes_policy
image: *current_elixir image: *current_elixir
stage: test stage: test
only:
changes: *build_changes_policy
cache: {} cache: {}
before_script: *current_bfr_script before_script: *current_bfr_script
script: script:

View File

@ -0,0 +1,10 @@
### Checklist
- [ ] Adding a changelog: In the `changelog.d` directory, create a file named `<code>.<type>`.
`<code>` can be anything, but we recommend using a more or less unique identifier to avoid collisions, such as the branch name.
`<type>` 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).

View File

View File

@ -1,22 +1,18 @@
#!/bin/sh #!/bin/sh
echo "looking for change log of $CI_MERGE_REQUEST_IID" echo "looking for change log"
count=0 git remote add upstream https://git.pleroma.social/pleroma/pleroma.git
for i in add remove fix security skip; do git fetch upstream ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}:refs/remotes/upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
[ -f changelog.d/"$CI_MERGE_REQUEST_IID"."$i" ]
retcode=$? git diff --raw --no-renames upstream/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD -- changelog.d | \
if [ $retcode -eq 0 ]; then grep ' A\t' | grep '\.\(skip\|add\|remove\|fix\|security\)$'
echo "found $CI_MERGE_REQUEST_IID.$i" ret=$?
count=$(( count + 1 ))
else if [ $ret -eq 0 ]; then
echo "no $CI_MERGE_REQUEST_IID.$i" echo "found a changelog entry"
fi
done
if [ $count -gt 0 ]; then
echo "ok"
exit 0 exit 0
else else
echo "must have a changelog entry or explicitly skip it" echo "changelog entry not found"
exit 1 exit 1
fi fi