Skip to content

Commit

Permalink
ci: analyzer action changes (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Nov 7, 2022
1 parent 8883799 commit 76410c3
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 166 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
workflow_call:
inputs:
package:
required: true
type: string
sdk:
required: false
type: string
default: dart
panaThreshold:
description: Minumum percentage of Dart Package Analyzer score that must be achieved.
required: false
type: number
default: 100

jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: ${{ inputs.package }}
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
if: ${{ inputs.sdk == 'dart' }}
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # pin@v2
if: ${{ inputs.sdk == 'flutter' }}
- run: ${{ inputs.sdk }} pub get
- run: ${{ inputs.sdk }} format --set-exit-if-changed ./

- name: dart analyze
uses: invertase/github-action-dart-analyzer@cdd8652b05bf7ed08ffce30f425436780f869f13 # pin@v1
with:
annotate: true
fatal-infos: true
fatal-warnings: true
annotate-only: false
working-directory: ${{ inputs.package }}

package-analysis:
# `axel-op/dart-package-analyzer` is using `flutter pub upgrade` instead of `get`,
# which ignores pubspec.yaml `dependency_overrides`. Because of that, all `release/*` branches are failing,
# because the package cannot find the "about to be released" version of our sentry-dart package that it depends on.
if: ${{ !startsWith(github.ref, 'refs/heads/release/') && inputs.panaThreshold > 0 }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # pin@v3
id: analysis
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: ${{ inputs.package }}
- name: Check scores
env:
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < ${{ inputs.panaThreshold }} ))
then
echo Score too low!
exit 1
fi
39 changes: 3 additions & 36 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,6 @@ jobs:
min_coverage: 85

analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: ./dart
steps:
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
with:
sdk: stable
- uses: actions/checkout@v3
- run: |
dart pub get
dart analyze --fatal-infos
dart format --set-exit-if-changed ./
package-analysis:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # pin@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 }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 90 ))
then
echo Score too low!
exit 1
fi
uses: ./.github/workflows/analyze.yml
with:
package: dart
43 changes: 3 additions & 40 deletions .github/workflows/dio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,43 +52,6 @@ jobs:
min_coverage: 81

analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: ./dio
steps:
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
with:
sdk: stable
- uses: actions/checkout@v3
- run: |
dart pub get
dart analyze --fatal-infos
dart format --set-exit-if-changed ./
package-analysis:
# `axel-op/dart-package-analyzer` is using `flutter pub upgrade` instead of `get`,
# which ignores pubspec.yaml `dependency_overrides`. Because of that, all `release/*` branches are failing,
# because the package cannot find the "about to be released" version of our sentry-dart package that it depends on.
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # pin@v3
id: analysis
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: dio/
- name: Check scores
env:
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 75 ))
then
echo Score too low!
exit 1
fi
uses: ./.github/workflows/analyze.yml
with:
package: dio
18 changes: 4 additions & 14 deletions .github/workflows/e2e_dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@ jobs:
dart run --define=SENTRY_ENVIRONMENT=e2e
analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: ./e2e_test
steps:
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
with:
sdk: stable
- uses: actions/checkout@v3
- run: |
dart pub get
dart analyze --fatal-infos
dart format --set-exit-if-changed ./
uses: ./.github/workflows/analyze.yml
with:
package: e2e_test
panaThreshold: 0
40 changes: 4 additions & 36 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,42 +132,10 @@ jobs:
esac
analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # pin@v2
- run: |
cd flutter
flutter pub get
flutter format -n --set-exit-if-changed ./
flutter analyze
package-analysis:
# `axel-op/dart-package-analyzer` is using `flutter pub upgrade` instead of `get`,
# which ignores pubspec.yaml `dependency_overrides`. Because of that, all `release/*` branches are failing,
# because the package cannot find the "about to be released" version of our sentry-dart package that it depends on.
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # pin@v3
id: analysis
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: flutter/
- name: Check scores
env:
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 90 ))
then
echo Score too low!
exit 1
fi
uses: ./.github/workflows/analyze.yml
with:
package: flutter
sdk: flutter

pod-lint:
runs-on: macos-latest
Expand Down
43 changes: 3 additions & 40 deletions .github/workflows/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,6 @@ jobs:
min_coverage: 90

analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: ./logging
steps:
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
with:
sdk: stable
- uses: actions/checkout@v3
- run: |
dart pub get
dart analyze --fatal-infos
dart format --set-exit-if-changed ./
package-analysis:
# `axel-op/dart-package-analyzer` is using `flutter pub upgrade` instead of `get`,
# which ignores pubspec.yaml `dependency_overrides`. Because of that, all `release/*` branches are failing,
# because the package cannot find the "about to be released" version of our sentry-dart package that it depends on.
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # pin@v3
id: analysis
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: logging/
- name: Check scores
env:
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 100 ))
then
echo Score too low!
exit 1
fi
uses: ./.github/workflows/analyze.yml
with:
package: logging

0 comments on commit 76410c3

Please sign in to comment.