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

Generate native-image binaries for google-java-format #1057

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

cushon
Copy link
Collaborator

@cushon cushon commented Feb 13, 2024

And include them in release artifacts.

I tested this on my fork of the repo, and have a demo here: https://github.com/cushon/google-java-format/releases

When downloading the artifacts from the releases page they don't have the executable bit set, and my Mac blocks them because they aren't signed. That can be worked around with the following, but isn't ideal:

chmod a+rx google-java-format-darwin
sudo xattr -r -d com.apple.quarantine google-java-format-darwin

Progress towards #868, builds on @vorburger's work in #1048.

@cushon
Copy link
Collaborator Author

cushon commented Feb 13, 2024

@vorburger can I get your review of this?

Copy link
Member

@vorburger vorburger left a comment

Choose a reason for hiding this comment

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

#1059 fixes why this is red

#1060 proposes to add Windows - do you want to extend this to that, or prefer getting this in as-is already?

And include them in release artifacts.

I tested this on my fork of the repo, and have a demo here:
https://github.com/cushon/google-java-format/releases

When downloading the artifacts from the releases page they don't have
the executable bit set, and my Mac blocks them because they aren't
signed. That can be worked around with the following, but isn't ideal:

```
chmod a+rx google-java-format-darwin
sudo xattr -r -d com.apple.quarantine google-java-format-darwin
```

Progress towards google#868
.github/workflows/release.yml Outdated Show resolved Hide resolved
- name: "Native"
run: mvn -Pnative -DskipTests package -pl core -am
- name: "Move outputs"
run: cp core/target/google-java-format google-java-format-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }}
Copy link
Member

Choose a reason for hiding this comment

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

@cushon I don't understand this expression... and it (now) won't work for Windows?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It returns the string 'linux' or 'darwin' depending on the current OS, so the platform-specific outputs get uploaded with unique names. The syntax is documented here: https://docs.github.com/en/actions/learn-github-actions/expressions

I agree we'll want to update this for windows, I'm not sure what the cleanest way to do that is yet. I looked around at a few different ways to upload these artifacts to the release and didn't find anything very appealing.

Copy link
Member

@vorburger vorburger Feb 13, 2024

Choose a reason for hiding this comment

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

Oh, I think I just got it - the idea is that this will evaluate to the following, right?

  • google-java-format-linux
  • google-java-format-darwin

How about we use slightly different suffixes for the released native binaries? Inspired by e.g. uname -a output, I would suggest:

  • google-java-format_linux-x86_64
  • google-java-format_darwin-arm64 (or something like that - what exactly does uname -a output on your Mac?)
  • google-java-format_win-x64 (I think that's what that's commonly referred to - but I'm not 100% sure; but I would NOT use "x86_64" à la Linux for this binary, because MS seems to use x86=32bit VS x64=64bit - apparently.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Those suffixes LGTM, thanks. (My uname output includes Darwin and arm64.)

Copy link
Member

Choose a reason for hiding this comment

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

I agree we'll want to update this for windows, I'm not sure what the cleanest way to do that is yet. I looked around at a few different ways to upload these artifacts to the release and didn't find anything very appealing.

Simplest could be to duplicate this (and the "gh release upload") lines x3, with an "if" for penguins, apples, and wins?

Copy link
Member

Choose a reason for hiding this comment

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

  • google-java-format_win-x64 (I think that's what that's commonly referred to - but I'm not 100% sure; but I would NOT use "x86_64" à la Linux for this binary, because MS seems to use x86=32bit VS x64=64bit - apparently.)

Just noticed on https://github.com/bazelbuild/bazel/releases that they use "*windows_x86-64" so perhaps we can go for that here as well after all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I found a different way to express that mapping, and updated to use the suggested names.

Copy link
Member

@vorburger vorburger left a comment

Choose a reason for hiding this comment

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

LGTM from me, if you wanted to already merge this as-is?

@@ -87,6 +87,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
SUFFIX: ${{fromJson('{"ubuntu-latest":"linux-x86_64", "macos-latest":"darwin-arm64", "windows-latest":"windows_x86-64"}')[matrix.os]}}
Copy link
Member

Choose a reason for hiding this comment

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

Fancy!! That's a really neat trick - TIL; Thank You!

Copy link
Member

@vorburger vorburger left a comment

Choose a reason for hiding this comment

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

Proposed changes, you'll also want to rebase this after merging #1060; otherwise LGTM!

Co-authored-by: Michael Vorburger <[email protected]>
@cushon cushon merged commit 865cdf8 into google:master Feb 16, 2024
11 checks passed
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