Skip to content

Commit 40bc0e5

Browse files
authored
Merge pull request #1 from dart-lang/initial
Initial version
2 parents 52c6415 + 79e1913 commit 40bc0e5

File tree

6 files changed

+208
-1
lines changed

6 files changed

+208
-1
lines changed

.github/workflows/dart.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Dart
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
channel: [stable, beta, dev]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: ./
19+
with:
20+
channel: ${{ matrix.channel }}
21+
22+
- name: Run hello world
23+
run: |
24+
echo "main() { print('hello world'); }" > hello.dart
25+
dart hello.dart

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Initial version
2+
3+
- Basic download and setup.
4+
- Support for Linux, macOS, and Windows.

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2020, the Dart project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,102 @@
11
# setup-dart
2-
GitHub Action for install and setup of a Dart SDK
2+
3+
This [GitHub Action]() installs and sets up of a Dart SDK for use in actions by:
4+
5+
* Downloading the Dart SDK
6+
* Adding the `dart` command and `pub` cache to path
7+
8+
# Usage
9+
10+
## Basic
11+
12+
Install the latest stable SDK, and run Hello World.
13+
14+
```
15+
name: Dart
16+
17+
on:
18+
push:
19+
branches: [ master ]
20+
pull_request:
21+
branches: [ master ]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: dart-lang/setup-dart@v1
30+
31+
- name: Install dependencies
32+
run: dart pub get
33+
34+
- name: Hello world
35+
run: dart bin/hello_world.dart
36+
```
37+
38+
## Check static analysis, formatting, and tests
39+
40+
Various static checks:
41+
42+
1) Check static analysis with the Dart analyzer
43+
2) Check code follows Dart ideomatic formatting
44+
3) Check that unit tests pass
45+
46+
```
47+
...
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Install dependencies
52+
run: dart pub get
53+
54+
- name: Verify formatting
55+
run: dart format --output=none --set-exit-if-changed .
56+
57+
- name: Analyze project source
58+
run: dart analyze
59+
60+
- name: Run tests
61+
run: dart test
62+
```
63+
64+
## Matrix testing
65+
66+
Double matrix across two dimensions:
67+
68+
- All three major operating systems: Linux, macOS, and Windows.
69+
- Dart release channels: stable, beta, dev.
70+
71+
```
72+
name: Dart
73+
74+
on:
75+
push:
76+
branches: [main]
77+
pull_request:
78+
branches: [main]
79+
80+
jobs:
81+
test:
82+
runs-on: ${{ matrix.os }}
83+
strategy:
84+
matrix:
85+
os: [ubuntu-latest, macos-latest, windows-latest]
86+
channel: [stable, beta, dev]
87+
steps:
88+
- uses: actions/checkout@v2
89+
- uses: dart-lang/setup-dart@v1
90+
with:
91+
channel: ${{ matrix.channel }}
92+
93+
- name: Install dependencies
94+
run: dart pub get
95+
96+
- name: Run tests
97+
run: dart test
98+
```
99+
100+
# License
101+
102+
See the [`LICENSE`](LICENSE) file.

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "Setup Dart SDK"
2+
description: "Setup the Dart SDK, and add it to the PATH"
3+
inputs:
4+
channel:
5+
description: "The release channel to install from ('stable', 'beta', or 'dev')"
6+
required: false
7+
default: "stable"
8+
runs:
9+
using: "composite"
10+
steps:
11+
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ runner.os }}
12+
shell: bash

setup.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
###############################################################################
4+
# Bash script that downloads and does setup for a Dart SDK. #
5+
# Takes three params; first listed is the default: #
6+
# $1: Dart channel: stable|beta|dev #
7+
# $2: OS: Linux|Windows|macOS #
8+
# $3: ARCH: x64|ia32 #
9+
###############################################################################
10+
11+
12+
# Parse args.
13+
CHANNEL="${1:-stable}"
14+
OS="${2:-Linux}"
15+
ARCH="${3:-x64}"
16+
OS=$(echo "$OS" | awk '{print tolower($0)}')
17+
echo "Installing Dart SDK from the ${CHANNEL} channel on ${OS}-${ARCH}"
18+
19+
# Calculate download Url. Based on:
20+
# https://dart.dev/tools/sdk/archive#download-urls
21+
PREFIX="https://storage.googleapis.com/dart-archive/channels"
22+
URL="${PREFIX}/${CHANNEL}/release/latest/sdk/dartsdk-${OS}-${ARCH}-release.zip"
23+
echo "Downloading ${URL}..."
24+
25+
# Download installation zip.
26+
curl --connect-timeout 15 --retry 5 "$URL" > "${HOME}/dartsdk.zip"
27+
unzip "${HOME}/dartsdk.zip" -d "${RUNNER_TOOL_CACHE}" > /dev/null
28+
if [ $? -ne 0 ]; then
29+
echo -e "::error::Download failed! Please check passed arguments."
30+
exit 1
31+
fi
32+
rm "${HOME}/dartsdk.zip"
33+
34+
# Update paths.
35+
echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH
36+
echo "${RUNNER_TOOL_CACHE}/dart-sdk/bin" >> $GITHUB_PATH
37+
38+
# Report success, and print version.
39+
echo -e "Succesfully installed Dart SDK:"
40+
${RUNNER_TOOL_CACHE}/dart-sdk/bin/dart --version

0 commit comments

Comments
 (0)