twisted / towncrier

Manage the release notes for your project.

Home Page:https://towncrier.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue using check compare-with --dir .

Andrea-Fan opened this issue · comments

I'm working with towncrier on a git repo. Towncrier on local works fine and when using it with check command it finds the fragment correctly.
I've also added a job to a gitlab pipeline that checks the fragments when opening a merge request. The job looks like this
sh 'pip install poetry '
sh 'pip install towncrier==23.6.0'
sh 'poetry run towncrier check --dir .'
when running that job towncrier fails with this output

Traceback (most recent call last):
File "/usr/local/bin/towncrier", line 8, in
sys.exit(cli())
^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/towncrier/check.py", line 64, in _main
__main(compare_with, directory, config)
File "/usr/local/lib/python3.11/dist-packages/towncrier/check.py", line 74, in __main
get_remote_branches(base_directory=base_directory)
File "/usr/local/lib/python3.11/dist-packages/towncrier/_git.py", line 21, in get_remote_branches
output = check_output(
^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'branch', '-r']' returned non-zero exit status 128.

Hi,

Can you link your CI config file?

Do you pull the full repo history and branch references when you checkout / close the repo inside the CI ?

Most of the time a CI will do a quick shallow clone.

I downloaded the code using GIT in a docker, executed MYPY, and then ran the code 'towncrier check --dir .'. Isn't it a file-checking method ., why does it give GIT related errors

pipeline {

agent {
    label 'linux-docker'
}

stages {
    stage('Run Tests'){
       agent {
            docker {
                label 'linux-docker'
                image 'thekevjames/nox:2023.4.22'
                args '-u root:root'
                reuseNode true
            }
        }
        stages{
            stage('Mypy') {
                steps {
                    sh 'nox -s mypy'
                }
            }
            stage('Check Changelog') {
                steps {                          
                    script { 
                        sh 'pip install   poetry  '
                        sh 'pip install towncrier==23.6.0'
                        sh 'poetry run towncrier check --dir  .'

I am not sure what are you trying to do here :)

Can you add more info?

towncrier check needs full access to the git repo history.

In this way it can check if the current branch has a newsfragment added in comparison with the main branch.

refer :issue using check compare-with #543