Skip to content
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

Action does not find a specified file in version_files #83

Open
lulingar opened this issue May 17, 2024 · 8 comments
Open

Action does not find a specified file in version_files #83

lulingar opened this issue May 17, 2024 · 8 comments

Comments

@lulingar
Copy link

lulingar commented May 17, 2024

Scenario

  • A repository holding a python project, with the following structure:
repo-root/
├── .cz.toml
├── .gitignore
├── src
│   ├── pypackage
│   │   ├── __init__.py
│   │   └── ...
│   ├── pyproject.toml
│   └── requirements.txt
└── test
    └── ...
  • The contents of .cz.toml being:
[tool.commitizen]
version = "0.0.5"
tag_format = "v$major.$minor.$patch"
version_scheme = "semver"
version_provider = "pep621"
major_version_zero = true
update_changelog_on_bump = false
version_files = [
    "src/pyproject.toml:version",
]
  • The invocation of this action
- id: cz
  name: Commitizen | Bump
  uses: commitizen-tools/commitizen-action@master
  with:
    push: false
    commit: false
    increment: PATCH
    github_token: ${{ secrets.MYTOKEN }}
    changelog: false

Expected outcome

Running the cz job step should succeed, bumping the version on .cz.toml and src/pyproject.toml.

Actual outcome (failure)

The log of execution is:

Run commitizen-tools/commitizen-action@master
/usr/local/bin/docker run --name ae4c464ff0919c3743e7818646fbeb9524d7_a3ecf2 --label 43ae4c --workdir /github/workspace --rm -e "INPUT_PUSH" -e "INPUT_COMMIT" -e "INPUT_INCREMENT" -e "INPUT_GITHUB_TOKEN" -e "INPUT_CHANGELOG" -e "INPUT_DEBUG" -e "INPUT_DRY_RUN" -e "INPUT_MERGE" -e "INPUT_PRERELEASE" -e "INPUT_DEVRELEASE" -e "INPUT_LOCAL_VERSION" -e "INPUT_REPOSITORY" -e "INPUT_BRANCH" -e "INPUT_EXTRA_REQUIREMENTS" -e "INPUT_CHANGELOG_INCREMENT_FILENAME" -e "INPUT_GIT_REDIRECT_STDERR" -e "INPUT_GIT_NAME" -e "INPUT_GIT_EMAIL" -e "INPUT_COMMITIZEN_VERSION" -e "INPUT_NO_RAISE" -e "INPUT_CHECK_CONSISTENCY" -e "INPUT_GPG_SIGN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_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_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_EVENT_PATH" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "GITHUB_ACTION" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/runner/_work/_temp/_github_home":"/github/home" -v "/runner/_work/_temp/_github_workflow":"/github/workflow" -v "/runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/runner/_work/myrepo/myrepo":"/github/workspace" 43ae4c:464ff0919c3743e7818646fbeb9524d7
gpg (GnuPG) 2.4.4
libgcrypt 1.10.3
Copyright (C) 2024 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /github/home/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
git version 2.43.4
Configuring Git username, email, and pull behavior...
Git name: github-actions[bot]
Git email: github-actions[bot]@users.noreply.github.com
pip install commitizen
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-3.25.0-py3-none-any.whl (70 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.2/70.2 kB 11.6 MB/s eta 0:00:00
...
Successfully installed MarkupSafe-2.1.5 argcomplete-3.3.0 charset-normalizer-3.3.2 colorama-0.4.6 commitizen-3.25.0 decli-0.6.2 importlib_metadata-7.1.0 jinja2-3.1.4 packaging-24.0 prompt_toolkit-3.0.36 pyyaml-6.0.1 questionary-2.0.1 termcolor-2.4.0 tomlkit-0.12.5 wcwidth-0.2.13 zipp-3.18.2
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

Notice:  A new release of pip is available: 23.0.1 -> 24.0
Notice:  To update, run: pip install --upgrade pip
Commitizen version: 3.25.0
Traceback (most recent call last):
  File "/usr/local/bin/cz", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/commitizen/cli.py", line 607, in main
    args.func(conf, arguments)()
  File "/usr/local/lib/python3.10/site-packages/commitizen/commands/version.py", line 25, in __call__
    version = get_provider(self.config).get_version()
  File "/usr/local/lib/python3.10/site-packages/commitizen/providers/base_provider.py", line 79, in get_version
    document = tomlkit.parse(self.file.read_text())
  File "/usr/local/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/local/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'
@woile
Copy link
Member

woile commented May 17, 2024

Can you share the full action?

@lulingar
Copy link
Author

The relevant job is as follows:

jobs:
  ...
  bump:
    name: Bump Version & Release
    needs:
    - build
    - lint-and-test
    - is-release
    runs-on: ...
    steps:
    - name: Checkout
      uses: actions/checkout@v4.1.4
      with:
        token: ${{ secrets.TOKEN }}
        fetch-depth: 0

    - id: cz
      name: Commitizen | Bump
      uses: commitizen-tools/commitizen-action@master
      with:
        push: false
        commit: false
        increment: PATCH
        github_token: ${{ secrets.TOKEN }}
        changelog: false

    - name: Git | Commit & Push
      uses: stefanzweifel/git-auto-commit-action@v5
      with:
        commit_message: '[skip actions]: bump to v${{ steps.cz.outputs.version }}'
        tagging_message: v${{ steps.cz.outputs.version }}

@woile
Copy link
Member

woile commented May 17, 2024

Is the file in the repository?

@lulingar
Copy link
Author

lulingar commented May 17, 2024

Well, of course it is.

@woile
Copy link
Member

woile commented May 17, 2024

Can you add a step before the cz action?

- run: |
  tree -L 3
# and then the cz 
- id: cz

@lulingar
Copy link
Author

lulingar commented May 17, 2024

As a workaround, I replaced the action by installing commitizen in a virtualenv during the workflow job, and when run, it resulted in the same exact error! So I called commitizen like:

cd src/
cz bump

and it worked. So I am moving the contents of .cz.toml back into src/pyproject.toml as a subsection, removing the version_files stanza.

@lulingar
Copy link
Author

I would suggest the action to provide an optional input root_dir, under which cz will be invoked if passed.

@woile
Copy link
Member

woile commented May 17, 2024

I see, I was under the assumption that you had a pyproject.toml at the root of the project.

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

2 participants