diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..cd60f436 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,52 @@ +name: Combined Coverage Report + +on: + workflow_run: + workflows: + - 'functions_client' + - 'gotrue' + - 'postgrest' + - 'realtime_client' + - 'storage_client' + - 'supabase' + - 'supabase_flutter' + - 'yet_another_json_isolate' + types: + - completed + +jobs: + combine-coverage: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Dart + uses: dart-lang/setup-dart@v1 + with: + sdk: stable + + - name: Install coverage tool + run: dart pub global activate coverage + + - name: Create coverage directory + run: mkdir -p coverage + + - name: Download coverage artifacts + uses: actions/download-artifact@v4 + with: + pattern: coverage-flutter-* + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Combine coverage reports + run: | + find coverage -name "lcov.info" -exec cat {} + > coverage/combined_lcov.info + + - name: Upload combined coverage to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage/combined_lcov.info diff --git a/.github/workflows/functions_client.yml b/.github/workflows/functions_client.yml index 7db4a9f7..e5088782 100644 --- a/.github/workflows/functions_client.yml +++ b/.github/workflows/functions_client.yml @@ -4,16 +4,7 @@ on: push: branches: - main - paths: - - 'packages/functions_client/**' - - '.github/workflows/functions_client.yml' - - 'packages/yet_another_json_isolate/**' - pull_request: - paths: - - 'packages/functions_client/**' - - '.github/workflows/functions_client.yml' - - 'packages/yet_another_json_isolate/**' jobs: test: @@ -51,7 +42,25 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Run tests - run: dart test + run: dart test --coverage=./coverage + + - name: Format coverage + if: ${{ matrix.sdk == 'stable'}} + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-functions-client + path: ./packages/functions_client/coverage/lcov.info diff --git a/.github/workflows/gotrue.yml b/.github/workflows/gotrue.yml index d7df105f..31cf0071 100644 --- a/.github/workflows/gotrue.yml +++ b/.github/workflows/gotrue.yml @@ -4,14 +4,7 @@ on: push: branches: - main - paths: - - 'packages/gotrue/**' - - '.github/workflows/gotrue.yml' - pull_request: - paths: - - 'packages/gotrue/**' - - '.github/workflows/gotrue.yml' jobs: test: @@ -48,8 +41,13 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Build Docker image run: | cd ../../infra/gotrue @@ -62,4 +60,16 @@ jobs: time: '5s' - name: Run tests - run: dart test --concurrency=1 + run: dart test --concurrency=1 --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-gotrue + path: ./packages/gotrue/coverage/lcov.info diff --git a/.github/workflows/postgrest.yml b/.github/workflows/postgrest.yml index 49e6f637..04c86f6b 100644 --- a/.github/workflows/postgrest.yml +++ b/.github/workflows/postgrest.yml @@ -4,16 +4,7 @@ on: push: branches: - main - paths: - - 'packages/postgrest/**' - - '.github/workflows/postgrest.yml' - - 'packages/yet_another_json_isolate/**' - pull_request: - paths: - - 'packages/postgrest/**' - - '.github/workflows/postgrest.yml' - - 'packages/yet_another_json_isolate/**' jobs: test: @@ -50,8 +41,13 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Build Docker image run: | cd ../../infra/postgrest @@ -64,4 +60,16 @@ jobs: time: '5s' - name: Run tests - run: dart test --concurrency=1 + run: dart test --concurrency=1 --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-postgrest + path: ./packages/postgrest/coverage/lcov.info diff --git a/.github/workflows/realtime_client.yml b/.github/workflows/realtime_client.yml index 48216378..002a0f85 100644 --- a/.github/workflows/realtime_client.yml +++ b/.github/workflows/realtime_client.yml @@ -4,14 +4,7 @@ on: push: branches: - main - paths: - - 'packages/realtime_client/**' - - '.github/workflows/realtime_client.yml' - pull_request: - paths: - - 'packages/realtime_client/**' - - '.github/workflows/realtime_client.yml' jobs: test: @@ -48,7 +41,24 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Run tests - run: dart test + run: dart test --concurrency=1 --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-realtime-client + path: ./packages/realtime_client/coverage/lcov.info diff --git a/.github/workflows/storage_client.yml b/.github/workflows/storage_client.yml index 33e0b989..ac00962a 100644 --- a/.github/workflows/storage_client.yml +++ b/.github/workflows/storage_client.yml @@ -4,13 +4,7 @@ on: push: branches: - main - paths: - - 'packages/storage_client/**' - - '.github/workflows/storage_client.yml' pull_request: - paths: - - 'packages/storage_client/**' - - '.github/workflows/storage_client.yml' jobs: test: @@ -47,8 +41,13 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Build Docker image run: | cd ../../infra/storage_client @@ -61,4 +60,16 @@ jobs: time: '5s' - name: Run tests - run: dart test + run: dart test --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-storage-client + path: ./packages/storage_client/coverage/lcov.info diff --git a/.github/workflows/supabase.yml b/.github/workflows/supabase.yml index 80b8b59d..32e9bb69 100644 --- a/.github/workflows/supabase.yml +++ b/.github/workflows/supabase.yml @@ -4,24 +4,7 @@ on: push: branches: - main - paths: - - 'packages/supabase/**' - - '.github/workflows/supabase.yml' - - 'packages/functions_client/**' - - 'packages/gotrue/**' - - 'packages/postgrest/**' - - 'packages/realtime_client/**' - - 'packages/storage_client/**' - pull_request: - paths: - - 'packages/supabase/**' - - '.github/workflows/supabase.yml' - - 'packages/functions_client/**' - - 'packages/gotrue/**' - - 'packages/postgrest/**' - - 'packages/realtime_client/**' - - 'packages/storage_client/**' jobs: test: @@ -58,7 +41,24 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Run tests - run: dart test --concurrency=1 + run: dart test --concurrency=1 --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-supabase + path: ./packages/supabase/coverage/lcov.info diff --git a/.github/workflows/supabase_flutter.yml b/.github/workflows/supabase_flutter.yml index 1ce67e14..c7ba70ee 100644 --- a/.github/workflows/supabase_flutter.yml +++ b/.github/workflows/supabase_flutter.yml @@ -4,28 +4,7 @@ on: push: branches: - main - paths: - - 'packages/supabase_flutter/**' - - '.github/workflows/supabase_flutter.yml' - - 'packages/functions_client/**' - - 'packages/gotrue/**' - - 'packages/postgrest/**' - - 'packages/realtime_client/**' - - 'packages/storage_client/**' - - 'packages/supabase/**' - - 'packages/yet_another_json_isolate/**' - pull_request: - paths: - - 'packages/supabase_flutter/**' - - '.github/workflows/supabase_flutter.yml' - - 'packages/functions_client/**' - - 'packages/gotrue/**' - - 'packages/postgrest/**' - - 'packages/realtime_client/**' - - 'packages/storage_client/**' - - 'packages/supabase/**' - - 'packages/yet_another_json_isolate/**' jobs: test: @@ -68,7 +47,7 @@ jobs: run: flutter analyze --fatal-warnings --fatal-infos . - name: Run tests - run: flutter test --concurrency=1 + run: flutter test --concurrency=1 --coverage - name: Run tests with downgraded app_links run: | @@ -79,3 +58,10 @@ jobs: run: | cd example flutter build web + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-supabase-flutter + path: ./packages/supabase_flutter/coverage/lcov.info diff --git a/.github/workflows/yet_another_json_isolate.yml b/.github/workflows/yet_another_json_isolate.yml index 83408586..fea23635 100644 --- a/.github/workflows/yet_another_json_isolate.yml +++ b/.github/workflows/yet_another_json_isolate.yml @@ -4,14 +4,7 @@ on: push: branches: - main - paths: - - 'packages/yet_another_json_isolate/**' - - '.github/workflows/yet_another_json_isolate.yml' - pull_request: - paths: - - 'packages/yet_another_json_isolate/**' - - '.github/workflows/yet_another_json_isolate.yml' jobs: test: @@ -48,7 +41,24 @@ jobs: run: dart format lib test -l 80 --set-exit-if-changed - name: analyzer + if: ${{ matrix.sdk == 'stable'}} run: dart analyze --fatal-warnings --fatal-infos . + - name: analyzer + if: ${{ matrix.sdk == 'beta' || matrix.sdk == 'dev' }} + run: dart analyze + - name: Run tests - run: dart test + run: dart test --coverage=./coverage + + - name: Format coverage + run: | + dart pub global activate coverage + dart pub global run coverage:format_coverage --lcov --in="./coverage/test" --out="./coverage/lcov.info" --report-on="./lib" + + - name: Upload coverage artifact + if: ${{ matrix.sdk == 'stable'}} + uses: actions/upload-artifact@v4 + with: + name: coverage-flutter-yet-another-json-isolate + path: ./packages/yet_another_json_isolate/coverage/lcov.info diff --git a/melos.yaml b/melos.yaml index 798b8843..2feb7757 100644 --- a/melos.yaml +++ b/melos.yaml @@ -39,6 +39,7 @@ scripts: exec: dart pub outdated update-version: + description: Updates the version.dart file for each packages except yet_another_json_isolate run: | # Loop through the packages directory for d in packages/*/ ; do @@ -53,4 +54,4 @@ scripts: rm packages/yet_another_json_isolate/lib/src/version.dart # Stage the version.dart file change git add packages/*/lib/src/version.dart - description: Updates the version.dart file for each packages except yet_another_json_isolate + \ No newline at end of file diff --git a/packages/realtime_client/lib/src/realtime_client.dart b/packages/realtime_client/lib/src/realtime_client.dart index 3ecfb612..b565def9 100644 --- a/packages/realtime_client/lib/src/realtime_client.dart +++ b/packages/realtime_client/lib/src/realtime_client.dart @@ -91,7 +91,7 @@ class RealtimeClient { int longpollerTimeout = 20000; SocketStates? connState; // This is called `accessToken` in realtime-js - Future Function()? customAccessToken; + Future Function()? customAccessToken; /// Initializes the Socket /// diff --git a/packages/realtime_client/test/socket_test.dart b/packages/realtime_client/test/socket_test.dart index 55c50914..a71f4f33 100644 --- a/packages/realtime_client/test/socket_test.dart +++ b/packages/realtime_client/test/socket_test.dart @@ -393,6 +393,8 @@ void main() { mockedSink = MockWebSocketSink(); when(() => mockedSocketChannel.sink).thenReturn(mockedSink); + when(() => mockedSocketChannel.ready).thenAnswer((_) => Future.value()); + when(() => mockedSink.close()).thenAnswer((_) => Future.value()); }); test('sends data to connection when connected', () { @@ -407,7 +409,7 @@ void main() { .called(1); }); - test('buffers data when not connected', () { + test('buffers data when not connected', () async { mockedSocket.connect(); mockedSocket.connState = SocketStates.connecting; @@ -575,6 +577,8 @@ void main() { mockedSink = MockWebSocketSink(); when(() => mockedSocketChannel.sink).thenReturn(mockedSink); + when(() => mockedSink.close()).thenAnswer((_) => Future.value()); + when(() => mockedSocketChannel.ready).thenAnswer((_) => Future.value()); mockedSocket.connect(); });