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

Issue with Coverage Reporting: 'relative_files = true' Not Resolved #499

Open
merajhashemi opened this issue Nov 10, 2024 · 1 comment
Open

Comments

@merajhashemi
Copy link

Hello,

I've been successfully using this action to report test coverage in our GitHub repository. However, after returning to the project after a two-month hiatus, I noticed that coverage reporting is now failing. I've tried various troubleshooting steps, including:

  • Reverting to older versions of python-coverage-comment-action.
  • Reverting to older versions of python-coverage.
  • Ensuring my .coveragerc file has relative_files = true, as suggested in the error message.

Unfortunately, these efforts haven't resolved the issue.

Full error log

Run py-cov-action/python-coverage-comment-action@v3
  with:
    GITHUB_TOKEN: ***
    MINIMUM_GREEN: 90
    MINIMUM_ORANGE: 80
    COVERAGE_DATA_BRANCH: python-coverage-comment-action-data
    COVERAGE_PATH: .
    COMMENT_ARTIFACT_NAME: python-coverage-comment-action
    COMMENT_FILENAME: python-coverage-comment-action.txt
    MAX_FILES_IN_COMMENT: 25
    MERGE_COVERAGE_FILES: false
    ANNOTATE_MISSING_LINES: false
    ANNOTATION_TYPE: warning
    VERBOSE: false
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.10.15/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib
/usr/bin/docker run --name f50b3de78a6fd0178e40edb9b52db20a3e5b93_0b6cd3 --label f50b3d --workdir /github/workspace --rm -e "pythonLocation" -e "PKG_CONFIG_PATH" -e "Python_ROOT_DIR" -e "Python2_ROOT_DIR" -e "Python3_ROOT_DIR" -e "LD_LIBRARY_PATH" -e "INPUT_GITHUB_TOKEN" -e "INPUT_MINIMUM_GREEN" -e "INPUT_MINIMUM_ORANGE" -e "INPUT_GITHUB_PR_RUN_ID" -e "INPUT_COMMENT_TEMPLATE" -e "INPUT_COVERAGE_DATA_BRANCH" -e "INPUT_COVERAGE_PATH" -e "INPUT_COMMENT_ARTIFACT_NAME" -e "INPUT_COMMENT_FILENAME" -e "INPUT_SUBPROJECT_ID" -e "INPUT_MAX_FILES_IN_COMMENT" -e "INPUT_MERGE_COVERAGE_FILES" -e "INPUT_ANNOTATE_MISSING_LINES" -e "INPUT_ANNOTATION_TYPE" -e "INPUT_VERBOSE" -e "GITHUB_TOKEN" -e "GITHUB_PR_RUN_ID" -e "COMMENT_TEMPLATE" -e "COVERAGE_DATA_BRANCH" -e "COVERAGE_PATH" -e "COMMENT_ARTIFACT_NAME" -e "COMMENT_FILENAME" -e "SUBPROJECT_ID" -e "MINIMUM_GREEN" -e "MINIMUM_ORANGE" -e "MERGE_COVERAGE_FILES" -e "ANNOTATE_MISSING_LINES" -e "ANNOTATION_TYPE" -e "VERBOSE" -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_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -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 "/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/cooper/cooper":"/github/workspace" f50b3d:e78a6fd0178e40edb9b52db20a3e5b93
Notice: Starting action
Notice: HTTP Request: GET https://api.github.com/repos/cooper-org/cooper "HTTP/1.1 200 OK"
Notice: Generating comment for PR
Error: Cannot read .coverage files because files are absolute. You need to configure coverage to write relative paths by adding the following option to your coverage configuration file:
[run]
relative_files = true

Note that the specific format can be slightly different if you're using setup.cfg or pyproject.toml. See details in: https://coverage.readthedocs.io/en/latest/config.html#config-run-relative-files
Error: Critical error. This error possibly occurred because the permissions of the workflow are set incorrectly. You can see the correct setting of permissions here: https://github.com/py-cov-action/python-coverage-comment-action#basic-usage
Otherwise please look for open issues or open one in https://github.com/py-cov-action/python-coverage-comment-action/
Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 22, in run
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('coverage', 'json', '-o', '-')' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workdir/coverage_comment/main.py", line 44, in main
    exit_code = action(
                ^^^^^^^
  File "/workdir/coverage_comment/main.py", line 96, in action
    return process_pr(
           ^^^^^^^^^^^
  File "/workdir/coverage_comment/main.py", line 127, in process_pr
    _, coverage = coverage_module.get_coverage_info(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workdir/coverage_comment/coverage.py", line 109, in get_coverage_info
    subprocess.run("coverage", "json", "-o", "-", path=coverage_path)
  File "/workdir/coverage_comment/subprocess.py", line 36, in run
    raise SubProcessError("\n".join([exc.stderr, exc.stdout])) from exc
coverage_comment.subprocess.SubProcessError: 
No source for code: '/tmp/tmptjq_oued/_remote_module_non_scriptable.py'.

Here is the repository link and branch where this issue is occurring: cooper-org/cooper. The action is running in this pull request: cooper-org/cooper/#98.

Could you help investigate what might be causing this issue?
Thank you!

@merajhashemi
Copy link
Author

Full debug log:

##[debug]Evaluating condition for step: 'Coverage comment'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Coverage comment
##[debug]Loading inputs
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run py-cov-action/python-coverage-comment-action@v3
  with:
    GITHUB_TOKEN: ***
    MINIMUM_GREEN: 90
    MINIMUM_ORANGE: 80
    COVERAGE_DATA_BRANCH: python-coverage-comment-action-data
    COVERAGE_PATH: .
    COMMENT_ARTIFACT_NAME: python-coverage-comment-action
    COMMENT_FILENAME: python-coverage-comment-action.txt
    MAX_FILES_IN_COMMENT: 25
    MERGE_COVERAGE_FILES: false
    ANNOTATE_MISSING_LINES: false
    ANNOTATION_TYPE: warning
    VERBOSE: false
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.10.15/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.15/x64/lib
##[debug]Evaluating: inputs.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: inputs.GITHUB_PR_RUN_ID
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_PR_RUN_ID'
##[debug]=> ''
##[debug]Result: ''
##[debug]Evaluating: inputs.COMMENT_TEMPLATE
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'COMMENT_TEMPLATE'
##[debug]=> ''
##[debug]Result: ''
##[debug]Evaluating: inputs.COVERAGE_DATA_BRANCH
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'COVERAGE_DATA_BRANCH'
##[debug]=> 'python-coverage-comment-action-data'
##[debug]Result: 'python-coverage-comment-action-data'
##[debug]Evaluating: inputs.COVERAGE_PATH
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'COVERAGE_PATH'
##[debug]=> '.'
##[debug]Result: '.'
##[debug]Evaluating: inputs.COMMENT_ARTIFACT_NAME
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'COMMENT_ARTIFACT_NAME'
##[debug]=> 'python-coverage-comment-action'
##[debug]Result: 'python-coverage-comment-action'
##[debug]Evaluating: inputs.COMMENT_FILENAME
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'COMMENT_FILENAME'
##[debug]=> 'python-coverage-comment-action.txt'
##[debug]Result: 'python-coverage-comment-action.txt'
##[debug]Evaluating: inputs.SUBPROJECT_ID
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SUBPROJECT_ID'
##[debug]=> ''
##[debug]Result: ''
##[debug]Evaluating: inputs.MINIMUM_GREEN
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MINIMUM_GREEN'
##[debug]=> '90'
##[debug]Result: '90'
##[debug]Evaluating: inputs.MINIMUM_ORANGE
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MINIMUM_ORANGE'
##[debug]=> '80'
##[debug]Result: '80'
##[debug]Evaluating: inputs.MERGE_COVERAGE_FILES
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MERGE_COVERAGE_FILES'
##[debug]=> 'false'
##[debug]Result: 'false'
##[debug]Evaluating: inputs.ANNOTATE_MISSING_LINES
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'ANNOTATE_MISSING_LINES'
##[debug]=> 'false'
##[debug]Result: 'false'
##[debug]Evaluating: inputs.ANNOTATION_TYPE
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'ANNOTATION_TYPE'
##[debug]=> 'warning'
##[debug]Result: 'warning'
##[debug]Evaluating: inputs.VERBOSE
##[debug]Evaluating Index:
##[debug]..Evaluating inputs:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'VERBOSE'
##[debug]=> 'false'
##[debug]Result: 'false'
/usr/bin/docker run --name e5381af9ccf5447fe47508d19ce62d88e0bcd_fc128e --label 3e5381 --workdir /github/workspace --rm -e "pythonLocation" -e "PKG_CONFIG_PATH" -e "Python_ROOT_DIR" -e "Python2_ROOT_DIR" -e "Python3_ROOT_DIR" -e "LD_LIBRARY_PATH" -e "INPUT_GITHUB_TOKEN" -e "INPUT_MINIMUM_GREEN" -e "INPUT_MINIMUM_ORANGE" -e "INPUT_GITHUB_PR_RUN_ID" -e "INPUT_COMMENT_TEMPLATE" -e "INPUT_COVERAGE_DATA_BRANCH" -e "INPUT_COVERAGE_PATH" -e "INPUT_COMMENT_ARTIFACT_NAME" -e "INPUT_COMMENT_FILENAME" -e "INPUT_SUBPROJECT_ID" -e "INPUT_MAX_FILES_IN_COMMENT" -e "INPUT_MERGE_COVERAGE_FILES" -e "INPUT_ANNOTATE_MISSING_LINES" -e "INPUT_ANNOTATION_TYPE" -e "INPUT_VERBOSE" -e "GITHUB_TOKEN" -e "GITHUB_PR_RUN_ID" -e "COMMENT_TEMPLATE" -e "COVERAGE_DATA_BRANCH" -e "COVERAGE_PATH" -e "COMMENT_ARTIFACT_NAME" -e "COMMENT_FILENAME" -e "SUBPROJECT_ID" -e "MINIMUM_GREEN" -e "MINIMUM_ORANGE" -e "MERGE_COVERAGE_FILES" -e "ANNOTATE_MISSING_LINES" -e "ANNOTATION_TYPE" -e "VERBOSE" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "
Notice: Starting action
##[debug]load_ssl_context verify=True cert=None trust_env=True http2=False
##[debug]load_verify_locations cafile='/usr/local/lib/python3.12/site-packages/certifi/cacert.pem'
##[debug]load_ssl_context verify=True cert=None trust_env=True http2=False
##[debug]load_verify_locations cafile='/usr/local/lib/python3.12/site-packages/certifi/cacert.pem'
##[debug]Operating on refs/pull/98/merge
##[debug]connect_tcp.started host='api.github.com' port=443 local_address=None timeout=60 socket_options=None
##[debug]connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f32ff870740>
##[debug]start_tls.started ssl_context=<ssl.SSLContext object at 0x7f32fe6127d0> server_hostname='api.github.com' timeout=60
##[debug]start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f32fe7d1400>
##[debug]send_request_headers.started request=<Request [b'GET']>
##[debug]send_request_headers.complete
##[debug]send_request_body.started request=<Request [b'GET']>
##[debug]send_request_body.complete
##[debug]receive_response_headers.started request=<Request [b'GET']>
##[debug]receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Wed, 13 Nov 2024 00:38:07 GMT'), (b'Content-Type', b'application/json; charset=utf-8'), (b'Cache-Control', b'private, max-age=60, s-maxage=60'), (b'Vary', b'Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With'), (b'ETag', b'W/"dd49f3d4a6d46fdfd205b8b08e36e9239ce8e8af322855b2c6fb40af0667fc50"'), (b'Last-Modified', b'Wed, 02 Oct 2024 07:14:09 GMT'), (b'X-GitHub-Media-Type', b'github.v3; format=json'), (b'x-accepted-github-permissions', b'metadata=read'), (b'x-github-api-version-selected', b'2022-11-28'), (b'X-RateLimit-Limit', b'5000'), (b'X-RateLimit-Remaining', b'4999'), (b'X-RateLimit-Reset', b'1731461887'), (b'X-RateLimit-Used', b'1'), (b'X-RateLimit-Resource', b'core'), (b'Access-Control-Expose-Headers', b'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted
Notice: HTTP Request: GET https://api.github.com/repos/cooper-org/cooper "HTTP/1.1 200 OK"
##[debug]receive_response_body.started request=<Request [b'GET']>
##[debug]receive_response_body.complete
##[debug]response_closed.started
##[debug]response_closed.complete
Notice: Generating comment for PR
##[debug]Command failed: args=('coverage', 'json', '-o', '-') path=PosixPath('.') kwargs={} exc.stderr='' exc.returncode=1
Error: Cannot read .coverage files because files are absolute. You need to configure coverage to write relative paths by adding the following option to your coverage configuration file:
[run]
relative_files = true

Note that the specific format can be slightly different if you're using setup.cfg or pyproject.toml. See details in: https://coverage.readthedocs.io/en/latest/config.html#config-run-relative-files
Error: Critical error. This error possibly occurred because the permissions of the workflow are set incorrectly. You can see the correct setting of permissions here: https://github.com/py-cov-action/python-coverage-comment-action#basic-usage
Otherwise please look for open issues or open one in https://github.com/py-cov-action/python-coverage-comment-action/
Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 22, in run
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('coverage', 'json', '-o', '-')' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workdir/coverage_comment/main.py", line 44, in main
    exit_code = action(
                ^^^^^^^
  File "/workdir/coverage_comment/main.py", line 96, in action
    
##[debug]Docker Action run completed with exit code 1
##[debug]Finishing: Coverage comment

@ewjoachim, could this be connected to issue #303? Do you have any suggestions on how I might resolve it?

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

1 participant