dart-lang / setup-dart

A GitHub Action to install and setup a Dart SDK.
BSD 3-Clause "New" or "Revised" License
194 stars 38 forks source link

setup-dart

setup-dart installs and sets up a Dart SDK for use in GitHub Actions; it:

Usage

To install the latest stable Dart SDK and run typical checks:

name: Dart

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dart-lang/setup-dart@v1

      - run: dart pub get
      - run: dart format --output=none --set-exit-if-changed .
      - run: dart analyze
      - run: dart test

Inputs

The action takes the following inputs:

Outputs

The action produces the following output:

Matrix testing example

You can create matrix jobs that run tests on multiple operating systems, and multiple versions of the Dart SDK.

The following example creates a matrix across two dimensions:

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: [3.1, stable, beta]
    steps:
      - uses: actions/checkout@v4
      - uses: dart-lang/setup-dart@v1
        with:
          sdk: ${{ matrix.sdk }}

      - name: Install dependencies
        run: dart pub get

      - name: Run tests
        run: dart test

License

See the LICENSE file.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

Version history

Please see our CHANGELOG.md file.