atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

feat: Add Gitea support

Open mvdkleijn opened this issue 1 year ago • 37 comments

what

Addition of Gitea client in order to close #3538

A functionally complete implementation of a client for Gitea, with the sole exception being the listing of teams that a user is a member of. However, that's not uncommon for other clients.

It was tested manually against both a Gitea and a Forgejo install. Automated tests were limited to the basics. A large part of the implementation uses the Gitea SDK.

why

See #3538

references

  • Closes #3538
  • Please test ghcr.io/mvdkleijn/atlantis:dev

testing

  • TestExecute_ValidateVCSConfig
  • TestExecute_GiteaUser
  • TestExecute_GiteaBaseURLScheme
  • TestExecute_GiteaWithWebhookSecret
  • TestExecute_GiteaBaseURLPort

Also: manual testing by @florianbeisel and @mvdkleijn against Gitea and Forgejo

mvdkleijn avatar Feb 11 '24 01:02 mvdkleijn

Small update for those keeping track: @florianbeisel found my PR and had also started work on his own version for this issue. After contacting me, we decided to work together on this PR.

mvdkleijn avatar Feb 13 '24 20:02 mvdkleijn

@GenPage @nitrocode @X-Guardian

This PR has been updated with the combined efforts of myself as well as @florianbeisel and we feel it has reached a point where we feel happy it works and is ready to receive feedback or approvals from maintainers and/or users.

Once approved, this will close #3538 by adding nearly full support for Gitea / Forgejo.

Additional Notes: Not implemented: GetTeamNamesForUser()

mvdkleijn avatar Feb 16 '24 22:02 mvdkleijn

I want to extend a huge thank you to @mvdkleijn who I had the pleasure working alongside on this PR. Martijn, It's collaborations like these that make our work not just successful, but also enjoyable.

Looking forward to more great teamwork in the future! Thank you for getting this of the ground!

florianbeisel avatar Feb 16 '24 22:02 florianbeisel

I love the collaboration; thanks, @florianbeisel and @mvdkleijn, for the work. Please be patient on the review, this is going to take a while.

jamengual avatar Feb 16 '24 23:02 jamengual

@mvdkleijn we are going to need docs/setup guide for gitea, same as we have for the other VCS and include whatever gitea specifics are in it.

jamengual avatar Feb 17 '24 04:02 jamengual

@mvdkleijn we are going to need docs/setup guide for gitea, same as we have for the other VCS and include whatever gitea specifics are in it.

On it. Will commit those sometime this weekend.

mvdkleijn avatar Feb 17 '24 09:02 mvdkleijn

Website docs added to PR

mvdkleijn avatar Feb 17 '24 12:02 mvdkleijn

Hi all. The pr says this is a draft and no tests. Is that accurate? If not, could you update this? Tests are always nice when adding a new feature as the feature could break in the future and tests would prevent merging a follow up breaking PR.

nitrocode avatar Feb 17 '24 20:02 nitrocode

Hi @nitrocode, the description needs to be updated - I think @mvdkleijn will be on this already. From our perspective this has now come out of a pure draft state. The implementation is functional complete and has been tested against a current self hosted Gitea instance and a Forgejo instance.

While you are right that more tests, more better we opted to concentrate on the tests that are testing the interfaces (TestPost_UnsupportedGiteaEvent etc,) first. From our point of view, writing a comprehensive test suite for the client itself would mostly be testing the gitea SDK which we weren't certain would be a real benefit.

P,S; yes one of those tests we have implemented is still failing :D

florianbeisel avatar Feb 17 '24 21:02 florianbeisel

@nitrocode Sorry, I forgot to update the description. Updated it.

Like @florianbeisel said, I'm looking atthe failed test. I was working on it last night but it was not co-operating. It is clear to me however that it is not a functional issue with our implementation.

I should have some time to work on that today.

Having said all that, the implementation is functionally done and documentation was added / updated as well.

mvdkleijn avatar Feb 18 '24 08:02 mvdkleijn

Thanks @florianbeisel I think I was over-complicating things for myself causing some code blindness in between bouts of my kid not feeling well. :)

@nitrocode All tests working. All docs present. Dependencies back to what they should be.

mvdkleijn avatar Feb 19 '24 10:02 mvdkleijn

Just an additional note, the CodeQL check that's failing is doing so based on code we did not touch. It falls under the header "Unchanged files with check annotations (Beta)". So not relevant to this PR in my opinion.

mvdkleijn avatar Feb 19 '24 10:02 mvdkleijn

How long have you been running atlantis with gitea support in your production instance?

Can you include any screenshots in your PR to ensure this is working as expected?

cc: @runatlantis/core-contributors @runatlantis/maintainers please help review

nitrocode avatar Feb 20 '24 15:02 nitrocode

How long have you been running atlantis with gitea support in your production instance?

Can you include any screenshots in your PR to ensure this is working as expected?

cc: @runatlantis/core-contributors @runatlantis/maintainers please help review

How long? Since I started developing the client? A little bit of a strange question for me... :smile:

I don't feel comfortable doing that with my prod stuff, but I could run through some steps with a null resource in a test repo if that's ok?

Myself as well as @florianbeisel have done manual testing against Forgejo and Gitea respectively.

Of course I'd welcome it if someone besides myself and Florian could do a manual test run.

mvdkleijn avatar Feb 21 '24 17:02 mvdkleijn

How long have you been running atlantis with gitea support in your production instance? Can you include any screenshots in your PR to ensure this is working as expected? cc: @runatlantis/core-contributors @runatlantis/maintainers please help review

How long? Since I started developing the client? A little bit of a strange question for me... 😄

I don't feel comfortable doing that with my prod stuff, but I could run through some steps with a null resource in a test repo if that's ok?

Myself as well as @florianbeisel have done manual testing against Forgejo and Gitea respectively.

Of course I'd welcome it if someone besides myself and Florian could do a manual test run.

Since this is a new VCS, the more tests, the better; an Atlantis image can be generated for people to test.

jamengual avatar Feb 21 '24 17:02 jamengual

@mvdkleijn you can create an image in your fork https://github.com/mvdkleijn/atlantis by merging your branch feat-gitea-support into your fork's head branch main which will kick off a github action to build the container and upload it to your fork's github container registry (ghcr). This image can then be used in your environment to beta test your changes.

nitrocode avatar Feb 21 '24 18:02 nitrocode

As per @nitrocode suggestion, dev images including Gitea support are now available to test with at https://github.com/mvdkleijn/atlantis/pkgs/container/atlantis

If someone uses it to test please give us your feedback here.

mvdkleijn avatar Feb 21 '24 20:02 mvdkleijn

@mvdkleijn is it possible to use this new image in your setup to ensure it works as expected? This may catch some edge cases prior to merge

nitrocode avatar Feb 24 '24 15:02 nitrocode

@jamengual @GenPage @lukemassa do we want to require (unsure if there is a formal document) a new vcs to be deployed in an existing environment for some time, or is there anything else to be addressed, or is this good to merge?

nitrocode avatar Feb 24 '24 15:02 nitrocode

@mvdkleijn is it possible to use this new image in your setup to ensure it works as expected? This may catch some edge cases prior to merge

I'll see if I can use the image locally and possibly provide a screenshot of some basic scenarios with a simple test repo.

mvdkleijn avatar Feb 24 '24 16:02 mvdkleijn

I'll have no way of running any kind of production stuff through it currently but I can set some things up in my homelab I guess.

florianbeisel avatar Feb 24 '24 17:02 florianbeisel

grafik grafik grafik grafik

florianbeisel avatar Feb 24 '24 18:02 florianbeisel

The tests still shows "none yet" in the description.

It would be good to describe what testing has been done for this PR in the PR description.

nitrocode avatar Feb 26 '24 13:02 nitrocode

@florianbeisel in your screenshot, is the above test against gitea?

nitrocode avatar Feb 26 '24 13:02 nitrocode

The tests still shows "none yet" in the description.

It would be good to describe what testing has been done for this PR in the PR description.

Added test description to PR description

mvdkleijn avatar Feb 26 '24 16:02 mvdkleijn

atlantis-4-Screenshot from 2024-02-26 18-22-45 atlantis-3-Screenshot from 2024-02-26 18-12-56 atlantis-2-Screenshot from 2024-02-26 18-11-46 atlantis-1-Screenshot from 2024-02-26 17-59-31 @ @ Screenshot 2024-02-26 at 18-14-41 Add ONE

@nitrocode Added some screenshots (using Forgejo) of Atlantis running on my (remote) Forgejo instance

mvdkleijn avatar Feb 26 '24 17:02 mvdkleijn

We need to hold on this until we merge #4285 from @X-Guardian and then rebase this PR on it before the 0.28 release cycle

GenPage avatar Feb 26 '24 17:02 GenPage

@mvdkleijn Thanks for testing and adding that screenshot.

Is that of a private repo? or a public repo? Ideally both types (or if there are additional types in gitea/forejo) are tested.

nitrocode avatar Feb 26 '24 17:02 nitrocode

@mvdkleijn Thanks for testing and adding that screenshot.

Is that of a private repo? or a public repo? Ideally both types (or if there are additional types in gitea/forejo) are tested.

That's for a public repo, I didn't have time yet to add them for a private one. I can possibly do that later this evening. (depends on the kid 😋)

mvdkleijn avatar Feb 26 '24 17:02 mvdkleijn

@florianbeisel in your screenshot, is the above test against gitea?

yes this is against a current Gitea installation, also against a public repository. But shouldn't be easy to move around.

florianbeisel avatar Feb 27 '24 10:02 florianbeisel