Skip to content

Add gitlab repositories information retrieval #1249

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

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jan 16, 2021

Part of #35

This PR refactors how we retrieve repositories information by creating a general Updater running specific ones and add the information retrieval for gitlab repositories.

Copy link
Member

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

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

Did a high level review of the PR. I agree with you that we should generalize, and move to a single database table, a single updater struct and a RepositoryHost trait implementing GitHub or GitLab specific parts.

@GuillaumeGomez GuillaumeGomez force-pushed the gitlab-support branch 2 times, most recently from 3326538 to 0348b9f Compare January 17, 2021 14:56
@jyn514 jyn514 added the A-backend Area: Webserver backend label Jan 17, 2021
@GuillaumeGomez
Copy link
Member Author

I made a repositories database which now handles both github and gitlab. Next step will be to clean up a bit the updaters. Having a trait for more generics will be welcome I assume. However, I think it's better to keep both of them separate, it makes going through the code simpler.

@Nemo157
Copy link
Member

Nemo157 commented Jan 18, 2021

I think it may make sense to have two levels here, a general RepositoryStatsUpdater that calls into the GithubUpdater/GitlabUpdater (which may be using some shared code). That would simplify the integration points: still only a single thread running the update loop, and only a single call from the builder to have it detect which implementation applies and call into it.

@GuillaumeGomez
Copy link
Member Author

Yes, I have something similar in mind.

@GuillaumeGomez GuillaumeGomez force-pushed the gitlab-support branch 4 times, most recently from d8a76f8 to 79449f2 Compare January 18, 2021 20:10
@GuillaumeGomez GuillaumeGomez force-pushed the gitlab-support branch 2 times, most recently from 8290d6a to d5a3d57 Compare January 19, 2021 10:38
@pietroalbini
Copy link
Member

I think there is still too much code duplication here. The trait should only contain code specific to the forge in question, so checking if a URL belongs to the forge, loading a single repository by its URL and loading multiple repositories by their IDs. Everything else, including every database interaction, should go into the main updater.

Also, it's probably time to move the whole thing out of utils into src/repositories/{mod,github,gitlab}.rs.

@GuillaumeGomez
Copy link
Member Author

I think there is still too much code duplication here. The trait should only contain code specific to the forge in question, so checking if a URL belongs to the forge, loading a single repository by its URL and loading multiple repositories by their IDs. Everything else, including every database interaction, should go into the main updater.

On it!

Also, it's probably time to move the whole thing out of utils into src/repositories/{mod,github,gitlab}.rs.

Any suggestion for the naming of the new module?

@pietroalbini
Copy link
Member

Any suggestion for the naming of the new module?

I guess just repositories.

@jyn514 jyn514 added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Jan 19, 2021
@GuillaumeGomez GuillaumeGomez force-pushed the gitlab-support branch 2 times, most recently from df571f6 to e9bf807 Compare January 19, 2021 20:26
@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Jan 19, 2021

Moved the repositories files into a repositories folder.

@GuillaumeGomez GuillaumeGomez marked this pull request as ready for review January 20, 2021 13:10
@GuillaumeGomez
Copy link
Member Author

I think it's now ready for review. :)

@GuillaumeGomez
Copy link
Member Author

Fixed conflict.

@GuillaumeGomez
Copy link
Member Author

I also added a test to ensure the regex update is working as expected.

Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

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

rpa, dockertest (repo is a sub-repo, I forgot how they were called in gitlab)

It works fine once the regex is fixed. :)
I tested it again, it works now.

Also I did another check on some random not found repos, and these were either really wrong, or moved.

phaser (repo url ends with .git, github integration seems to support this)

The repository doesn't exist: https://gitlab.com/bloom42/phaser (maybe it's private?).

Not sure how that failed, I just tried again and it's fine.

with_tempdir, biorustlings (repo was moved, I don't know the how github integration behaves here)

It simply doesn't work I guess? So until they update the repository URL, I don't think there is much we can do about...

let's keep it like that, agreed.

Anyway, I fixed the backward migration and the regex so now things are working as expected. :)

The backwards migration is still broken, I added a fixed sql statement that. (it works in a local test)

@GuillaumeGomez
Copy link
Member Author

The backwards migration is still broken, I added a fixed sql statement that. (it works in a local test)

I just realized I was testing the backward migration with a gitlab crate... Thanks a lot!

Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

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

so,

from looking at the code I don't see anything else we can test to be sure here. Also I guess the code itself had many iterations with @pietroalbini

Everything I tested works as it should, with gitlab- and github repos

  • migrations forward and backwards are fine now
  • the crate-detail page is fine with both github and gitlab repos
  • backfill and normal update work fine and put in data

of course I might be missing details I don't know about (yet), but IMHO this is good enough to go live. The risk of breaking something major is low, and the revert is easy and tested.

I don't know (yet) how the deploy-process works (order of server-restart and the migrations being executed), depending on that there will be a time where we will have server errors.

Building this in a non-destructive way (without server errors while deploying/migrating) is possible of course, but would add quite some work.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Could you update the PR description?

I left a lot of comments, but they're mostly nits, no major changes.

@jyn514 jyn514 added S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Apr 14, 2021
@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Apr 15, 2021
@GuillaumeGomez
Copy link
Member Author

Updated the description as well.

@GuillaumeGomez GuillaumeGomez changed the title Add gitlab support Add gitlab repositories information retrieval Apr 15, 2021
@jyn514 jyn514 added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Apr 15, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 15, 2021

It would be nice to squash the history a bit when you get a chance, things have changed quite a lot since the initial PR. If it's a pain to use logical commits I'm fine with one giant commit.

@GuillaumeGomez
Copy link
Member Author

For the history rewrite, I was waiting for the PR to get approved so I can squash everything in one commit and we're done for. Gonna do that in the next push.

* Create RepositoryStatsUpdater type to use as interface over updaters
* Add RepositoryStatsUpdater instance to global contexts so they can be used in CrateDetails
* Add Pool field into RepositoryStatsUpdater
* Return a default icon
* Add mock tests for github and gitlab updaters
@jyn514 jyn514 added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Apr 15, 2021
@jyn514 jyn514 merged commit 1e22bc1 into rust-lang:master Apr 15, 2021
@GuillaumeGomez GuillaumeGomez deleted the gitlab-support branch April 15, 2021 19:08
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend Area: Webserver backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants