Skip to content

Commit

Permalink
test: add docs and test checking if calver is set
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielAtanasovski committed Mar 20, 2024
1 parent fa056d4 commit 680fdb0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ inputs:
required: false
default: false
conventional_commits:
description: |
Will parse the last commit message to determine the increment type
description: |
Will parse the last commit message to determine the increment type.
This is incompatible with the `calver` scheme and will be ignored.
Supports the following types:
- feat
- fix
- 'BREAKING CHANGE:' in commit body
Supports the following increment types:
- patch (build, chore, ci, docs, fix, perf, refactor, revert, style, test)
- minor (feat)
- Major (any of the above types with an '!' or 'BREAKING CHANGE:' in commit body)
required: false
default: false

Expand All @@ -53,7 +55,7 @@ outputs:
value: ${{ steps.version-increment.outputs.VERSION }}
v-version:
description: 'Incremented version calculated, prefixed with a `v` charatcter'
value: ${{ steps.version-increment.outputs.V_VERSION }}
value: ${{ steps.version-increment.outputs.V_VERSION }}
major-version:
description: 'Major number of the incremented version'
value: ${{ steps.version-increment.outputs.MAJOR_VERSION }}
Expand Down
19 changes: 19 additions & 0 deletions tests/test_version-increment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,22 @@ function init_repo {
[[ "$output" = *"VERSION=1.2.4"* ]]
[[ "$output" = *"No conventional commit found"* ]]
}

@test "conventional commits is non-impacting in the calver scheme (conventional commits)" {
init_repo

export current_version=$(date +%Y.%-m.1)
export scheme="calver"
export conventional_commits="true"

echo "fix: something" > fix.txt
git add fix.txt
git commit -m "fix: something"

run ../../version-increment.sh

print_run_info
[ "$status" -eq 0 ] &&
[[ "$output" = *"VERSION=$(date +%Y.%-m.2)"* ]]
[[ "$output" = *"Conventional commits does not work with the 'calver' scheme"* ]]
}
5 changes: 5 additions & 0 deletions version-increment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ fi

##==----------------------------------------------------------------------------
## Conventional commits
# If calver is set, raise a warning
if [[ "${scheme}" == 'calver' ]] ; then
echo "⚠️ Conventional commits does not work with the 'calver' scheme" 1>&2
conventional_commits='false'
fi

if [[ "${conventional_commits:-}" == 'true' ]] ; then
# Get message from given commit
Expand Down

0 comments on commit 680fdb0

Please sign in to comment.