Skip to content

Commit

Permalink
Merge pull request #10 from pedrox-hs/workflows/testing
Browse files Browse the repository at this point in the history
Create testing.yml workflow
  • Loading branch information
kodiakhq[bot] authored Nov 3, 2023
2 parents 1d506b4 + 067aa1a commit 8d39732
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 6 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Run automated tests

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

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:

find-tests:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.find-tests.outputs.tests }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Find tests
id: find-tests
run: |
testable_pkg=$(find . -type f -name pubspec.yaml -execdir test -e './test' \; -exec dirname {} \; | sed -e 's,^\./,,' | sort -u | awk '{print}' ORS='", "')
echo "tests=[\"${testable_pkg::-4}\"]" >> $GITHUB_OUTPUT
run-tests:
needs: find-tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tests: ${{ fromJson(needs.find-tests.outputs.tests) }}
defaults:
run:
working-directory: ${{ matrix.tests }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache pub packages
uses: actions/cache@v2
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- name: Check if has Flutter SDK on pubspec.yaml
id: has-flutter-sdk
run: |
if grep -q 'sdk: *flutter' pubspec.yaml; then
echo "has-flutter-sdk=true" >> $GITHUB_OUTPUT
else
echo "has-flutter-sdk=false" >> $GITHUB_OUTPUT
fi
- name: Setup Dart
uses: dart-lang/setup-dart@v1
if: steps.has-flutter-sdk.outputs.has-flutter-sdk == 'false'

- name: Setup Flutter
uses: subosito/flutter-action@v1
if: steps.has-flutter-sdk.outputs.has-flutter-sdk == 'true'

- name: Install Coverage
run: |
dart pub global activate coverage
if: steps.has-flutter-sdk.outputs.has-flutter-sdk == 'false'

- name: Get package name
id: package-name
run: |
echo "package=$(grep -E '^name:' pubspec.yaml | awk '{print $2}')" >> $GITHUB_OUTPUT
- uses: stelynx/[email protected]
with:
package: ${{ steps.package-name.outputs.package }}
path: ${{ matrix.tests }}/lib
test_file: ${{ matrix.tests }}/test/full_coverage_helper.dart

- name: Run tests
run: |
dart pub get
if command -v test_with_coverage &> /dev/null; then
test_with_coverage
else
flutter test --coverage
fi
- name: Codecov
uses: codecov/codecov-action@v3
with:
name: ${{ matrix.tests }}
file: ${{ matrix.tests }}/coverage/lcov.info
3 changes: 0 additions & 3 deletions auto_route/auto_route/test/auto_route_test.dart

This file was deleted.

2 changes: 2 additions & 0 deletions auto_route/generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ environment:
sdk: '>=2.19.6 <3.0.0'

dependencies:
flutter:
sdk: flutter
analyzer: any
build: any
collection: any
Expand Down
3 changes: 0 additions & 3 deletions auto_route/generator/test/auto_route_generator_test.dart

This file was deleted.

0 comments on commit 8d39732

Please sign in to comment.