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

Fix brew-update util, and add CI #207

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

danielbayley
Copy link
Contributor

@danielbayley danielbayley commented Dec 23, 2024

YAMLScript

Ideally, the util/brew-update script would be replaced with brewbump-formula-pr, but this doesn't currently seem to work properly with formulae containing multiple urls and sha256sums. Fixing that will be yet another PR, over on Homebrew…

CI

The workflow will run on every release, and uses brewlivecheck to only update if the release SemVer tag is newer than the latest formula. You can preview the CI in action on my fork
The workflow just requires an organisation ACCESS_TOKEN

See also #205 and #197 (comment).

Copy link
Member

@ingydotnet ingydotnet left a comment

Choose a reason for hiding this comment

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

@danielbayley Thanks so much for this effort. Like so many things with YS I have wanted to (find the time to) encode more automations with GHA.
Looking at your workflow YAML it is obvious that you know what you are doing at multiple levels: GHA, YAML and shell commands. (I'm very particular about YAML and shell so good to see!)

I don't see anything to comment on in the workflow yaml.
I have a few comments for the brew-update ys script...

Also, let me know if you are up for helping with the overall release process.

util/brew-update Outdated Show resolved Hide resolved

defn main(version):
check-version: version
download-releases: version
update-brew: version

defn sha256sum(file):
Copy link
Member

Choose a reason for hiding this comment

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

I love to see you refactoring with YS code!

util/brew-update Outdated Show resolved Hide resolved
util/brew-update Outdated Show resolved Hide resolved
util/brew-update Outdated
Comment on lines 61 to 63
res =: sh("curl --silent --location $url --output $file")
when res.exit:N.?:
die: "Download of '$url' failed:\n$(res.err)"
Copy link
Member

Choose a reason for hiding this comment

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

YS has std/curl so you could also replace this with

spit file: curl(url)

I wrote this script pretty quickly so didn't think of that before.

Copy link
Contributor Author

@danielbayley danielbayley Dec 26, 2024

Choose a reason for hiding this comment

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

YS has std/curl so you could also replace this with

spit file: curl(url)

Cool. The thing I didn't know about was spit, which is not the most intuative method name… So I missed it in the docs, searching instead for write/file or similar :)

Copy link
Member

Choose a reason for hiding this comment

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

The spit function comes from straight from clojure.core

$ ys -pe spit
#object[clojure.core$spit 0x2d4edc62 "clojure.core$spit@2d4edc62"]

it's supposed to be the opposite of slurp. I really don't like the name spit for that. read and write might be better. Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's supposed to be the opposite of slurp. I really don't like the name spit for that. read and write might be better. Any ideas?

I see, makes more sense in that case. Well since they're in Clojure core, they should keep that naming for users used to that convention, but also maybe add read and write aliases for everyone else…

util/brew-update Outdated
@@ -62,7 +69,7 @@ defn releases(version)::
MAC_INT:: "ys-${version}-macos-x64.tar.xz"

defn check-version(version):
when version !~ /^0\.1\.\d+$/:
when version !~ /^\d(\.\d+){2}$/:
Copy link
Member

Choose a reason for hiding this comment

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

Let's not generalize this quite yet. I purposefully coded it that way, because I wanted to remember to circle back here when I got to a major release.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe I need to add more comments in general :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, reverted…

Note

For future reference, the general pattern here is missing a +, it should actually be /^\d+(\.\d+){2}$/.

@danielbayley
Copy link
Contributor Author

I'm very particular about YAML and shell

I'm also very particular, about everything!

@ingydotnet As you mentioned in #205

I think the big thing that YS needs first is a language server.

If/once you have an LSP up and running, it should be straightforward enough to build a linter to enforce these kind of formatting concerns on top of it…

@ingydotnet ingydotnet changed the base branch from main to devel January 17, 2025 05:36
@ingydotnet
Copy link
Member

@danielbayley Sorry about the delay.
I put out 0.1.88 yesterday.
Just now I started with your PR. I rebased in my devel branch, and retargeted the PR at that.
I redid the commits a little and force pushed back to you.
I used your brew-update to push out the 0.1.88 release by hand.
I noticed that you changed the remote url to use https rather that git@ ssh.
Is that for the CI integration?

I'll try to find time this weekend to get to the CI part.
Cheers

@danielbayley
Copy link
Contributor Author

@danielbayley Sorry about the delay. I put out 0.1.88 yesterday. Just now I started with your PR. I rebased in my devel branch, and retargeted the PR at that. I redid the commits a little and force pushed back to you. I used your brew-update to push out the 0.1.88 release by hand.

I'll try to find time this weekend to get to the CI part. Cheers

No worries.

I noticed that you changed the remote url to use https rather that git@ ssh. Is that for the CI integration?

Yeah, it was broken otherwise. Maybe there is a way around it, if you want to insist on ssh… But that is what worked for me.

@ingydotnet
Copy link
Member

@danielbayley

I have some questions about brew.

My current process is to run my release process (run make yamlscript-release ... by hand on 4 machines which updates https://github.com/yaml/yamlscript/releases)

Then I run util/brew-update 0.1.88 by hand which clones the https://github.com/yaml/homebrew-yamlscript repo and downloads the new tarballs, gets their sha digests and updates the repo. Then I commit and push.

I'd like to automate it all eventually.

I don't know brew very well, but I have used it over the years. When I set this up I learned about using brew install yaml/yamlscript/ys instead of brew install yamlscript which lets you install from a repo instead of going through the process of making a new formulae for yamlscript. I did this because it was easier at the time, but maybe we should do it right. Have you looked into registering a formulae for yamlscript yet?

I did the 0.1.88 update using your changes to from this PR but I just tested this on a mac and I get this:

$ brew search yamlscript                  
==> Formulae
yaml/yamlscript/ys                    yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]
yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]             yaml/yamlscript/[email protected]
$ brew install yaml/yamlscript/[email protected]
==> Fetching yaml/yamlscript/[email protected]
==> Downloading https://github.com/yaml/yamlscript/releases/download/0.1.86/ys-0.1.86-macos-aarch64.tar.xz
Already downloaded: /Users/ingy/Library/Caches/Homebrew/downloads/138e0c4b24e211b921bb5f727b9a7bce4f5bac8fb4a726d2a2c379e0d6e10075--ys-0.1.86-macos-aarch64.tar.xz
==> Installing [email protected] from yaml/yamlscript
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 15.4.

🍺  /opt/homebrew/Cellar/[email protected]/0.1.86: 6 files, 56.9MB, built in 1 second
==> Running `brew cleanup [email protected]`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$ brew install yaml/yamlscript/[email protected]
==> Fetching yaml/yamlscript/[email protected]
==> Downloading https://github.com/yaml/yamlscript/releases/download/0.1.88/ys-0.1.88-macos-aarch64.tar.xz
Already downloaded: /Users/ingy/Library/Caches/Homebrew/downloads/1600118db096fad28699fe169256108e330596adc6e452421f06f2468cd11688--ys-0.1.88-macos-aarch64.tar.xz
Error: [email protected]: SHA256 mismatch
Expected: eddcb16690054007204d4cf207ceffc9ebd87f851b97d0e6714ff2e2d795286f
  Actual: 28b89c3d28bb81b776852640b81693a3812408059798ba52d26f5462449650db
    File: /Users/ingy/Library/Caches/Homebrew/downloads/1600118db096fad28699fe169256108e330596adc6e452421f06f2468cd11688--ys-0.1.88-macos-aarch64.tar.xz
To retry an incomplete download, remove the file above.

Can you figure out what happened there?

Also open to suggestions about how to proceed.

Also I have another way to install things that I want to ask you about.
I'll make another issue for that and mention this issue so they link.

@ingydotnet
Copy link
Member

ingydotnet commented Jan 19, 2025

@danielbayley This is also interesting...

ys has a --upgrade option that uses https://yamlscript.org/install script to install the latest version in the same dir as ys. Looks like it has an issue with symlinks.

I'd like things to work such that once people have a ys of any version installed by any method, they can use ys to upgrade and also install/manage YS libraries etc.

We'll have to think about how this works with brew and other pkg sources...

$ brew install yaml/yamlscript/[email protected] 
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Fetching yaml/yamlscript/[email protected]
==> Downloading https://github.com/yaml/yamlscript/releases/download/0.1.86/ys-0.1.86-macos-aarch64.tar.xz
Already downloaded: /Users/ingy/Library/Caches/Homebrew/downloads/138e0c4b24e211b921bb5f727b9a7bce4f5bac8fb4a726d2a2c379e0d6e10075--ys-0.1.86-macos-aarch64.tar.xz
==> Installing [email protected] from yaml/yamlscript
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 15.4.

🍺  /opt/homebrew/Cellar/[email protected]/0.1.86: 6 files, 56.9MB, built in 1 second
==> Running `brew cleanup [email protected]`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$ which ys
/opt/homebrew/bin/ys
$ ys --upgrade
Exception in thread "main" java.lang.RuntimeException: Path /opt/homebrew/bin/ys-sh-0.1.86 does not point to executable file
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.PosixProcessPropertiesSupport.exec(PosixProcessPropertiesSupport.java:133)
	at org.graalvm.nativeimage/org.graalvm.nativeimage.ProcessProperties.exec(ProcessProperties.java:172)
	at babashka.process$exec.invokeStatic(process.cljc:611)
	at yamlscript.cli$do_upgrade.invokeStatic(cli.clj:195)
	at yamlscript.cli$do_main.invokeStatic(cli.clj:505)
	at yamlscript.cli$_main.invokeStatic(cli.clj:568)
	at yamlscript.cli$_main.doInvoke(cli.clj:520)
	at clojure.lang.RestFn.applyTo(RestFn.java:140)
	at yamlscript.cli.main(Unknown Source)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
$ 

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