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

[SYSTEMDS-3529] codecov badge + PyPI downloads badge #2029

Conversation

evelina-gudauskayte
Copy link
Contributor

@evelina-gudauskayte evelina-gudauskayte commented Jun 1, 2024

SYSTEMDS-3529

The task was to add to the repository two badges:

  1. PyPI downloads badge to show actual usage of the python API of systems and motivate people to contribute to the project.
  2. Code coverage badge for test coverage transparency

PyPI badge

I decided to include two separate badges to indicate download activity:

  • Downloads in the last month: This badge highlights the project's current usage by showing recent downloads.
  • Total downloads: This badge showcases the project's overall popularity with a potentially impressive number.

Another consideration was clarifying that the badges specifically refer to PyPI downloads, since systemd can be installed through various methods. To avoid misleading users, the badge text explicitly mentions 'PyPI downloads'.

I evaluated several methods for adding the PyPI download badges to the repository and chose the one that fits the best.

shields.io pypi badge

PyPI - Downloads
✅ Simple REST API to access the badge
✅ Reach customization options
✅ Static badge, no need for ci/cd pipeline to update it
✅ Direct REST API to get the badge
Open source project
✅ Does let you to change the text on the left side of the badge
Can show downloads for last month/week/day, cannot show total downloads

Shields.io uses another API to actually get the value of downloads → it serves as a wrapper.

I still needed the total number of badges, so I decided to take a look at the API that is used inside of shields.io badge in case it has more functionality than shields.io shows

PyPi stats API

✅ Simple REST API to access the data
✅ Reach customization options
Open source project
❌ No API to retrieve the badge, only shields.io is available
Can show downloads for last month/week/day, cannot show total downloads

PyPi stats API does not allow getting total downloads, therefore I did not want to use it.

Pepy.tech

Total PyPI downloads Monthly PyPI downloads

✅ Simple REST API to access the data
✅ Reach customization options
✅ Static badge, no need for ci/cd pipeline to update it
Open source project
✅ Does let you change the text on the left side of the badge
✅ Direct REST API to get the badge
✅ Can show total and monthly PyPI downloads

This solution showed itself the best, as the API allows me to create two badges that I was looking for. The only downside is that personalized-badge API is not well documented, and I had to read some of the source code to understand which customization options I actually had.

I decided to stay with the default gray and blue badge, as I think it nicely contrasts with other badges and hints that this data is about python.

This comment helped me find different solutions and understand different ways to count the downloads.

Codecov badge

For test coverage badge, I looked at how apache spark created their badge and decided to try replicating the approach.

How to codecov?

  1. You need to log in to codecov webside using the github account that has access to systemds repository
  2. Find systemds in the list of repositories on the website and click Configure
  3. You should be met with a page like that:
    image
  4. Set given token in projects SettingsSecrets and VariablesActions
  5. Trigger the CI/CD pipeline that runs the Java tests for systemds.
  6. After successful pipeline runs, Codecov will collect and display your code coverage data on a page like this: https://app.codecov.io/gh/*_your_username_*/systemds
  7. Go to the settings page for the systemds repository on Codecov (link provided in previous step). Find and copy the badge link (image provided might be helpful).
    image
  8. Change the link in README.md
  9. 🎉🎉🎉 Done! You've successfully configured the Codecov badge for your systemds repository!

Warnings! Read before merging ⚠️ ⚠️ ⚠️

Currently, the badge might show unknown instead of percent of test coverage as it looks into the main branch of my forked repository.
codecov
This is how it should look like, but this badge is configured to my draft feature branch in fork, instead of original main repo as I do not have such access.
codecov

You have to reconfigure the badge before the merge! Current state is not intended to be in the main branch of systemds.

@evelina-gudauskayte evelina-gudauskayte force-pushed the SYSTEMDS-3529_Code-coverage_PyPI_downloads branch from a1868f1 to d237ab5 Compare June 1, 2024 23:44
@evelina-gudauskayte
Copy link
Contributor Author

@mboehm7 hello!
I believe you are my mentor for this task, so I'd greatly appreciate it if you could take a look and provide your feedback when you have a chance.
Thanks in advance for your time!

@evelina-gudauskayte evelina-gudauskayte marked this pull request as ready for review June 2, 2024 00:23
@evelina-gudauskayte evelina-gudauskayte force-pushed the SYSTEMDS-3529_Code-coverage_PyPI_downloads branch from d237ab5 to fbd9cf4 Compare June 2, 2024 00:30
@mboehm7
Copy link
Contributor

mboehm7 commented Jun 2, 2024

LGTM - thanks @evelina-gudauskayte for the patch and very detailed instructions. I'll try to setup my account and reconfigure the code next week (before merging it in).

@mboehm7
Copy link
Contributor

mboehm7 commented Jun 4, 2024

Since we don't have access to the settings of the github repository, I looked around and found recent examples of Apache projects [1] using the same upload action v4. Apparently INFRA set it up globally already. So let's see and I'll give it a try.

[1] apache/nifi#8808

@mboehm7 mboehm7 closed this in 0f1c99c Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants