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

Fix pyproject.toml support #16

Closed
wants to merge 4 commits into from

Conversation

miurahr
Copy link
Contributor

@miurahr miurahr commented May 3, 2021

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 miurahr@linux.com

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@mcarans
Copy link

mcarans commented Oct 14, 2021

Will this be merged soon?

@AndreMiras
Copy link
Owner

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

@mcarans
Copy link

mcarans commented Oct 15, 2021

@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: #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.

@loicgasser
Copy link

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

@mcarans
Copy link

mcarans commented Dec 3, 2021

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

@loicgasser
Copy link

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

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@miurahr
Copy link
Contributor Author

miurahr commented Dec 5, 2021

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.

@weibullguy
Copy link

weibullguy commented Dec 31, 2021

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

@djhoese
Copy link
Contributor

djhoese commented May 25, 2022

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).

@miurahr
Copy link
Contributor Author

miurahr commented May 26, 2022

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.

@monim67
Copy link

monim67 commented Sep 10, 2022

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.

@miurahr
Copy link
Contributor Author

miurahr commented Oct 21, 2022

adjust comment on #20

@miurahr miurahr changed the title Test with pyproject.toml existence Fix pyproject.toml support Oct 21, 2022

[tool.coverage.report]
show_missing = true
exclude_lines = ["if __name__ == .__main__.:", "pragma: no-cover", "@abstract", "def __repr__"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line needed for pyproject.toml support? What is it doing? What about the other changes to this file? Is build-system needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build-system section is alternative of setup of setup.py. When there is no setup.py, and when using setuptools for build, it is to be a same configuraiton.

A file pyproject.toml is used for test, not to supporting pyproject.toml in users project.
These lines are adeed for testing purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing of the pyproject.toml support? I think the extra changes in this PR were a little confusing otherwise so it was more difficult to review by the maintainer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm well aware of what pyproject.toml is and its purpose. I was only trying to say that it isn't clearly mentioned in any comments or in the PR description what the extra configuration in this pyproject.toml is doing. The coverage configuration is different from the existing configuration in setup.cfg (which is not removed in this PR). You also define a build system where previously there wasn't one so it isn't clear why one is needed.

I'm also a little confused because the tests in push.yml and in make tests don't explicitly handle pyproject.toml so by putting it here in the root of the repository I assume all tests are now using this pyproject.toml. However, that doesn't test the absence of a pyproject.toml (by using the existing setup.cfg). Shouldn't both cases be tested? Perhaps with a subdirectory for different test configuration cases? One with a setup.cfg and one with a pyproject.toml?

@giampaolo
Copy link

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.

@Zeitsperre
Copy link

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.

@djhoese
Copy link
Contributor

djhoese commented Jan 24, 2023

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.

@AndreMiras
Copy link
Owner

AndreMiras commented Jan 24, 2023

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

@HDembinski
Copy link

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
Copy link

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.

@djhoese
Copy link
Contributor

djhoese commented May 17, 2023

@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.

@AndreMiras
Copy link
Owner

@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

@djhoese
Copy link
Contributor

djhoese commented Jul 24, 2023

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.

@AndreMiras
Copy link
Owner

Thanks for the follow up, closing then

@AndreMiras AndreMiras closed this Jul 24, 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

Successfully merging this pull request may close these issues.

None yet

10 participants