diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 0000000000..ad808fae59 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -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 diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 449c177c1d..aa9edffc4b 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -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 diff --git a/.github/workflows/dio.yml b/.github/workflows/dio.yml index 0406a16b6d..94ab38a367 100644 --- a/.github/workflows/dio.yml +++ b/.github/workflows/dio.yml @@ -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 diff --git a/.github/workflows/e2e_dart.yml b/.github/workflows/e2e_dart.yml index ec70dd20b1..469258123e 100644 --- a/.github/workflows/e2e_dart.yml +++ b/.github/workflows/e2e_dart.yml @@ -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 diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 9add96e012..d515476b91 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -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 diff --git a/.github/workflows/logging.yml b/.github/workflows/logging.yml index 108dc1fe93..412502c78d 100644 --- a/.github/workflows/logging.yml +++ b/.github/workflows/logging.yml @@ -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