This GitHub Action installs and sets up of a Dart SDK for use in actions by:
- Downloading the Dart SDK
- Adding the
dart
command andpub
cache to path
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.7.2
or2.12.0-1.4.beta
- A release channel, which will install the latest build from that channel.
Available channels are
stable
,beta
,dev
, andmain
. See https://dart.dev/tools/sdk/archive for details.
- A specific SDK version, e.g.
-
flavor
: Which build flavor to setup.- Avaliable build flavors are
raw
andrelease
. release
flavor contains published builds.raw
flavor contains unpublished builds, which can be used by developers to test against SDK versions before a release.main
release channel only supportsraw
build flavor.
- Avaliable build flavors are
-
architecture
: The CPU architecture to setup support for. Valid options arex64
,ia32
,arm
, andarm64
. Note that not all CPU architectures are supported on all operating systems; see https://dart.dev/tools/sdk/archive for valid combinations.
Install the latest stable SDK, and run Hello World.
name: Dart
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1.3
- name: Install dependencies
run: dart pub get
- name: Hello world
run: dart bin/hello_world.dart
Various static checks:
- Check static analysis with the Dart analyzer
- Check code follows Dart idiomatic formatting
- Check that unit tests pass
...
steps:
- name: Install dependencies
run: dart pub get
- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .
- name: Analyze project source
run: dart analyze
- name: Run tests
run: dart test
You can create matrix jobs that run tests on multiple operating systems, and multiple versions of the Dart SDK.
The following example create a double matrix across two dimensions:
- All three major operating systems: Linux, macOS, and Windows.
- Five Dart SDKs: Latest stable, beta & dev plus two specific versions.
name: Dart
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [stable, beta, dev, 2.10.3, 2.12.0-29.10.beta]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1.3
with:
sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Run tests
run: dart test
The Dart SDK continously evolves, and new features and tools are added. The Dart
2.10 SDK introduced a new unified dart
developer tool, which is what we use in
the usage examples above for installing dependencies, verifying formatting,
analyzing, etc. If you need to test a combination of SDKs before and after Dart
2.10, we recommend splitting your test job as illustrated here:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [stable, beta, dev]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1.3
with:
sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
- name: Analyze code
run: dart analyze
- name: Run tests
run: dart test
test_old_sdks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [2.9.0, 2.8.1]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1.3
with:
sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: pub get
- name: Check formatting
run: dartfmt --dry-run --set-exit-if-changed .
- name: Analyze code
run: dartanalyzer --fatal-warnings .
- name: Run tests
run: pub run test
-
The install location of the Dart SDK is now available in an environment variable,
DART_HOME
(#43) -
Fixed a issue where cached downloads could lead to unzip issues on self hosted runners (#35)
- Fixed a path issue impacting git dependencies on Windows.
- Added a
flavor
option setup.sh to allow downloading unpublished builds.
- Promoted to 1.0 stable.
- Fixed a Windows
pub global activate
path issue.
- Removed previously deprecated input
channel
. Use thesdk
input instead. - Added support for specifying the CPU architecture.
- Added support for installing SDKs from the
main
channel.
- Added support for installing a specific SDK version (e.g.
2.10.0
).
- Initial version.
See the LICENSE
file.