From 616aa765cbcaec046decd4c9a393845586f5688e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 31 Jul 2023 14:31:41 +0200 Subject: [PATCH 01/21] Revert to check & fail only approach for format & analyze --- .github/workflows/analyze.yml | 14 ++------------ scripts/commit-formatted-code.sh | 16 ---------------- 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100755 scripts/commit-formatted-code.sh diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 60d8b32b21..7b15768881 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -24,7 +24,6 @@ jobs: access_token: ${{ github.token }} analyze: - name: Format, fix & analyze Code if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest timeout-minutes: 20 @@ -39,17 +38,8 @@ jobs: if: ${{ inputs.sdk == 'flutter' }} - run: ${{ inputs.sdk }} pub get - - - run: dart format . - - - run: dart fix --apply - - # actions/checkout fetches only a single commit in a detached HEAD state. Therefore - # we need to pass the current branch, otherwise we can't commit the changes. - # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF - if: env.GITHUB_HEAD_REF != null - + - run: dart format --set-exit-if-changed ./ + - name: dart analyze uses: invertase/github-action-dart-analyzer@cdd8652b05bf7ed08ffce30f425436780f869f13 # pin@v1 with: diff --git a/scripts/commit-formatted-code.sh b/scripts/commit-formatted-code.sh deleted file mode 100755 index 8f77921ceb..0000000000 --- a/scripts/commit-formatted-code.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -euo pipefail - -GITHUB_BRANCH="${1}" - -if [[ $(git status) == *"nothing to commit"* ]]; then - echo "Nothing to commit. All code formatted correctly." -else - echo "Formatted some code. Going to push the changes." - git config --global user.name 'Sentry Github Bot' - git config --global user.email 'bot+github-bot@sentry.io' - git fetch - git checkout ${GITHUB_BRANCH} - git commit -am "Format & fix code" - git push --set-upstream origin ${GITHUB_BRANCH} -fi From 72e95204440695e68249cbc2a37e957cd6331fd1 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 13:54:27 +0200 Subject: [PATCH 02/21] seperate job to run fomrat and fix --- .github/workflows/format_and_fix.yml | 46 ++++++++++++++++++++++++++++ scripts/commit-formatted-code.sh | 16 ++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/format_and_fix.yml create mode 100755 scripts/commit-formatted-code.sh diff --git a/.github/workflows/format_and_fix.yml b/.github/workflows/format_and_fix.yml new file mode 100644 index 0000000000..cf81378d6f --- /dev/null +++ b/.github/workflows/format_and_fix.yml @@ -0,0 +1,46 @@ +on: + workflow_call: + inputs: + package: + required: true + type: string + sdk: + required: false + type: string + default: dart + +jobs: + cancel-previous-workflow: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0 + with: + access_token: ${{ github.token }} + + format-and-fix: + name: Format & fix code + if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} + 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@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 + if: ${{ inputs.sdk == 'flutter' }} + + - run: ${{ inputs.sdk }} pub get + + - run: dart format . + + - run: dart fix --apply + + # actions/checkout fetches only a single commit in a detached HEAD state. Therefore + # we need to pass the current branch, otherwise we can't commit the changes. + # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. + - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF + if: env.GITHUB_HEAD_REF != null diff --git a/scripts/commit-formatted-code.sh b/scripts/commit-formatted-code.sh new file mode 100755 index 0000000000..8f77921ceb --- /dev/null +++ b/scripts/commit-formatted-code.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +GITHUB_BRANCH="${1}" + +if [[ $(git status) == *"nothing to commit"* ]]; then + echo "Nothing to commit. All code formatted correctly." +else + echo "Formatted some code. Going to push the changes." + git config --global user.name 'Sentry Github Bot' + git config --global user.email 'bot+github-bot@sentry.io' + git fetch + git checkout ${GITHUB_BRANCH} + git commit -am "Format & fix code" + git push --set-upstream origin ${GITHUB_BRANCH} +fi From 93ae7710f9a97768ab6bc5879e50b9ea39b73061 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 13:58:38 +0200 Subject: [PATCH 03/21] rename file --- .github/workflows/{format_and_fix.yml => format-and-fix.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{format_and_fix.yml => format-and-fix.yml} (100%) diff --git a/.github/workflows/format_and_fix.yml b/.github/workflows/format-and-fix.yml similarity index 100% rename from .github/workflows/format_and_fix.yml rename to .github/workflows/format-and-fix.yml From 046e029ee61474e282d0ea5c9e137802aa80591a Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:01:27 +0200 Subject: [PATCH 04/21] run workflow file once --- .github/workflows/dart.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 312a573806..8ee7a32b02 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -80,7 +80,13 @@ jobs: path: './dart/coverage/lcov.info' min_coverage: 85 + format-and-fix: + uses: ./.github/workflows/format-and-fix.yml + with: + package: dart + analyze: uses: ./.github/workflows/analyze.yml with: package: dart + \ No newline at end of file From 3782d613b819d0f476d890f0072501d715e18431 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:14:50 +0200 Subject: [PATCH 05/21] update how workflow is run --- .github/workflows/dart.yml | 6 ------ .github/workflows/format-and-fix.yml | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 8ee7a32b02..312a573806 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -80,13 +80,7 @@ jobs: path: './dart/coverage/lcov.info' min_coverage: 85 - format-and-fix: - uses: ./.github/workflows/format-and-fix.yml - with: - package: dart - analyze: uses: ./.github/workflows/analyze.yml with: package: dart - \ No newline at end of file diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index cf81378d6f..5c9566298c 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -1,13 +1,23 @@ on: - workflow_call: + workflow_dispatch: inputs: package: required: true - type: string + type: choice + options: + - dart + - flutter + - dio + - sqflite + - logging + - file sdk: required: false - type: string + type: choice default: dart + options: + - dart + - flutter jobs: cancel-previous-workflow: From 7bfeb23bac52104c90b7b6b8f853fb60762e9fa9 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:25:53 +0200 Subject: [PATCH 06/21] run fix/apply in all packages --- .github/workflows/format-and-fix.yml | 35 ++++++++++------------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index 5c9566298c..e4629b2822 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -1,23 +1,6 @@ on: workflow_dispatch: - inputs: - package: - required: true - type: choice - options: - - dart - - flutter - - dio - - sqflite - - logging - - file - sdk: - required: false - type: choice - default: dart - options: - - dart - - flutter + push: jobs: cancel-previous-workflow: @@ -33,17 +16,23 @@ jobs: if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest timeout-minutes: 20 + strategy: + matrix: + package: [ dart, flutter, dio, sqflite, logging, file ] defaults: run: - working-directory: ${{ inputs.package }} + working-directory: ${{ matrix.package }} steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 - if: ${{ inputs.sdk == 'dart' }} + if: ${{ package.package != 'flutter' }} - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 - if: ${{ inputs.sdk == 'flutter' }} + if: ${{ package.package == 'flutter' }} - - run: ${{ inputs.sdk }} pub get + - run: dart pub get + if: ${{ package.package != 'flutter' }} + - run: flutter pub get + if: ${{ package.package == 'flutter' }} - run: dart format . @@ -53,4 +42,4 @@ jobs: # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF - if: env.GITHUB_HEAD_REF != null +# if: env.GITHUB_HEAD_REF != null From d1e4030e1f1eed27abe04f58e84e6c051f89d0e2 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:29:13 +0200 Subject: [PATCH 07/21] fix workflow --- .github/workflows/format-and-fix.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index e4629b2822..a4a550b3c1 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -25,14 +25,14 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 - if: ${{ package.package != 'flutter' }} + if: ${{ matrix.package != 'flutter' }} - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 - if: ${{ package.package == 'flutter' }} + if: ${{ matrix.package == 'flutter' }} - run: dart pub get - if: ${{ package.package != 'flutter' }} + if: ${{ matrix.package != 'flutter' }} - run: flutter pub get - if: ${{ package.package == 'flutter' }} + if: ${{ matrix.package == 'flutter' }} - run: dart format . @@ -41,5 +41,5 @@ jobs: # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF +# - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF # if: env.GITHUB_HEAD_REF != null From 48599237087765580949095a4ae9714e2470dd9e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:35:41 +0200 Subject: [PATCH 08/21] run in root dir --- .github/workflows/format-and-fix.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index a4a550b3c1..cbd6ac85de 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -16,30 +16,14 @@ jobs: if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest timeout-minutes: 20 - strategy: - matrix: - package: [ dart, flutter, dio, sqflite, logging, file ] - defaults: - run: - working-directory: ${{ matrix.package }} steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 - if: ${{ matrix.package != 'flutter' }} - - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 - if: ${{ matrix.package == 'flutter' }} - - - run: dart pub get - if: ${{ matrix.package != 'flutter' }} - - run: flutter pub get - if: ${{ matrix.package == 'flutter' }} - - run: dart format . - - run: dart fix --apply # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. -# - run: ../scripts/commit-formatted-code.sh $GITHUB_HEAD_REF + - run: scripts/commit-formatted-code.sh $GITHUB_HEAD_REF # if: env.GITHUB_HEAD_REF != null From 9558cfb3ebb26459f7fb1883f884efc696ec86b7 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:38:31 +0200 Subject: [PATCH 09/21] update path --- .github/workflows/format-and-fix.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index cbd6ac85de..b82436dc83 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -25,5 +25,4 @@ jobs: # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - run: scripts/commit-formatted-code.sh $GITHUB_HEAD_REF -# if: env.GITHUB_HEAD_REF != null + - run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF From cb0a512e2f0379cfea6723452d2e8ef1eab75f73 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:45:11 +0200 Subject: [PATCH 10/21] extract branch name --- .github/workflows/format-and-fix.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index b82436dc83..e9cc48b354 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -22,7 +22,12 @@ jobs: - run: dart format . - run: dart fix --apply + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF + - run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} From 7aef82c3635f531647dc75dc182b7e7d0a601076 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Mon, 14 Aug 2023 12:46:19 +0000 Subject: [PATCH 11/21] Format & fix code --- dio/lib/src/dio_event_processor.dart | 1 + flutter/lib/src/binding_wrapper.dart | 1 - flutter/lib/src/navigation/sentry_navigator_observer.dart | 1 - .../src/user_interaction/sentry_user_interaction_widget.dart | 1 - flutter/lib/src/view_hierarchy/sentry_tree_walker.dart | 2 -- logging/lib/src/logging_integration.dart | 1 - 6 files changed, 1 insertion(+), 6 deletions(-) diff --git a/dio/lib/src/dio_event_processor.dart b/dio/lib/src/dio_event_processor.dart index 3a9603abd1..55ffb028ae 100644 --- a/dio/lib/src/dio_event_processor.dart +++ b/dio/lib/src/dio_event_processor.dart @@ -158,5 +158,6 @@ class DioEventProcessor implements EventProcessor { return null; } } + return null; } } diff --git a/flutter/lib/src/binding_wrapper.dart b/flutter/lib/src/binding_wrapper.dart index 4d6856861a..df099fc50b 100644 --- a/flutter/lib/src/binding_wrapper.dart +++ b/flutter/lib/src/binding_wrapper.dart @@ -1,6 +1,5 @@ // ignore_for_file: invalid_use_of_internal_member -import '../sentry_flutter.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; diff --git a/flutter/lib/src/navigation/sentry_navigator_observer.dart b/flutter/lib/src/navigation/sentry_navigator_observer.dart index 135d131ec2..dd60375336 100644 --- a/flutter/lib/src/navigation/sentry_navigator_observer.dart +++ b/flutter/lib/src/navigation/sentry_navigator_observer.dart @@ -1,6 +1,5 @@ import 'package:flutter/widgets.dart'; -import '../../sentry_flutter.dart'; import '../sentry_native.dart'; import '../sentry_native_channel.dart'; diff --git a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart index f98a919065..3b5fec5224 100644 --- a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart +++ b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart @@ -207,7 +207,6 @@ import 'package:flutter/rendering.dart'; import 'package:meta/meta.dart'; import '../../sentry_flutter.dart'; -import '../widget_utils.dart'; import 'user_interaction_widget.dart'; const _tapDeltaArea = 20 * 20; diff --git a/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart b/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart index 2a85bf49be..94b8fa47d7 100644 --- a/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart +++ b/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart @@ -203,8 +203,6 @@ import 'package:flutter/widgets.dart'; -import '../../sentry_flutter.dart'; -import '../widget_utils.dart'; class _TreeWalker { static const _privateDelimiter = '_'; diff --git a/logging/lib/src/logging_integration.dart b/logging/lib/src/logging_integration.dart index 304deb9e57..392cd13c68 100644 --- a/logging/lib/src/logging_integration.dart +++ b/logging/lib/src/logging_integration.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:logging/logging.dart'; import 'package:sentry/sentry.dart'; -import 'extension.dart'; import 'version.dart'; /// An [Integration] which listens to all messages of the From fc0be25ee9db0fafaae7fc5c67559653430c1f49 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:54:48 +0200 Subject: [PATCH 12/21] revert changes --- dio/lib/src/dio_event_processor.dart | 1 - flutter/lib/src/binding_wrapper.dart | 1 + flutter/lib/src/navigation/sentry_navigator_observer.dart | 1 + .../src/user_interaction/sentry_user_interaction_widget.dart | 1 + flutter/lib/src/view_hierarchy/sentry_tree_walker.dart | 2 ++ logging/lib/src/logging_integration.dart | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dio/lib/src/dio_event_processor.dart b/dio/lib/src/dio_event_processor.dart index 55ffb028ae..3a9603abd1 100644 --- a/dio/lib/src/dio_event_processor.dart +++ b/dio/lib/src/dio_event_processor.dart @@ -158,6 +158,5 @@ class DioEventProcessor implements EventProcessor { return null; } } - return null; } } diff --git a/flutter/lib/src/binding_wrapper.dart b/flutter/lib/src/binding_wrapper.dart index df099fc50b..4d6856861a 100644 --- a/flutter/lib/src/binding_wrapper.dart +++ b/flutter/lib/src/binding_wrapper.dart @@ -1,5 +1,6 @@ // ignore_for_file: invalid_use_of_internal_member +import '../sentry_flutter.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; diff --git a/flutter/lib/src/navigation/sentry_navigator_observer.dart b/flutter/lib/src/navigation/sentry_navigator_observer.dart index dd60375336..135d131ec2 100644 --- a/flutter/lib/src/navigation/sentry_navigator_observer.dart +++ b/flutter/lib/src/navigation/sentry_navigator_observer.dart @@ -1,5 +1,6 @@ import 'package:flutter/widgets.dart'; +import '../../sentry_flutter.dart'; import '../sentry_native.dart'; import '../sentry_native_channel.dart'; diff --git a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart index 3b5fec5224..f98a919065 100644 --- a/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart +++ b/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart @@ -207,6 +207,7 @@ import 'package:flutter/rendering.dart'; import 'package:meta/meta.dart'; import '../../sentry_flutter.dart'; +import '../widget_utils.dart'; import 'user_interaction_widget.dart'; const _tapDeltaArea = 20 * 20; diff --git a/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart b/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart index 94b8fa47d7..2a85bf49be 100644 --- a/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart +++ b/flutter/lib/src/view_hierarchy/sentry_tree_walker.dart @@ -203,6 +203,8 @@ import 'package:flutter/widgets.dart'; +import '../../sentry_flutter.dart'; +import '../widget_utils.dart'; class _TreeWalker { static const _privateDelimiter = '_'; diff --git a/logging/lib/src/logging_integration.dart b/logging/lib/src/logging_integration.dart index 392cd13c68..304deb9e57 100644 --- a/logging/lib/src/logging_integration.dart +++ b/logging/lib/src/logging_integration.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:logging/logging.dart'; import 'package:sentry/sentry.dart'; +import 'extension.dart'; import 'version.dart'; /// An [Integration] which listens to all messages of the From 1c6f8aa04c82dfb10b26ae120f6ef5ce87b6d0a5 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:57:11 +0200 Subject: [PATCH 13/21] setup flutter --- .github/workflows/format-and-fix.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index e9cc48b354..2e51c48fd5 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -19,9 +19,12 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 + - run: dart format . - run: dart fix --apply + # Source: https://stackoverflow.com/a/58035262 - name: Extract branch name shell: bash run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT @@ -30,4 +33,5 @@ jobs: # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} + - name: Commit & push + run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} From 9b8d4f4e1e6c72d9b4bb4bce997ddf21f1909f5b Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 14:57:20 +0200 Subject: [PATCH 14/21] =?UTF-8?q?don=E2=80=99t=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/format-and-fix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index 2e51c48fd5..f5c9f607ae 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -33,5 +33,5 @@ jobs: # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - name: Commit & push - run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} +# - name: Commit & push +# run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} From 777880fb48cf6c21cc7e72b345f9acca78df5759 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 15:09:42 +0200 Subject: [PATCH 15/21] run pin package directories --- .github/workflows/format-and-fix.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index f5c9f607ae..a6d204460c 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -16,12 +16,29 @@ jobs: if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest timeout-minutes: 20 + matrix: + package: [ + {name: dart, sdk: dart}, + {name: dio, sdk: dart}, + {name: file, sdk: dart}, + {name: flutter, sdk: flutter}, + {name: logging, sdk: dart}, + {name: sqflite, sdk: flutter}, + ] + defaults: + run: + working-directory: ${{ matrix.package.name }} steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1 + if: ${{ matrix.package.sdk == 'dart' }} - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0 + if: ${{ matrix.package.sdk == 'flutter' }} + + - run: ${{ matrix.package.sdk }} pub get - run: dart format . + - run: dart fix --apply # Source: https://stackoverflow.com/a/58035262 From 85f656b287c357b1d71b2ab762e138cfc576d5bb Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 15:11:22 +0200 Subject: [PATCH 16/21] add strategy --- .github/workflows/format-and-fix.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index a6d204460c..6a4f0fe551 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -16,15 +16,16 @@ jobs: if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} runs-on: ubuntu-latest timeout-minutes: 20 - matrix: - package: [ - {name: dart, sdk: dart}, - {name: dio, sdk: dart}, - {name: file, sdk: dart}, - {name: flutter, sdk: flutter}, - {name: logging, sdk: dart}, - {name: sqflite, sdk: flutter}, - ] + strategy: + matrix: + package: [ + {name: dart, sdk: dart}, + {name: dio, sdk: dart}, + {name: file, sdk: dart}, + {name: flutter, sdk: flutter}, + {name: logging, sdk: dart}, + {name: sqflite, sdk: flutter}, + ] defaults: run: working-directory: ${{ matrix.package.name }} From 5ca84a628fd75d19e0a4d9a3ed5959a253f552e8 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 14 Aug 2023 15:13:55 +0200 Subject: [PATCH 17/21] only run on workflow dispatch --- .github/workflows/format-and-fix.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format-and-fix.yml b/.github/workflows/format-and-fix.yml index 6a4f0fe551..fa77a33098 100644 --- a/.github/workflows/format-and-fix.yml +++ b/.github/workflows/format-and-fix.yml @@ -1,6 +1,5 @@ on: workflow_dispatch: - push: jobs: cancel-previous-workflow: @@ -51,5 +50,5 @@ jobs: # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. -# - name: Commit & push -# run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} + - name: Commit & push + run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }} From 43b2ba7e61e12767928b914bf8e170805062c279 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 29 Aug 2023 17:09:12 +0200 Subject: [PATCH 18/21] run `dart fix --apply` --- dio/test/dio_event_processor_test.dart | 24 +++++++++---------- dio/test/failed_request_interceptor_test.dart | 2 +- dio/test/mocks.dart | 2 +- sqflite/test/mocks/mocks.dart | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dio/test/dio_event_processor_test.dart b/dio/test/dio_event_processor_test.dart index af45d0c681..3cd060ea8e 100644 --- a/dio/test/dio_event_processor_test.dart +++ b/dio/test/dio_event_processor_test.dart @@ -67,7 +67,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -96,7 +96,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -125,7 +125,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -177,7 +177,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -207,7 +207,7 @@ void main() { data: 'foobar', headers: Headers.fromMap(>{ 'foo': ['bar'], - 'set-cookie': ['foo=bar'] + 'set-cookie': ['foo=bar'], }), requestOptions: request, isRedirect: true, @@ -219,7 +219,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -248,7 +248,7 @@ void main() { response: Response( data: 'foobar', headers: Headers.fromMap(>{ - 'foo': ['bar'] + 'foo': ['bar'], }), requestOptions: request, isRedirect: true, @@ -260,7 +260,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -320,7 +320,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; @@ -338,7 +338,7 @@ void main() { final dataByType = { ResponseType.plain: ['plain'], ResponseType.bytes: [ - [1337] + [1337], ], ResponseType.json: [ 9001, @@ -347,7 +347,7 @@ void main() { true, ['list'], {'map-key': 'map-value'}, - ] + ], }; for (final entry in dataByType.entries) { @@ -375,7 +375,7 @@ void main() { throwable: throwable, exceptions: [ fixture.sentryError(throwable), - fixture.sentryError(dioError) + fixture.sentryError(dioError), ], ); final processedEvent = sut.apply(event) as SentryEvent; diff --git a/dio/test/failed_request_interceptor_test.dart b/dio/test/failed_request_interceptor_test.dart index 80eede8803..e7fb5a63e1 100644 --- a/dio/test/failed_request_interceptor_test.dart +++ b/dio/test/failed_request_interceptor_test.dart @@ -113,7 +113,7 @@ class Fixture { FailedRequestInterceptor getSut({ List failedRequestStatusCodes = const [ - SentryStatusCode.defaultRange() + SentryStatusCode.defaultRange(), ], List failedRequestTargets = const ['.*'], }) { diff --git a/dio/test/mocks.dart b/dio/test/mocks.dart index 83454cbfb3..5ed6dcd00a 100644 --- a/dio/test/mocks.dart +++ b/dio/test/mocks.dart @@ -42,7 +42,7 @@ final fakeEvent = SentryEvent( type: 'navigation', data: {'screen': 'MainActivity', 'state': 'created'}, level: SentryLevel.info, - ) + ), ], contexts: Contexts( operatingSystem: const SentryOperatingSystem( diff --git a/sqflite/test/mocks/mocks.dart b/sqflite/test/mocks/mocks.dart index 0a3115df74..5ecd57ce50 100644 --- a/sqflite/test/mocks/mocks.dart +++ b/sqflite/test/mocks/mocks.dart @@ -33,7 +33,7 @@ ISentrySpan startTransactionShim( DatabaseExecutor, ], customMocks: [ - MockSpec(fallbackGenerators: {#startTransaction: startTransactionShim}) + MockSpec(fallbackGenerators: {#startTransaction: startTransactionShim}), ], ) void main() {} From 1872854cee2d61b8ee0380dd2039e9b613fa2b5a Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 4 Sep 2023 14:16:13 +0200 Subject: [PATCH 19/21] run fix & format --- sqflite/test/mocks/mocks.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqflite/test/mocks/mocks.dart b/sqflite/test/mocks/mocks.dart index 5ecd57ce50..bcafb94302 100644 --- a/sqflite/test/mocks/mocks.dart +++ b/sqflite/test/mocks/mocks.dart @@ -33,7 +33,9 @@ ISentrySpan startTransactionShim( DatabaseExecutor, ], customMocks: [ - MockSpec(fallbackGenerators: {#startTransaction: startTransactionShim}), + MockSpec( + fallbackGenerators: {#startTransaction: startTransactionShim}, + ), ], ) void main() {} From 36866985e3b7daa94dcb8b1d03b17c2b74572b94 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 5 Sep 2023 10:31:51 +0200 Subject: [PATCH 20/21] Use ios sim 16.4 --- .github/workflows/flutter_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter_test.yml b/.github/workflows/flutter_test.yml index 375db90f57..5beddb26a9 100644 --- a/.github/workflows/flutter_test.yml +++ b/.github/workflows/flutter_test.yml @@ -134,7 +134,7 @@ jobs: - name: launch ios simulator id: sim run: | - simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-2) + simulator_id=$(xcrun simctl create sentryPhone com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-4) echo "SIMULATOR_ID=${simulator_id}" >> "$GITHUB_OUTPUT" xcrun simctl boot ${simulator_id} # Disable flutter integration tests because of flaky execution From 1087024646115e510f0a465d007f3d7e15d3a9bf Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 11 Sep 2023 11:57:05 +0200 Subject: [PATCH 21/21] format & fix --- flutter/test/sentry_navigator_observer_test.dart | 1 + sqflite/lib/src/sentry_database.dart | 15 +++++++++++---- sqflite/test/sentry_batch_test.dart | 8 ++++++-- sqflite/test/sentry_database_test.dart | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/flutter/test/sentry_navigator_observer_test.dart b/flutter/test/sentry_navigator_observer_test.dart index d3871b4390..d4c2499efc 100644 --- a/flutter/test/sentry_navigator_observer_test.dart +++ b/flutter/test/sentry_navigator_observer_test.dart @@ -756,6 +756,7 @@ class _MockHub extends MockHub { @override final options = SentryOptions(dsn: fakeDsn); + @override late final scope = Scope(options); @override diff --git a/sqflite/lib/src/sentry_database.dart b/sqflite/lib/src/sentry_database.dart index 71147c3464..d148eb7ded 100644 --- a/sqflite/lib/src/sentry_database.dart +++ b/sqflite/lib/src/sentry_database.dart @@ -58,8 +58,11 @@ class SentryDatabase extends SentryDatabaseExecutor implements Database { @internal Hub? hub, }) : _hub = hub ?? HubAdapter(), dbName = p.basenameWithoutExtension(_database.path), - super(_database, - hub: hub, dbName: p.basenameWithoutExtension(_database.path)) { + super( + _database, + hub: hub, + dbName: p.basenameWithoutExtension(_database.path), + ) { // ignore: invalid_use_of_internal_member final options = _hub.options; options.sdk.addIntegration('SentrySqfliteTracing'); @@ -132,8 +135,12 @@ class SentryDatabase extends SentryDatabaseExecutor implements Database { setDatabaseAttributeData(span, dbName); Future newAction(Transaction txn) async { - final executor = SentryDatabaseExecutor(txn, - parentSpan: span, hub: _hub, dbName: dbName); + final executor = SentryDatabaseExecutor( + txn, + parentSpan: span, + hub: _hub, + dbName: dbName, + ); final sentrySqfliteTransaction = SentrySqfliteTransaction(executor, hub: _hub, dbName: dbName); diff --git a/sqflite/test/sentry_batch_test.dart b/sqflite/test/sentry_batch_test.dart index ce6f59e0d5..e3b24d811a 100644 --- a/sqflite/test/sentry_batch_test.dart +++ b/sqflite/test/sentry_batch_test.dart @@ -296,7 +296,9 @@ SELECT * FROM Product'''; final span = fixture.tracer.children.last; expect(span.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem); expect( - span.data[SentryDatabase.dbNameKey], (db as SentryDatabase).dbName); + span.data[SentryDatabase.dbNameKey], + (db as SentryDatabase).dbName, + ); await db.close(); }); @@ -313,7 +315,9 @@ SELECT * FROM Product'''; final span = fixture.tracer.children.last; expect(span.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem); expect( - span.data[SentryDatabase.dbNameKey], (db as SentryDatabase).dbName); + span.data[SentryDatabase.dbNameKey], + (db as SentryDatabase).dbName, + ); await db.close(); }); diff --git a/sqflite/test/sentry_database_test.dart b/sqflite/test/sentry_database_test.dart index e05bd2367c..5c954426bb 100644 --- a/sqflite/test/sentry_database_test.dart +++ b/sqflite/test/sentry_database_test.dart @@ -112,7 +112,9 @@ void main() { expect(insertSpan.context.parentSpanId, trSpan.context.spanId); expect(insertSpan.status, SpanStatus.ok()); expect( - insertSpan.data[SentryDatabase.dbSystemKey], SentryDatabase.dbSystem); + insertSpan.data[SentryDatabase.dbSystemKey], + SentryDatabase.dbSystem, + ); expect(insertSpan.data[SentryDatabase.dbNameKey], inMemoryDatabasePath); expect(