Skip to content

Commit 699d685

Browse files
authored
convert the implementation of the action to Dart (#77)
* re-write into Dart * fix http_client interop * update entry-point * refactor dist * more updates * packaging updates * update the developing instructions; add a sig file * fix build script * await a future * use JS types * review comments
1 parent ed899c0 commit 699d685

29 files changed

+12644
-178
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** -diff linguist-generated=true

.github/dependabot.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
version: 2
33

44
updates:
5-
- package-ecosystem: "github-actions"
6-
directory: "/"
5+
- package-ecosystem: github-actions
6+
directory: /
77
schedule:
8-
interval: "weekly"
8+
interval: monthly
9+
10+
- package-ecosystem: npm
11+
directory: /
12+
schedule:
13+
interval: monthly

.github/workflows/build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Validate that the compiled artifacts are up-to-date.
2+
3+
name: Build
4+
5+
on:
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: ./
15+
with:
16+
sdk: beta
17+
- run: dart pub get
18+
- run: dart tool/sig.dart --verify

.github/workflows/dart.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Tests for general `setup-dart` configurations.
2+
13
name: Dart
24

35
on:
@@ -6,7 +8,7 @@ on:
68
pull_request:
79
branches: [main]
810
schedule:
9-
- cron: "0 0 * * 0" # Run every Sunday at 00:00.
11+
- cron: "0 0 * * 0" # Run every Sunday at 00:00.
1012

1113
jobs:
1214

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
example/.packages
2-
example/pubspec.lock
3-
example/.dart_tool/
1+
# Dart files
2+
.dart_tool/
3+
pubspec.lock
4+
5+
# node modules
6+
node_modules/
7+
8+
# intermediary compilation artifacts
9+
lib/main.js
10+
lib/main.js.deps
11+
lib/main.js.map
12+
13+
lib/sig.txt

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v1.5.0-dev
2+
3+
* Re-wrote the implementation of the action into Dart.
4+
* Auto-detect the platform architecture (`x64`, `ia32`, `arm`, `arm64`).
5+
* Improved the caching and download resilience of the sdk.
6+
* Added a new action output: `dart-version` - the installed version of the sdk.
7+
18
## v1.4.0
29

310
* Automatically create OIDC token for pub.dev.

CONTRIBUTING.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
## How to Contribute
1+
# How to Contribute
22

3-
Prior to sending patches and contributions to this project, please file
4-
an issue in the issue tracker to ensure there is alignment with the overall
5-
goals of this project. Thanks!
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
65

76
## Contributor License Agreement
87

@@ -17,3 +16,46 @@ You generally only need to submit a CLA once, so if you've already submitted one
1716
(even if it was for a different project), you probably don't need to do it
1817
again.
1918

19+
## Start with an issue
20+
21+
Prior to sending patches and contributions to this project, please file an issue
22+
in the issue tracker to ensure there is alignment with the overall goals of this
23+
project. Thanks!
24+
25+
## Code Reviews
26+
27+
All submissions, including submissions by project members, require review. We
28+
use GitHub pull requests for this purpose. Consult
29+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
30+
information on using pull requests.
31+
32+
## Coding style
33+
34+
The Dart source code in this repo follows the:
35+
36+
* [Dart style guide](https://dart.dev/guides/language/effective-dart/style)
37+
38+
You should familiarize yourself with those guidelines.
39+
40+
## File headers
41+
42+
All files in the Dart project must start with the following header; if you add a
43+
new file please also add this. The year should be a single number stating the
44+
year the file was created (don't use a range like "2011-2012"). Additionally, if
45+
you edit an existing file, you shouldn't update the year.
46+
47+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
48+
// for details. All rights reserved. Use of this source code is governed by a
49+
// BSD-style license that can be found in the LICENSE file.
50+
51+
## Building and testing
52+
53+
See the [DEVELOPING.md](DEVELOPING.md) file.
54+
55+
## Community Guidelines
56+
57+
This project follows
58+
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
59+
60+
We pledge to maintain an open and welcoming environment. For details, see our
61+
[code of conduct](https://dart.dev/code-of-conduct).

DEVELOPING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[![Build](https://github.com/dart-lang/setup-dart/actions/workflows/build.yml/badge.svg)](https://github.com/dart-lang/setup-dart/actions/workflows/build.yml)
2+
[![Dart](https://github.com/dart-lang/setup-dart/actions/workflows/dart.yml/badge.svg)](https://github.com/dart-lang/setup-dart/actions/workflows/dart.yml)
3+
4+
## Setting up
5+
6+
1. Install node
7+
1. Install additional node tooling (`npm i -g @vercel/ncc`)
8+
1. Install the node package dependencies (`npm install`)
9+
10+
## Development
11+
12+
tldr: edit Dart source files; run `npm run all` to re-compile the action
13+
14+
### Working on the action
15+
16+
Generally, to work on the action, edit the Dart source code in `lib/` and
17+
re-compile the JavaScript code via `npm run all`. This will:
18+
19+
- compile the Dart source (via dart2js) to `lib/main.js`; copy that file to
20+
`dist/main.cjs`
21+
- package and minify the `lib/main.mjs` entrypoint point and referencd node
22+
modules to `dist/index.mjs`
23+
24+
### Files
25+
26+
`lib/main.dart` - the Dart entry-point to the action.
27+
28+
`lib/main.mjs` - the JavaScript wrapper; this sets up some important JS interop
29+
globals and bootstraps into `lib/main.dart`.
30+
31+
`dist/index.mjs` - the execution entry-point of the action.
32+
33+
## Releasing
34+
35+
See our
36+
[publishing](https://github.com/dart-lang/setup-dart/wiki/Publishing-procedure)
37+
wiki page.

README.md

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# setup-dart
22

3-
[![Dart](https://github.com/dart-lang/setup-dart/workflows/Dart/badge.svg)](https://github.com/dart-lang/setup-dart/actions?query=workflow%3A%22Dart%22+branch%3Amain)
3+
[setup-dart](https://github.com/dart-lang/setup-dart) installs and sets up a
4+
Dart SDK for use in GitHub Actions; it:
45

5-
This [GitHub Action](https://github.com/dart-lang/setup-dart) installs
6-
and sets up of a Dart SDK for use in actions by:
7-
8-
* Downloading the Dart SDK
9-
* Adding the [`dart`](https://dart.dev/tools/dart-tool) command
10-
and [`pub` cache](https://dart.dev/tools/pub/cmd/pub-get#the-system-package-cache)
11-
to the system path
6+
* downloads the Dart SDK
7+
* adds the [`dart`](https://dart.dev/tools/dart-tool) tool to the system path
128

139
## Usage
1410

15-
Install the latest stable SDK and run 'Hello World':
11+
To install the latest stable Dart SDK and run typical checks:
1612

1713
```yml
18-
steps:
19-
- uses: actions/checkout@v3
20-
- uses: dart-lang/setup-dart@v1
21-
- run: dart pub get
22-
- run: dart run bin/hello_world.dart
14+
name: Dart
15+
16+
on:
17+
pull_request:
18+
branches: [main]
19+
push:
20+
branches: [main]
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: dart-lang/setup-dart@v1
28+
29+
- run: dart pub get
30+
- run: dart format --output=none --set-exit-if-changed .
31+
- run: dart analyze
32+
- run: dart test
2333
```
2434
2535
## Inputs
@@ -36,8 +46,9 @@ The action takes the following inputs:
3646
* The available build flavors are `release` and `raw`.
3747
* The `release` flavor contains published builds.
3848
* The `raw` flavor contains unpublished builds; these can be used by
39-
developers to test against SDK versions before a release. Note that the
40-
`main` release channel only supports `raw` build flavor.
49+
developers to test against SDK versions before a signed release is
50+
available. Note that the `main` release channel only supports the `raw`
51+
build flavor.
4152

4253
* `architecture`: The CPU architecture to setup support for.
4354
* Valid options are `x64`, `ia32`, `arm`, and `arm64`.
@@ -46,30 +57,11 @@ The action takes the following inputs:
4657
[Dart system requirements](https://dart.dev/get-dart#system-requirements)
4758
for valid combinations.
4859

49-
## Check static analysis, formatting, and run tests
60+
## Outputs
5061

51-
Various static checks:
62+
The action produces the following output:
5263

53-
1) Check static analysis with the Dart analyzer
54-
2) Check code follows Dart idiomatic formatting
55-
3) Check that unit tests pass
56-
57-
```yml
58-
...
59-
steps:
60-
61-
- name: Install dependencies
62-
run: dart pub get
63-
64-
- name: Verify formatting
65-
run: dart format --output=none --set-exit-if-changed .
66-
67-
- name: Analyze project source
68-
run: dart analyze
69-
70-
- name: Run tests
71-
run: dart test
72-
```
64+
* `dart-version`: The version of the Dart SDK that was installed.
7365

7466
## Matrix testing example
7567

@@ -171,4 +163,4 @@ Contributions are welcome! Please see [CONTRIBUTING.md.md](CONTRIBUTING.md.md).
171163

172164
## Version history
173165

174-
Please see out [CHANGELOG.md](CHANGELOG.md) file.
166+
Please see our [CHANGELOG.md](CHANGELOG.md) file.

action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
name: "Setup Dart SDK"
2-
description: "Setup the Dart SDK, and add it to the PATH"
2+
description: "Download and setup the Dart SDK."
33
branding:
44
icon: check-circle
55
color: blue
66
inputs:
77
sdk:
88
description: >-
99
The channel, or a specific version from a channel to install ('stable',
10-
'beta', 'dev', '2.7.2', '2.12.0-1.4.beta'). Using one of the three
10+
'beta', 'dev', '2.7.2', '2.12.0-1.4.beta'). Using one of the named
1111
channels instead of a version will give you the latest version published
1212
to that channel.
1313
required: false
1414
default: "stable"
1515
architecture:
1616
description: "The CPU architecture ('x64', 'ia32', 'arm', or 'arm64')."
1717
required: false
18-
default: "x64"
1918
flavor:
20-
description: "The build flavor ('raw' or 'release')."
19+
description: "The build flavor ('release' or 'raw')."
2120
required: false
21+
outputs:
22+
dart-version:
23+
description: 'The installed Dart version.'
2224
runs:
23-
using: "composite"
24-
steps:
25-
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.sdk }} ${{ runner.os }} ${{ inputs.architecture }} ${{ inputs.flavor }}
26-
shell: bash
25+
using: "node16"
26+
main: "dist/index.mjs"

analysis_options.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include: package:lints/recommended.yaml
2+
3+
linter:
4+
rules:
5+
- unawaited_futures

0 commit comments

Comments
 (0)