Fix arch is undefined, update tests, and allow manual invocation of action#8
Fix arch is undefined, update tests, and allow manual invocation of action#8
Conversation
Earthfile
Outdated
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | ||
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.* [a-zA-Z0-9]* linux/amd64; Alpine Linux' |
There was a problem hiding this comment.
Running as a separate command simply makes it easier to see the version to make the necessary changes. This test relies on the specific format of our version command.
| exports[`get-version range versions should match ^0 versions 1`] = `"v0.6.23"`; | ||
|
|
||
| exports[`get-version range versions should match 0.*.* versions 1`] = `"v0.6.14"`; | ||
| exports[`get-version range versions should match 0.*.* versions 1`] = `"v0.6.23"`; | ||
|
|
||
| exports[`get-version range versions should match 0.4.* versions 1`] = `"v0.4.6"`; | ||
|
|
||
| exports[`get-version range versions should match 0.6.1 versions 1`] = `"v0.6.1"`; | ||
|
|
||
| exports[`get-version range versions should match 0.6.1 versions 2`] = `"v0.6.1"`; | ||
|
|
||
| exports[`get-version range versions should match latest versions 1`] = `"v0.6.14"`; | ||
| exports[`get-version range versions should match latest versions 1`] = `"v0.6.23"`; |
There was a problem hiding this comment.
snapshots depend on the current version of Earthly. They need to be updated every time we do work after releasing a new version.
There was a problem hiding this comment.
ouch!
Maybe we should parse the string into [0, 6, 23] then we can just programatically check that it's greater than [0,6,1].
There was a problem hiding this comment.
I decided to use semver for this. Made the tests very straightforward.
| const osArch = os.arch(); | ||
| const releaseArch = nodeArchToReleaseArch[os.arch()] || osArch; |
There was a problem hiding this comment.
When the osArch wasn't in the map we got undefined and cached linux-undefined.
Earthfile
Outdated
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.*linux/amd64; Linux' | ||
| # [a-zA-Z0-9]* attempt to match a commit hash | ||
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | ||
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.* [a-zA-Z0-9]* linux/amd64; Alpine Linux' |
There was a problem hiding this comment.
it looks like this regex now requires two spaces for cases like v0.1.2<space><space>linux/amd64
should it be something closer to:
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.* [a-zA-Z0-9]* linux/amd64; Alpine Linux' | |
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.*( [a-zA-Z0-9]+)? linux/amd64; Alpine Linux' |
However note that there's already a .* should should match everything between v and linux/amd64, so I'm not sure about this regex change.
What about:
RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | tee version.output
RUN grep '^earthly version v.*linux/amd64; Linux' version.output
instead?
There was a problem hiding this comment.
This is very close.
I've adjusted the regex you've provided just a bit to allow for the specific flavour of Linux as well (Alpine in this example).
RUN grep '^earthly version v.*linux/amd64; Alpine Linux' version.output
alexcb
left a comment
There was a problem hiding this comment.
looking good!
I left a couple of small suggestions to make this more manageable in the future.
| RUN cat output | grep '^::add-path::' | sed 's/::add-path:://g' > earthly-path | ||
| RUN test "$(cat earthly-path)" = "/root/.earthly/bin" | ||
| RUN export PATH="$(cat earthly-path):$PATH" && earthly --version | grep '^earthly version v.*linux/amd64; Linux' | ||
| # [a-zA-Z0-9]* attempt to match a commit hash |
There was a problem hiding this comment.
is this comment still relevant?
Fix arch is undefined, update tests, and allow manual invocation of action.