From ac00ba0eec2ea69cc354e1273f31f11273ce05af Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Mon, 7 Jun 2021 19:15:41 +0200 Subject: [PATCH 1/2] Setup CI --- .github/workflows/test-package.yml | 65 ++++++++++++++++++++++++++++++ lib/cronet.dart | 5 +++ lib/src/my_sum.dart | 6 +++ test/my_test.dart | 13 ++++++ 4 files changed, 89 insertions(+) create mode 100644 .github/workflows/test-package.yml create mode 100644 lib/cronet.dart create mode 100644 lib/src/my_sum.dart create mode 100644 test/my_test.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml new file mode 100644 index 0000000..9a94565 --- /dev/null +++ b/.github/workflows/test-package.yml @@ -0,0 +1,65 @@ +# Copyright (c) 2021, 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. + +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart stable. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [stable] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Analyze code + run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + + # Run tests on a matrix consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release channel: dev + test: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [2.13.0, dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm + if: always() && steps.install.outcome == 'success' diff --git a/lib/cronet.dart b/lib/cronet.dart new file mode 100644 index 0000000..6914515 --- /dev/null +++ b/lib/cronet.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2021, 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. + +export 'src/my_sum.dart'; diff --git a/lib/src/my_sum.dart b/lib/src/my_sum.dart new file mode 100644 index 0000000..9c2486d --- /dev/null +++ b/lib/src/my_sum.dart @@ -0,0 +1,6 @@ +// Copyright (c) 2021, 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. + +/// Computes the sum of its arguments. +int mySum(int a, int b) => a + b; diff --git a/test/my_test.dart b/test/my_test.dart new file mode 100644 index 0000000..cdf0c4f --- /dev/null +++ b/test/my_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2021, 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. + +import 'package:test/test.dart'; +import 'package:cronet/cronet.dart'; + +void main() { + test('dummy test', () { + final result = mySum(2, 40); + expect(result, 42); + }); +} From a591809f7aa9eecb081716d083501d7b930be1c4 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Mon, 7 Jun 2021 19:19:21 +0200 Subject: [PATCH 2/2] fix typo --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 9a94565..e69785c 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -7,9 +7,9 @@ name: Dart CI on: # Run on PRs and pushes to the default branch. push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] schedule: - cron: "0 0 * * 0"