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

Add gitea support #759

Merged
merged 26 commits into from Jan 13, 2024
Merged

Add gitea support #759

merged 26 commits into from Jan 13, 2024

Conversation

ghost
Copy link

@ghost ghost commented Jan 2, 2024

Took me a little longer, since i noticed that my initial idea would literally have required a full refactor, which was a little too large in scope. the above checklist is for keeping track of what will be added and this PR is here to track the progress and eventual questions.

closes #743

Plans

  • Extending the configuration format and adding a [gitea] section
  • Allowing to generate the configuration from known gitea remotes
  • using gitea on the CreatePullRequest step
  • using gitea on the Release step
  • creating a new step SelectGiteaIssue
  • adding a new forge concept to the documentation to link forge integrations together in a convenient place
  • adding a new gitea section to the config file reference
  • multi-forge support as mentioned in Add gitea support #743 (comment)

Testing

Notes

  • Commits will be reorganized after review. This is simply because i don't feel like constantly reorganizing commits.
  • The PR looks huge, but most of that is tests and test assets.
  • Currently ureq (as far as i can tell) doesn't support sending multipart form data and the only library i could find, ureq_multipart, panics on IO errors and has messages in chinese (see in its own codebase). Together i find those unacceptable design choices. issue: Support Multipart Forms algesten/ureq#698

Copy link

netlify bot commented Jan 2, 2024

Deploy Preview for knope canceled.

Name Link
🔨 Latest commit 38383ae
🔍 Latest deploy log https://app.netlify.com/sites/knope/deploys/65a1e1946ab4c90008e8e286

@ghost
Copy link
Author

ghost commented Jan 2, 2024

The clippy lint that is triggering makes no sense. The error is a copy of integrations::github::create_release::Error with some minor changes. So why does it trigger here, but not there? It also does not trigger locally. (answer: I was being dumb)

another one is the failing test. I do not know why it adds that unicode symbol there... i can't find that anywhere in the files.

---- version_go_mod stdout ----
thread 'version_go_mod' panicked at tests/gitea_release.rs:243:5:

---- expected: tests/gitea_release/version_go_mod/expected_go.mod
++++ actual:   In-memory
   1      - module codeberg.org/owner/repo // v1.1.0
        1 + module codeberg.org/owner/repo // v1.1.0∅

@dbanty would you know why this happens?

@ghost
Copy link
Author

ghost commented Jan 2, 2024

another one is the failing test. I do not know why it adds that unicode symbol there... i can't find that anywhere in the files.

---- version_go_mod stdout ----
thread 'version_go_mod' panicked at tests/gitea_release.rs:243:5:

---- expected: tests/gitea_release/version_go_mod/expected_go.mod
++++ actual:   In-memory
   1      - module codeberg.org/owner/repo // v1.1.0
        1 + module codeberg.org/owner/repo // v1.1.0∅

Okay, this one makes a lot of sense now. The in-memory value uses CRLF to mark the end of the line where the file uses LF.

@ghost
Copy link
Author

ghost commented Jan 2, 2024

Tested Release Workflow on https://codeberg.org/OpenThingies/openmood/releases
An image showing a test release

this is after fixing the releases url

@ghost
Copy link
Author

ghost commented Jan 3, 2024

https://codeberg.org/FallenValkyrie/testing/pulls/5

PR generated by knope on a copy of one of the projects i work on. (fixes will be pushed in a bit)

generated release:
https://codeberg.org/FallenValkyrie/testing/releases/tag/v0.3.0

Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

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

preliminary code check

docs/src/content/docs/reference/Concepts/forge.md Outdated Show resolved Hide resolved
src/config/toml/config.rs Outdated Show resolved Hide resolved
src/config/toml/config.rs Outdated Show resolved Hide resolved
src/config/toml/config.rs Outdated Show resolved Hide resolved
src/integrations/gitea/create_release.rs Outdated Show resolved Hide resolved
src/integrations/gitea/create_release.rs Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Jan 4, 2024

There we go, that should be it. The Commit history is nice and clean, Everything is implemented and i can't find any additional thing i could correct. That makes this PR ready for review. 🎉

@ghost ghost marked this pull request as ready for review January 4, 2024 00:32
Copy link
Member

@dbanty dbanty left a comment

Choose a reason for hiding this comment

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

Thanks so much for this 🤩! I left some questions & suggestions in the review. Here are a few more that didn't belong to any particular file:

  1. There are probably more places where "GitHub" is mentioned that can be cleaned up to more generic forge lingo. I'll take a scan around on a later day.
  2. Semi-related, it seems like Gitea Actions is supposed to be compatible with GitHub Actions, does that mean that the release recipes preview release and workflow dispatch will work as is? If so, it'd be nice to update them to mention that Gitea can be used too.
  3. Do you think it's worth noting the relationship between Codeberg, Forgejo, and Gitea in the docs anywhere? Or is that relationship well known by their users (I had to look it up 😁)
  4. Can you add a test that verifies if multiple forges are configured they are all used?

Then, as a future follow-up, we probably should switch to a [[forges]] array to maintain the multi-forge capabilities but with more concise config. Historically I also include an auto-upgrade option with a deprecation so it's easy to update config. Adding the host option to GitHub isn't a bad idea either, for GitHub Enterprise.

.changeset/gitea_support.md Outdated Show resolved Hide resolved
docs/src/content/docs/reference/Concepts/release.md Outdated Show resolved Hide resolved
src/step/releases/mod.rs Outdated Show resolved Hide resolved
tests/generate.rs Outdated Show resolved Hide resolved
tests/generate/gitea/knope.toml Show resolved Hide resolved
tests/gitea_release.rs Show resolved Hide resolved
tests/gitea_release/release_assets/dry_run_output.txt Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Jan 8, 2024

Do you think it's worth noting the relationship between Codeberg, Forgejo, and Gitea in the docs anywhere? Or is that relationship well known by their users (I had to look it up 😁)

mmmh... from my experience the people that use codeberg/forgejo know they are based on and fully compatible with gitea. But i think your idea to make this even more generic in the future might actually allow us to not have to. I'd say we mention Forgejo in the forge concept as a supported forge to be more clear.

Semi-related, it seems like Gitea Actions is supposed to be compatible with GitHub Actions, does that mean that the release recipes preview release and workflow dispatch will work as is? If so, it'd be nice to update them to mention that Gitea can be used too.

mmh I'd say we test if we can get an equivalent configuration in gitea working. Tho hosting my own CI instance already stretches my money to its max, so rn i can't do it. Since I'm a proponent of testing/verifying before mentioning things in docs I'd leave that to be added a later day.

Can you add a test that verifies if multiple forges are configured they are all used?

Sure can do ^^

There are probably more places where "GitHub" is mentioned that can be cleaned up to more generic forge lingo. I'll take a scan around on a later day.

There were a few github specific examples that could stand cleaning. I've scanned the docs during my first try and it was quite a lot. Tho i would like to keep some of the GitHub specific stuff, since it mentions the CLI.

Then, as a future follow-up, we probably should switch to a [[forges]] array to maintain the multi-forge capabilities but with more concise config. Historically I also include an auto-upgrade option with a deprecation so it's easy to update config. Adding the host option to GitHub isn't a bad idea either, for GitHub Enterprise.

I wanted to try this from the start, but it changed so much of the codebase that it would've been a pain to review. I do support doing that tho ^^

@ghost
Copy link
Author

ghost commented Jan 8, 2024

I just noticed that you merged this into a local branch. Since I accepted the invite, i would have access to that branch. My question is: how would you like me to continue? Would you like me to switch to the local branch within the repo or do it on the fork I'm already working on and only do future contributions here?

@dbanty
Copy link
Member

dbanty commented Jan 8, 2024

I didn’t intentionally merge it anywhere 🧐. Maybe something automatic that GitHub did? You’re more than welcome to work on a branch in here or on your fork, whatever is easiest!

@ghost
Copy link
Author

ghost commented Jan 8, 2024

Idk, see here:
An image showing that the PR branch was merged into a local branch of the same name

Anyway, in that case I'll finish this PR on the fork, since that is simpler on both ends, and any future PRs will happen on a local branch ^^

@ghost ghost requested a review from dbanty January 12, 2024 10:41
@ghost
Copy link
Author

ghost commented Jan 12, 2024

There we go, that should (hopefully) fix the conflict. Tho when rebasing on main, i didn't get a conflict at all...

@dbanty
Copy link
Member

dbanty commented Jan 13, 2024

Enforced that Gitea + assets aren't both declared and opened #779 to track adding in support (either manually with ureq or switching to something else)

@ghost
Copy link
Author

ghost commented Jan 13, 2024

Enforced that Gitea + assets aren't both declared

I could swear i did that... but it seems my brain never finished that thought...

dbanty
dbanty previously approved these changes Jan 13, 2024
Copy link
Member

@dbanty dbanty left a comment

Choose a reason for hiding this comment

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

I think it's ready! Thanks again for pulling this together! I've added some follow-up issues in #779, #780, and #781 but I don't think this is worth holding up for any of those.

@dbanty dbanty enabled auto-merge January 13, 2024 01:04
@dbanty dbanty added this pull request to the merge queue Jan 13, 2024
Merged via the queue into knope-dev:main with commit b2712e7 Jan 13, 2024
7 checks passed
dbanty added a commit that referenced this pull request Jan 13, 2024
This PR was created by Knope. Merging it will create a new release

### Features

#### Gitea support

PR #759 closed issue #743. Thank you, @FallenValkyrie!

- Added Support for Gitea in the `CreatePullRequest` step
- Added Support for Gitea in the `Release` step
- Added A new `SelectGiteaIssue` step
- Add support to generate Gitea config from known public Gitea instances

To use these new steps, just add a new section to your configuration,
like this:

```toml
[gitea]
repo = "knope"
owner = "knope-dev"
host = "https://codeberg.org"
```

You can now use the supported steps in the same way as their GitHub
equivalents.

> [!TIP]
> Knope can now generate a configuration for you, if your repository's
remote is one of the known
public Gitea instances. Currently only [Codeberg](https://codeberg.org)
is supported,
but feel free to add more
[here](https://github.com/knope-dev/knope/blob/main/src/config/toml/config.rs#L90).

---------

Co-authored-by: GitHub <[email protected]>
Co-authored-by: Dylan Anthony <[email protected]>
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.

Add gitea support
2 participants