coveralls-python-action icon indicating copy to clipboard operation
coveralls-python-action copied to clipboard

Test with pyproject.toml existence

Open miurahr opened this issue 4 years ago • 11 comments

README express toml support. Because actions does not install toml extension so it always fails. This PR add pyproject.toml and CI will test with the file.

Signed-off-by: Hiroshi Miura [email protected]

miurahr avatar May 03 '21 02:05 miurahr

Will this be merged soon?

mcarans avatar Oct 14 '21 21:10 mcarans

It's not completely clear to me what's the problem we're trying to solve here to be honest. This action only deals with calling coveralls to upload the reports, but not running the actual coverage test. The coverage testing should be run from the calling project itself, and the comes the action to deal with the upload and few tweaks

AndreMiras avatar Oct 15 '21 09:10 AndreMiras

@AndreMiras The problem for me is that all my configuration is in pyproject.toml and the action fails. It looks like it is because it is unable to load that configuration. Maybe it doesn't need to, but uses the coverage dependency which tries to - I don't know. See: https://github.com/AndreMiras/coveralls-python-action/issues/20. It would be good if you could see how to make a setup with the action for a project with no tox.ini, .coveragerc etc., only a pyproject.toml with coverage settings in it.

mcarans avatar Oct 15 '21 17:10 mcarans

I have the same problem. Here us a full traceback.

Run AndreMiras/coveralls-python-action@develop
/usr/bin/docker run --name b62799ca4966efb4690b85e38d2163587d2_473d11 --label 905b62 --workdir /github/workspace --rm -e INPUT_BASE-PATH -e INPUT_GITHUB-TOKEN -e INPUT_PARALLEL -e INPUT_PARALLEL-FINISHED -e INPUT_FLAG-NAME -e INPUT_DEBUG -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/service-mida/service-mida":"/github/workspace" 905b62:799ca4966efb4690b85e38d2163587d2  "--github-token" "***" "--base-path" "src" "--flag-name" "" "--parallel" "false" "--parallel-finished" "false" "--debug" "false"
Trying submitting coverage with service_name: github...
cd src
cd /github/workspace
Can't read 'pyproject.toml' without TOML support. Install with [toml] extra
Traceback (most recent call last):
  File "/src/entrypoint.py", line 176, in try_main
    main()
  File "/src/entrypoint.py", line 171, in main
    run_coveralls(repo_token, parallel, flag_name, base_path)
  File "/src/entrypoint.py", line 82, in run_coveralls
    result = coveralls.wear()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 254, in wear
    json_string = self.create_report()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 332, in create_report
    data = self.create_data()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 386, in create_data
    self._data = {'source_files': self.get_coverage()}
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 400, in get_coverage
    workman = coverage.coverage(config_file=config_file)
  File "/usr/local/lib/python3.10/site-packages/coverage/control.py", line 239, in __init__
    self.config = read_coverage_config(
  File "/usr/local/lib/python3.10/site-packages/coverage/config.py", line 545, in read_coverage_config
    config_read = config.from_file(fname, warn, our_file=our_file)
  File "/usr/local/lib/python3.10/site-packages/coverage/config.py", line 273, in from_file
    files_read = cp.read(filename)
  File "/usr/local/lib/python3.10/site-packages/coverage/tomlconfig.py", line 60, in read
    raise CoverageException(msg.format(filename))
coverage.exceptions.CoverageException: Can't read 'pyproject.toml' without TOML support. Install with [toml] extra
ExitCode.FAILURE

loicgasser avatar Dec 03 '21 18:12 loicgasser

In the end I gave up as I couldn't find a workaround and switched to codecov.

mcarans avatar Dec 03 '21 21:12 mcarans

@AndreMiras coveralls uses coverage under the hood like you can see in the traceback.

loicgasser avatar Dec 04 '21 17:12 loicgasser

I pushed modification for Dockerfile that fixes the issue. Because @AndreMiras did not allow github actions test for the PR, we can not observes failure by previous modification, and see the latter change resolve one.

miurahr avatar Dec 05 '21 00:12 miurahr

I'm getting the same traceback as @loicgasser. Switching to @miurahr's repository in my GH actions fixes the issue for me.

weibullguy avatar Dec 31 '21 20:12 weibullguy

What is the status of this PR? I'm running into this with my projects as I switch to pyproject.toml for all my configuration (over setup.cfg or other).

djhoese avatar May 25 '22 20:05 djhoese

Waiting @AndreMiras to see things under the hood clearly.

It's not completely clear to me what's the problem we're trying to solve here to be honest.

miurahr avatar May 26 '22 01:05 miurahr

Is there any update on this? Looks like just a missing dependency issue, coveralls depends on coverage, coverage raises if it sees pyproject.toml file with coverage config but can't find toml installed.

This actions is installing coveralls which in turns installs coverage, just adding toml to the requirements should fix it.

monim67 avatar Sep 10 '22 16:09 monim67

adjust comment on #20

miurahr avatar Oct 21 '22 06:10 miurahr

pyproject.toml is the new unified Python project settings file that (is supposed to) replace setup.py.

pyproject.toml is especially useful to avoid having a config file per each python tool used in your python app. E.g. I have a pyproject.toml hosting the config of black, iosort, coverage and cibuildwheel tools.

As such I would deem this feature as a must-have.

giampaolo avatar Dec 30 '22 22:12 giampaolo

I want to chime in here to echo that there is elevated need to support coverage configurations in pyproject.toml on this action. This standard has been adopted by PEP for several (5+) years now. I'm not sure why this hasn't been addressed to date.

Zeitsperre avatar Jan 24 '23 17:01 Zeitsperre

I want to add again that my PR #24 includes the actual toml dependencies from this PR without the extra configuration changes that don't seem to be needed. It may be easiest to merge my PR first and then see if anything from this PR is still needed.

djhoese avatar Jan 24 '23 18:01 djhoese

Thanks, I'll try to look this up over the weekend Edit: two weeks later, I didn't forget, just been terribly busy

AndreMiras avatar Jan 24 '23 18:01 AndreMiras

Hi Andre, thanks for this really nice work. We are still waiting for this fix :).

Run AndreMiras/coveralls-python-action@develop
  with:
    github-token: ***
    parallel: false
    parallel-finished: false
    base-path: .
    debug: false
  env:
    PIP_ONLY_BINARY: :all:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.16/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.16/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.16/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.16/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.16/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.16/x64/lib
/usr/bin/docker run --name c0442c9f7383073554d2c831a33f6d0fb33d1_0b584b --label 6c0442 --workdir /github/workspace --rm -e "PIP_ONLY_BINARY" -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_PARALLEL" -e "INPUT_PARALLEL-FINISHED" -e "INPUT_BASE-PATH" -e "INPUT_FLAG-NAME" -e "INPUT_DEBUG" -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_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/resample/resample":"/github/workspace" 6c0442:c9f7383073554d2c831a33f6d0fb33d1  "--github-token" "***" "--base-path" "." "--flag-name" "" "--parallel" "false" "--parallel-finished" "false" "--debug" "false"
Trying submitting coverage with service_name: github...
cd .
cd /github/workspace
Can't read 'pyproject.toml' without TOML support. Install with [toml] extra
Traceback (most recent call last):
  File "/src/entrypoint.py", line 176, in try_main
    main()
  File "/src/entrypoint.py", line 171, in main
    run_coveralls(repo_token, parallel, flag_name, base_path)
  File "/src/entrypoint.py", line 82, in run_coveralls
    result = coveralls.wear()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 254, in wear
    json_string = self.create_report()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 332, in create_report
    data = self.create_data()
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 386, in create_data
    self._data = {'source_files': self.get_coverage()}
  File "/usr/local/lib/python3.10/site-packages/coveralls/api.py", line 400, in get_coverage
    workman = coverage.coverage(config_file=config_file)
  File "/usr/local/lib/python3.10/site-packages/coverage/control.py", line 239, in __init__
    self.config = read_coverage_config(
  File "/usr/local/lib/python3.10/site-packages/coverage/config.py", line 545, in read_coverage_config
    config_read = config.from_file(fname, warn, our_file=our_file)
  File "/usr/local/lib/python3.10/site-packages/coverage/config.py", line 273, in from_file
    files_read = cp.read(filename)
  File "/usr/local/lib/python3.10/site-packages/coverage/tomlconfig.py", line 60, in read
    raise CoverageException(msg.format(filename))
coverage.exceptions.CoverageException: Can't read 'pyproject.toml' without TOML support. Install with [toml] extra
ExitCode.FAILURE

HDembinski avatar Apr 12 '23 12:04 HDembinski

For those who seek a temporary workaround: You can put the coverage configuration into .coveragerc. If this file is present, it takes precedence over pyproject.toml and the error disappears.

HDembinski avatar Apr 12 '23 12:04 HDembinski

@AndreMiras I ran into this in another project. Anything we can do to help? As a reminder, my PR #24 adds pyproject support and Cython.

djhoese avatar May 17 '23 18:05 djhoese

@AndreMiras I ran into this in another project. Anything we can do to help? As a reminder, my PR #24 adds pyproject support and Cython.

Merged thanks, let me know how it goes with it

AndreMiras avatar Jul 23 '23 12:07 AndreMiras

I just did a quick update to switch from my PR's branch to the develop branch here and it looks like it is all working. Thanks @AndreMiras. I think this can be closed.

djhoese avatar Jul 24 '23 15:07 djhoese

Thanks for the follow up, closing then

AndreMiras avatar Jul 24 '23 20:07 AndreMiras