diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 0000000000..0c254ed012 --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,73 @@ +name: sentry-dart +on: + push: + branches: + - main + pull_request: +defaults: + run: + shell: bash +jobs: + build: + name: Build ${{matrix.sdk}} on ${{matrix.os}} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # TODO: cedx/setup-dart@v2 doesn't work on Windows (doesn't add pub to the PATH?) + # os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, macos-latest] + sdk: [beta, dev, stable] + exclude: + # Bad state: Could not run tests with Observatory enabled. Try setting a different port with --port option. + - os: ubuntu-latest + sdk: beta + # hanging often + - os: ubuntu-latest + sdk: dev + - os: macos-latest + sdk: beta + steps: + - uses: cedx/setup-dart@v2 + with: + release-channel: ${{ matrix.sdk }} + - uses: actions/checkout@v2 + - run: | + cd dart + pub get + - name: Test on Dart VM and collect code coverage + run: | + cd dart + pub run test_coverage + - uses: codecov/codecov-action@v1 + - name: Test on Chrome + run: | + cd dart + pub run test -p vm test/* + - run: | + cd dart + dartanalyzer --fatal-warnings ./ + - run: | + cd dart + dartfmt -n --set-exit-if-changed ./ + package-analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: axel-op/dart-package-analyzer@v3 + id: analysis + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + relativePath: dart/ + - name: Check scores + env: + TOTAL: ${{ steps.analysis.outputs.total }} + TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} + # TODO: Once 4.0.0 lands, change to 100 + run: | + PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX )) + if (( $PERCENTAGE < 90 )) + then + echo Score too low! + exit 1 + fi diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 5de528b067..f2acbcb548 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -1,4 +1,4 @@ -name: Flutter +name: sentry-flutter on: push: branches: @@ -75,10 +75,9 @@ jobs: env: TOTAL: ${{ steps.analysis.outputs.total }} TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} - # TODO: Once 1.0.0 lands, change to 100 run: | PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX )) - if (( $PERCENTAGE < 95 )) + if (( $PERCENTAGE < 90 )) then echo Score too low! exit 1 diff --git a/.gitignore b/.gitignore index 9cdc3692e9..722f819f1a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ android/ ios/ build/ .cxx/ + +.test_coverage.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 187e956604..4c61ffb4d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - remove the `package:args` dependency #94 - move the `package:pedantic` to dev depencies #94 - Added GH Action Changelog verifier #95 +- Added GH Action (CI) for Dart - new Dart code file structure #96 - Base the sdk name on the platform (`sentry.dart` for io & flutter, `sentry.dart.browser` in a browser context) #103 diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index ee7fcd0c7c..e688917675 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -19,3 +19,4 @@ dev_dependencies: pedantic: ^1.9.2 test: ^1.15.4 yaml: ^2.2.1 + test_coverage: ^0.4.2