From 680fdb0eefa13974c80c5656cb1230545b179c72 Mon Sep 17 00:00:00 2001 From: Daniel Atanasovski Date: Wed, 20 Mar 2024 14:10:07 +1100 Subject: [PATCH] test: add docs and test checking if calver is set --- action.yml | 16 +++++++++------- tests/test_version-increment.bats | 19 +++++++++++++++++++ version-increment.sh | 5 +++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 97b0d11..c309e30 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} diff --git a/tests/test_version-increment.bats b/tests/test_version-increment.bats index 74e2081..33ee22c 100644 --- a/tests/test_version-increment.bats +++ b/tests/test_version-increment.bats @@ -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"* ]] +} diff --git a/version-increment.sh b/version-increment.sh index d22a56a..0842480 100755 --- a/version-increment.sh +++ b/version-increment.sh @@ -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