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

Improvements for local dev and CI tools #66

Merged
merged 5 commits into from
Apr 2, 2022

Conversation

JWCook
Copy link
Contributor

@JWCook JWCook commented Apr 2, 2022

Closes #65. This also adds some other pytest, coverage, and GitHub Actions features that I use in my own projects. If there are any of these items you don't want, let me know and I'll remove it from the PR.

Scripts

  • Remove dev scripts from published package
  • Use nox to run dev scripts (lint, test, cover)
  • Use pytest-cov plugin to run coverage
    • Makes coverage commands/args simpler, and allows integration with xdist
  • Use pytest-xdist plugin to run tests in parallel
    • Given all the time.sleep() calls in tests, this significantly reduces total test time!
    • On GitHub Actions, the runners only have 2 cores, so time is roughly cut in half to ~2 mins 30 seconds. On my local machine it now runs in about 40 seconds.

GitHub Actions

  • Use cache action to cache python packages until lockfile changes
    • Saves around 45 seconds per run (on cache hit)
  • Use install-poetry action to install poetry
    • This uses the poetry installer, and puts poetry in its own virtualenv to avoid potential dependency conflicts
  • Use codecov-action to upload coverage
  • Upload coverage to codecov for PRs
    • Codecov automatically tracks coverage separately per branch
    • It also notifies you within a PR to show coverage changes (see example below)
    • It also adds a step to PR checks, and will fail if coverage decreases
    • The failure threshold can be configured in codecov.yml, if you want

@codecov
Copy link

codecov bot commented Apr 2, 2022

Codecov Report

Merging #66 (a8b9a45) into master (2e68f71) will decrease coverage by 0.90%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master      #66      +/-   ##
==========================================
- Coverage   98.73%   97.82%   -0.91%     
==========================================
  Files           8        8              
  Lines         316      322       +6     
  Branches        0       30      +30     
==========================================
+ Hits          312      315       +3     
  Misses          4        4              
- Partials        0        3       +3     
Impacted Files Coverage Δ
pyrate_limiter/bucket.py 93.51% <0.00%> (-2.78%) ⬇️
pyrate_limiter/request_rate.py 100.00% <0.00%> (ø)
pyrate_limiter/limit_context_decorator.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1087514...a8b9a45. Read the comment docs.

@JWCook JWCook marked this pull request as ready for review April 2, 2022 01:38
@JWCook
Copy link
Contributor Author

JWCook commented Apr 2, 2022

I'm not quite sure why that Codedov report is saying coverage decreased.

@vutran1710
Copy link
Owner

I'm not quite sure why that Codedov report is saying coverage decreased.

i dont think its a big deal. if you think evrything ready, i will merge the pr.

@JWCook
Copy link
Contributor Author

JWCook commented Apr 2, 2022

Yes, if it all looks good to you, go ahead and merge it.

@vutran1710 vutran1710 merged commit 54dd04f into vutran1710:master Apr 2, 2022
@JWCook JWCook deleted the dev-scripts branch April 2, 2022 15:25
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.

Poetry scripts get installed with PyPI package
2 participants