Skip to content

Bump failing after commitizen upgrade to 2.21.0 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
datanrd opened this issue Feb 19, 2022 · 28 comments
Closed

Bump failing after commitizen upgrade to 2.21.0 #19

datanrd opened this issue Feb 19, 2022 · 28 comments

Comments

@datanrd
Copy link

datanrd commented Feb 19, 2022

When commitizen was upgraded to 2.21.0, my job started to fail with No tag found to do an incremental changelog. Here are the logs from the workflow:

Run commitizen-tools/commitizen-action@master
  with:
    github_token: ***
    changelog_increment_filename: body.md
    branch: main
    commit: true
    push: true
    changelog: true
    git_name: github-actions[bot]
    git_email: github-actions[bot]@users.noreply.github.com

/usr/bin/docker run --name db2d75cd135537dca42949a8bba04dc640a1c_2a63e9 --label 7db2d7 --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_CHANGELOG_INCREMENT_FILENAME -e INPUT_BRANCH -e INPUT_DRY_RUN -e INPUT_COMMIT -e INPUT_PUSH -e INPUT_PRERELEASE -e INPUT_CHANGELOG -e INPUT_REPOSITORY -e INPUT_EXTRA_REQUIREMENTS -e INPUT_GIT_NAME -e INPUT_GIT_EMAIL -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/dialexa-python-cookiecutter/dialexa-python-cookiecutter":"/github/workspace" 7db2d7:5cd135537dca42949a8bba04dc640a1c

Repository: datanrd/dialexa-python-cookiecutter
Actor: datanrd
Installing requirements...
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting commitizen
  Downloading commitizen-2.21.0-py3-none-any.whl (44 kB)
Collecting termcolor<2.0,>=1.1
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting jinja2>=2.10.3
  Downloading Jinja2-3.0.3-py3-none-any.whl ([13](https://github.com/datanrd/dialexa-python-cookiecutter/runs/5259326201?check_suite_focus=true#step:4:13)3 kB)
Collecting pyyaml>=3.08
  Downloading PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (701 kB)
Collecting questionary<2.0.0,>=1.4.0
  Downloading questionary-1.10.0-py3-none-any.whl (31 kB)
Collecting decli<0.6.0,>=0.5.2
  Downloading decli-0.5.2-py3-none-any.whl (7.7 kB)
Collecting packaging<22,>=19
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
Collecting colorama<0.5.0,>=0.4.1
  Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting typing-extensions<5.0.0,>=4.0.1
  Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Collecting argcomplete<2.0.0,>=1.12.1
  Downloading argcomplete-1.12.3-py2.py3-none-any.whl (38 kB)
Collecting tomlkit<1.0.0,>=0.5.3
  Downloading tomlkit-0.10.0-py3-none-any.whl (33 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux20[14](https://github.com/datanrd/dialexa-python-cookiecutter/runs/5259326201?check_suite_focus=true#step:4:14)_x86_64.whl (25 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting prompt_toolkit<4.0,>=2.0
  Downloading prompt_toolkit-3.0.28-py3-none-any.whl (380 kB)
Collecting wcwidth
  Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Building wheels for collected packages: termcolor
  Building wheel for termcolor (setup.py): started
  Building wheel for termcolor (setup.py): finished with status 'done'
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4848 sha256=798398deb6ba012869b562e9e66ba52d214a099d0cf6132f1ff269d81104ce27
  Stored in directory: /tmp/pip-ephem-wheel-cache-5mm7a4mv/wheels/a0/[16](https://github.com/datanrd/dialexa-python-cookiecutter/runs/5259326201?check_suite_focus=true#step:4:16)/9c/5473df82468f958445479c59e784896fa24f4a5fc024b0f501
Successfully built termcolor
Installing collected packages: wcwidth, pyparsing, prompt-toolkit, MarkupSafe, typing-extensions, tomlkit, termcolor, questionary, pyyaml, packaging, jinja2, decli, colorama, argcomplete, commitizen
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Successfully installed MarkupSafe-2.1.0 argcomplete-1.12.3 colorama-0.4.4 commitizen-2.[21](https://github.com/datanrd/dialexa-python-cookiecutter/runs/5259326201?check_suite_focus=true#step:4:21).0 decli-0.5.2 jinja2-3.0.3 packaging-21.3 prompt-toolkit-3.0.28 pyparsing-3.0.7 pyyaml-6.0 questionary-1.10.0 termcolor-1.1.0 tomlkit-0.10.0 typing-extensions-4.1.1 wcwidth-0.2.5
WARNING: You are using pip version 21.2.4; however, version [22](https://github.com/datanrd/dialexa-python-cookiecutter/runs/5259326201?check_suite_focus=true#step:4:22).0.3 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Commitizen version:
2.21.0
Configuring git user and email...
Git name: github-actions[bot]
Git email: github-actions[bot]@users.noreply.github.com
Running cz:   --changelog 
bump: version 0.1.0 → 0.1.1
tag to create: 0.1.1
increment detected: PATCH

No tag found to do an incremental changelog

When running cz bump --yes --changelog locally it completes without error.

@floredelasteyrie
Copy link
Contributor

I'm having the same issue.
Also, it's a problem that it breaks existing CIs in which I have fixed the version - which worked fine until the underlying package changed.

Using the action:

id: commitizen
uses: commitizen-tools/[email protected]
with:
    github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }}

Logs from my failing workflow:

Commitizen version:
2.21.0
Running cz:   --changelog 
[NO_COMMITS_TO_BUMP]
The commits found are not elegible to be bumped
chore(version): 0.6.2 → 0.6.2
tag to create: 0.6.2
increment detected: None

@woile
Copy link
Member

woile commented Feb 21, 2022

That's very strange, gonna take a look, thanks for reporting!

@woile
Copy link
Member

woile commented Feb 21, 2022

Could you share some samples of the commits that are not being detected?

thanks!

@floredelasteyrie
Copy link
Contributor

I think I didn't give enough details, sorry about that !

For my part the problem isn't that the commit isn't detected, but rather that now the action fails for a specific case when before it didn't :)
So feat or fix commits work fine, but ci or perf commits make the whole CI fail.
I solved it for the moment by using continue-on-error: true in my workflow, but I'm afraid of the other errors this could lead to.

I assume it's due to this patch : commitizen-tools/commitizen#473
But the fact that the version of the action (v0.11.0) can use different package versions is a problem - shouldn't we choose to update the action to use a new version of Commitizen ?

@woile
Copy link
Member

woile commented Feb 21, 2022

I think we could make the action point to latest by default, or manually enter the version.
I think the problem here is that I introduced a change that I didn't think was gonna break commitizen.
It should've been a major release if I had known better, I apologise for that 🙏🏻

@woile
Copy link
Member

woile commented Feb 21, 2022

I've created a PR to introduce the version, if you could review I'd appreciate

#20

@floredelasteyrie
Copy link
Contributor

Great idea to be able to manually enter the version while keeping the original latest by default :)

Thanks a lot for the quick fix ! I looked at the PR and added a comment - I'm not very familiar with the codebase but can review if needed !

@datanrd
Copy link
Author

datanrd commented Mar 2, 2022

@floredelasteyrie I've proposed another option in #21 that may be useful to your situation as well.

@woile
Copy link
Member

woile commented Mar 7, 2022

New changes to revert back the version were introduced already in this action.
I'm working on this PR as well: commitizen-tools/commitizen#489 which I'll then integrate into this action

@woile
Copy link
Member

woile commented Apr 29, 2022

Please review #25 it should solve the issue and bring back functionality

@Kurt-von-Laven
Copy link
Contributor

@datanrd, No tag found to do an incremental changelog suggests to me that you may have started doing a sparse checkout by failing to pass fetch-depth: 0 to actions/checkout. A sparse checkout does not include tags, so Commitizen cannot do its job.

@adam-grant-hendry
Copy link
Contributor

@woile Is this not fixed yet? I am having the same issue on:

commitizen: 2.35.0
commitizen-tools/commitizen-action: 0.15.0

@woile
Copy link
Member

woile commented Oct 7, 2022

What happens if you do git tag in the CI? Does any version appear?

@adam-grant-hendry
Copy link
Contributor

@Kurt-von-Laven @woile I'm not thinking; I'm sorry. I need fetch-depth to checkout the last version tag, not the new one I'm trying to create.

@Kurt-von-Laven
Copy link
Contributor

Yeah, and just to be clear for the sake of anyone following this thread, my understanding is that passing fetch-depth: n for any value of n other than 0, retrieves no tags at all since you are still doing a sparse checkout.

@adam-grant-hendry
Copy link
Contributor

@woile @Kurt-von-Laven How can I push without triggering CI? GitHub supports adding a comment to the commit message, like [skip ci] that will skip CI.

Can I do this somehow with the commitizen-action?

@adam-grant-hendry
Copy link
Contributor

@Kurt-von-Laven @woile I suppose for now, I can add

if: "!startsWith(github.event.head_commit.message, 'bump:')"

to the beginning of those workflow jobs I don't want to run when this happens.

Just wondering if there's another way to do this?

@woile
Copy link
Member

woile commented Oct 7, 2022

You could customize the bump commit message to include skip ci and use that condition with skip ci instead of bump:

@adam-grant-hendry
Copy link
Contributor

@woile How do you customize the message from within a GitHub Actions workflow?

@Kurt-von-Laven
Copy link
Contributor

Do the official Commitizen docs answer your question?

@adam-grant-hendry
Copy link
Contributor

Do the official Commitizen docs answer your question?

No because that gives you general information about how to customize all commit messages, but we would need to customize the message to have a comment if the bump: is in the message.

This probably involves some form of a regular expression I'm sure...

@Kurt-von-Laven
Copy link
Contributor

Oh, I see your point. Maybe this is a feature request for commitizen-tools/commitizen in that case? @woile will know better than I though.

@adam-grant-hendry
Copy link
Contributor

No worries at all. I'm sure I could figure it out if I devoted more time to it, but it's more time than I have to commit at the given moment. It would be nice as an example added to the documentation, so a feature request sounds appropriate.

@adam-grant-hendry
Copy link
Contributor

@Kurt-von-Laven @woile I need to

  • bump versions
  • build multiple wheels to that version for different platforms, and finally
  • create a release with all the wheels

I'm trying to figure out how to do this. I'm not able to update a release once it's created, but I'm also not finding a way to pass ${{ env.REVISION }} from the bump version step to the release step (${{ github.ref_name }} is main for me, not my tag).

How can I achieve this?

@adam-grant-hendry
Copy link
Contributor

@Kurt-von-Laven @woile nvm, I figured it out. I had to use your repo plus https://github.com/ncipollo/release-action. See this run

@metya
Copy link

metya commented Feb 27, 2023

Any news about the issue?
I have the same problem and don't know how to fix.

@Kurt-von-Laven
Copy link
Contributor

@metya, are you already passing fetch-depth: 0 to actions/checkout? I'm actually not sure why this issue is still open. @woile, did you envision some further change beyond #20 and #25?

@adam-grant-hendry, I recently learned of semantic-release, which may be helpful to you or others in the future with more complex use cases.

@woile
Copy link
Member

woile commented Feb 28, 2023

No, it should've been closed. @metya this ticket discusses multiple different problems, please open a new issue with your problem and provide more information.

In github actions if you use the GITHUB_TOKEN, it behaves as using [skip-ci].

If you need to add [skip-ci] it won't solve anything in github actions, because it doesn't care about it. But you can add it by using:

[tool.commitizen]
bump_message = "release $current_version → $new_version [skip-ci]"

Alternatively, you can skip a commit in github actions using:

if: "!startsWith(github.event.head_commit.message, 'bump:')"

see commitizen action

If you need to make a release, look at commitizen's documentation

I'm closing this as it's off-topic, please open new issues for other problems

@woile woile closed this as completed Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants