Skip to content

Conversation

@adriantombu
Copy link

As promised almost 3 months ago, here's a script that checks for the following criterias for the existing crates listed on the repo:

  • The crate has at least 4k recent downloads on crates.io
  • The package's repository is not archived

I also added back crates I previously removed by error and cleaned existing ones that did not meet the above criterias.

Please note that I am by no means any good in bash scripting so I did my very best here and probably spent too much time writing those lines.

As a future addition in another PR, we can add the check to the last criteria ("The package is not flagged as unmaintained in the Rust security advisory database") to clean some crates that have gone unmaintained for many years.

@adriantombu adriantombu requested a review from a team October 19, 2024 13:16
@adriantombu adriantombu self-assigned this Oct 19, 2024
@LukeMathWalker
Copy link

Thanks for taking the time!
Could we run it in CI, perhaps skipping the GitLab part, if it indeed requires a token?

# No "archived" status on Bitbucket: https://jira.atlassian.com/browse/BCLOUD-18018
ARCHIVED="false"
elif [[ "$REPOSITORY" == *"gitlab.com"* ]]; then
DATA=$(curl -s -H "Accept:application/json" -H "Authorization: Bearer $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/$ENCODED_OWNER_REPO")

Choose a reason for hiding this comment

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

It doesn't look like we need auth for this? https://docs.gitlab.com/ee/api/projects.html#get-a-single-project

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately an authenticated call to the Gitlab API only returns a fraction of the project fields and archived is not part of it.

It's not well described in their doc, you juste have a brief explanation of it in https://docs.gitlab.com/ee/api/projects.html#list-all-projects where they talk about

When simple=true or the user is unauthenticated this returns something like:

ENCODED_OWNER_REPO="${OWNER_REPO//\//%2F}"

if [[ "$REPOSITORY" == *"github.com"* ]]; then
DATA=$(curl -s -H "Accept:application/json" -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER_REPO")

Choose a reason for hiding this comment

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

Same here, we don't need a token for public repositories: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#get-a-repository

Copy link
Author

Choose a reason for hiding this comment

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

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.

2 participants