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

convert the implementation of the action to Dart #77

Merged
merged 11 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
11 changes: 8 additions & 3 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
version: 2

Copy link
Member

Choose a reason for hiding this comment

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

Just curious, why no package-ecosystem: pub?

Copy link
Member Author

Choose a reason for hiding this comment

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

I ran into some issues when eval'ing it when it was in beta (dependabot/dependabot-core#4979), and was generally waiting for them to be addressed before using the functionality more widely.

updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
interval: monthly

- package-ecosystem: npm
directory: /
schedule:
interval: monthly
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Validate that the compiled artifacts are up-to-date.

name: Build

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
sdk: beta
- run: dart pub get
- run: dart tool/sig.dart --verify
4 changes: 3 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Tests for general `setup-dart` configurations.

name: Dart

on:
Expand All @@ -6,7 +8,7 @@ on:
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * 0" # Run every Sunday at 00:00.
- cron: "0 0 * * 0" # Run every Sunday at 00:00.

jobs:

Expand Down
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
example/.packages
example/pubspec.lock
example/.dart_tool/
# Dart files
.dart_tool/
pubspec.lock

# node modules
node_modules/

# intermediary compilation artifacts
lib/main.js
lib/main.js.deps
lib/main.js.map

lib/sig.txt
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v1.5.0-dev

* Re-wrote the implementation of the action into Dart.
* Auto-detect the platform architecture (`x64`, `ia32`, `arm`, `arm64`).
* Improved the caching and download resilience of the sdk.
* Added a new action output: `dart-version` - the installed version of the sdk.

## v1.4.0

* Automatically create OIDC token for pub.dev.
Expand Down
50 changes: 46 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
## How to Contribute
# How to Contribute

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

## Contributor License Agreement

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

## Start with an issue

Prior to sending patches and contributions to this project, please file an issue
in the issue tracker to ensure there is alignment with the overall goals of this
project. Thanks!

## Code Reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Coding style

The Dart source code in this repo follows the:

* [Dart style guide](https://dart.dev/guides/language/effective-dart/style)

You should familiarize yourself with those guidelines.

## File headers

All files in the Dart project must start with the following header; if you add a
new file please also add this. The year should be a single number stating the
year the file was created (don't use a range like "2011-2012"). Additionally, if
you edit an existing file, you shouldn't update the year.

// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

## Building and testing

See the [DEVELOPING.md](DEVELOPING.md) file.

## Community Guidelines

This project follows
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).

We pledge to maintain an open and welcoming environment. For details, see our
[code of conduct](https://dart.dev/code-of-conduct).
34 changes: 34 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Setting up

1. Install node
1. Install additional node tooling (`npm i -g @vercel/ncc`)
1. Install the node package dependencies (`npm install`)

## Development

tldr: edit Dart source files; run `npm run all` to re-compile the action

### Working on the action

Generally, to work on the action, edit the Dart source code in `lib/` and
re-compile the JavaScript code via `npm run all`. This will:

- compile the Dart source (via dart2js) to `lib/main.js`; copy that file to
`dist/main.cjs`
- package and minify the `lib/main.mjs` entrypoint point and referencd node
modules to `dist/index.mjs`

### Files

`lib/main.dart` - the Dart entry-point to the action.

`lib/main.mjs` - the JavaScript wrapper; this sets up some important JS interop
globals and bootstraps into `lib/main.dart`.

`dist/index.mjs` - the execution entry-point of the action.

## Releasing

See our
[publishing](https://github.com/dart-lang/setup-dart/wiki/Publishing-procedure)
wiki page.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ The action takes the following inputs:
* The available build flavors are `release` and `raw`.
* The `release` flavor contains published builds.
* The `raw` flavor contains unpublished builds; these can be used by
developers to test against SDK versions before a release. Note that the
`main` release channel only supports `raw` build flavor.
developers to test against SDK versions before a signed release is
available. Note that the `main` release channel only supports the `raw`
build flavor.

* `architecture`: The CPU architecture to setup support for.
* Valid options are `x64`, `ia32`, `arm`, and `arm64`.
Expand All @@ -46,7 +47,13 @@ The action takes the following inputs:
[Dart system requirements](https://dart.dev/get-dart#system-requirements)
for valid combinations.

## Check static analysis, formatting, and run tests
## Outputs

The action produces the following output:

* `dart-version`: The version of the Dart SDK that was installed.

## Checking static analysis, formatting, and running tests

Various static checks:

Expand Down Expand Up @@ -171,4 +178,4 @@ Contributions are welcome! Please see [CONTRIBUTING.md.md](CONTRIBUTING.md.md).

## Version history

Please see out [CHANGELOG.md](CHANGELOG.md) file.
Please see our [CHANGELOG.md](CHANGELOG.md) file.
16 changes: 8 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: "Setup Dart SDK"
description: "Setup the Dart SDK, and add it to the PATH"
description: "Download and setup the Dart SDK."
branding:
icon: check-circle
color: blue
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 three
'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.
required: false
default: "stable"
architecture:
description: "The CPU architecture ('x64', 'ia32', 'arm', or 'arm64')."
required: false
default: "x64"
flavor:
description: "The build flavor ('raw' or 'release')."
description: "The build flavor ('release' or 'raw')."
required: false
outputs:
dart-version:
description: 'The installed Dart version.'
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.sdk }} ${{ runner.os }} ${{ inputs.architecture }} ${{ inputs.flavor }}
shell: bash
using: "node16"
main: "dist/index.mjs"
5 changes: 5 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:lints/recommended.yaml

linter:
rules:
- unawaited_futures
Loading