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

support sdk version wildcard format #106

Merged
merged 8 commits into from Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/dart.yml
Expand Up @@ -82,7 +82,25 @@ jobs:
- uses: ./
with:
sdk: ${{ matrix.sdk }}
architecture: ia32

- name: Run hello world
run: |
echo "main() { print('hello world'); }" > hello.dart
dart hello.dart
- run: dart --version

# Test using wildcard versions for the sdk parameter.
test_release_wildcards:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: test_latest_patch_release (and # Test getting the latest patch release for a major.minor sdk parameter.)

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

(btw, you can make in-line suggested edits to PRs using the 'add a suggestion' action)

runs-on: ubuntu-latest
strategy:
matrix:
sdk: [2.19.x, 3.1.x]
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered using ^2.19.0 instead? Then this would be more similar to how you specify SDK constraints, maybe we could even support more complicated SDK constraints in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I haven't. We had a feature request for 2.19.x, and I believe this may match the action support for one other language.

We could also consider just 2.19; using just two version segments could be an implicit way to opt-into using the latest patch release for a version.

^2.19.0 could also work. The current way this PR is implemented, we couldn't efficiently have an actual semver match - like getting the latest version that matches a version range (i.e., '>=2.18.3 <2.19.2', ...). We could do that if we have a json method we could call that either returned all the available sdk versions, or, all the versions that matched a given range. We're currently relying on a very specific usage of the google storage list API. It works the way we want it for this specific use case, but for anything more sophisticated we'd need to have all the sdk versions available (perhaps read from a single well-known file in google storage - https://storage.googleapis.com/dart-archive/channels/stable/release/versions.json?).

Copy link
Member

Choose a reason for hiding this comment

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

Up to you :)

Either option will work. Caret syntax feels more "Dart". Not sure if we ever need more complicated constraints (definitely wouldn't implement it now without a use case).

Copy link
Contributor

Choose a reason for hiding this comment

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

We could also just have e.g. "2.19" to select the latest 2.19.x release

Agreed that caret syntax feels dart-y although it also does suggest the powerful of the whole pub version resolution

Copy link
Contributor

Choose a reason for hiding this comment

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

The caret is actually kinda bad since ^3.1.0 means up to 4.0, which isn't the semantics we try to do here.

Copy link
Member

Choose a reason for hiding this comment

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

That's true, caret means until the next major, so it doesn't quite cover the use case of latest patch version. So for that we'd need to support pub-like version ranges which seems inconvenient. So I think rather than making this too complicated we should look at other languages and make a "GitHub-y" solution.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like most setup- actions support: 3, 3.2, 3.4.5. The .x is probably supported as well mostly because https://github.com/npm/node-semver supports it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sortie - good point about the caret syntax above.

I'd be fine w/ either 2.19 or 2.19.x. They're both simple. If the two version variant (2.19) is more common for github actions then we should just do that. We could support both patterns but I don't think the flexibility is really necessary here.

I'll re-work this PR to use 2.19.

fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: ./
with:
sdk: ${{ matrix.sdk }}

- name: Run hello world
run: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
## v1.5.2-wip

* Add support for specifying a wildcard format for provisioning the latest patch
devoncarew marked this conversation as resolved.
Show resolved Hide resolved
release of an SDK.

## v1.5.1

* No longer test the `setup-dart` action on pre-2.12 SDKs.
Expand Down
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -36,11 +36,13 @@ jobs:

The action takes the following inputs:

* `sdk`: Which SDK version to setup. Can be specified using one of two forms:
* A specific SDK version, e.g. `2.19.0` or `2.12.0-1.4.beta`
* `sdk`: Which SDK version to setup. Can be specified using one of three forms:
* A release channel, which will install the latest build from that channel.
Available channels are `stable`, `beta`, `dev`, and `main`.
See the [Dart SDK archive](https://dart.dev/get-dart/archive) for details.
Available channels are `stable`, `beta`, `dev`, and `main`. See the
[Dart SDK archive](https://dart.dev/get-dart/archive) for details.
* A wildcard form for the latest patch release for a specific SDK version.
E.g., `2.19.x` will get the latest patch release for the 2.19 SDK.
* A specific SDK version, e.g. `2.19.0` or `2.12.0-1.4.beta`.

* `flavor`: Which build flavor to setup.
* The available build flavors are `release` and `raw`.
Expand Down Expand Up @@ -89,7 +91,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [2.18.0, stable, beta, dev]
sdk: [3.1.x, stable, beta, dev]
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
Expand Down
9 changes: 5 additions & 4 deletions action.yml
Expand Up @@ -6,10 +6,11 @@ branding:
inputs:
sdk:
description: >-
The channel, or a specific version from a channel to install ('stable',
'beta', 'dev', '2.7.2', '2.12.0-1.4.beta'). Using one of the named
channels instead of a version will give you the latest version published
to that channel.
This can be either the channel to install (i.e., 'stable', 'beta', 'dev'),
a wildcard format for the latest patch release (i.e., `2.19.x`, `3.1.x`),
or a specific sdk version to install (i.e, '2.19.1', '3.0.0-1.4.beta').
Using one of the named channels instead of a version will give you the
latest version published of that channel.
required: false
default: "stable"
architecture:
Expand Down