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 docker build with all formatting tools #82

Merged
merged 9 commits into from
Mar 3, 2025

Conversation

svix-mman
Copy link
Contributor

@svix-mman svix-mman commented Feb 28, 2025

This PR adds a arm64/amd64 docker image that include

  • openapi-codegen
  • rustfmt +nightly (Rust)
  • biome (JS/TS)
  • ruff (Python)
  • google-java-format (Java)
  • ktfmt (Kotlin)
  • rubyfmt (Ruby)
  • goimports (Go)
  • gofmt (Go)
  • csharpier (C#)

The docker-release.yml workflow builds and releases a new image on every push to main
The images are pushed to ghcr.io/svix/openapi-codegen with tag latest and <date>-<git rev-parse --short> (20250228-ffac537)
I build the arm64 image using ubuntu-24.04-arm runners

There is a little bit of a hack I have to do to get 2 separate builds for arm64/amd64 published under the same tag
But this is way faster then using QEMU!

Once the arm64 github runner is stable I want to use it in our svix-webhooks docker releases (instead of QEMU)

@svix-mman svix-mman requested a review from a team as a code owner February 28, 2025 20:26
Copy link
Contributor

@svix-onelson svix-onelson left a comment

Choose a reason for hiding this comment

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

LGTM but maybe @svix-jplatte should have the final say

@svix-mman
Copy link
Contributor Author

@svix-onelson indeed, I want @svix-jplatte to have the final say here

@svix-mman svix-mman force-pushed the mendy/add-docker-builds branch from b025af1 to 20234f7 Compare February 28, 2025 23:51
Copy link
Member

@svix-jplatte svix-jplatte left a comment

Choose a reason for hiding this comment

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

Some more nitpicks, but overall LGTM!


- name: Export digest
# we create empty files with the sha256 digest of the docker image as the filename
# since we did not push with a tag, the only way to identify the image is with the digest
Copy link
Member

Choose a reason for hiding this comment

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

Down the line we should probably do releases for openapi-codegen and its Docker image, but for now this seems like a good start 👍

src/generator.rs Outdated
Comment on lines 177 to 179
if !self.output_dir.exists() {
fs::create_dir_all(self.output_dir)?;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually have to check whether the dir exists first? I would expect that calling create_dir_all on an already-existing directory is a no-op.

Also can't this happen further up the call tree? So we run it once per invocation, rather than once per template invocation?

Copy link
Contributor Author

@svix-mman svix-mman Mar 3, 2025

Choose a reason for hiding this comment

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

Do we actually have to check whether the dir exists first? I would expect that calling create_dir_all on an already-existing directory is a no-op.

Just tested it and you are right, not sure why the docs mention this If this function returns an error, some of the parent components might have been created already.

Also can't this happen further up the call tree? So we run it once per invocation, rather than once per template invocation?

Good call, let me move it up the call tree

@svix-mman svix-mman merged commit e660953 into main Mar 3, 2025
3 checks passed
@svix-mman svix-mman deleted the mendy/add-docker-builds branch March 3, 2025 13:32
svix-jplatte added a commit to svix/svix-webhooks that referenced this pull request Mar 4, 2025
Using the docker image from
svix/openapi-codegen#82
This results in the identical code.

I replaced the `regen_openapi.sh` with a multi-threaded python script
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.

3 participants