Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Generate coverage reports and upload them. #1110

Merged
merged 25 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3bc6134
chore: Update CI to generate coverage report.
dshukertjr Jan 16, 2025
412d5fb
chore: Upload coverage results
dshukertjr Jan 17, 2025
f997258
removed unneccessary code
dshukertjr Jan 17, 2025
e3e5681
update command name
dshukertjr Jan 17, 2025
5f86150
test command
dshukertjr Jan 17, 2025
f072634
verify melos path
dshukertjr Jan 18, 2025
95d7c06
Update workflow to format and upload the report
dshukertjr Jan 19, 2025
d972f09
fix functions ci
dshukertjr Jan 19, 2025
e294550
update path of functionc ci
dshukertjr Jan 19, 2025
f0963ea
fix path for all ci
dshukertjr Jan 19, 2025
f596d43
fix: Update type for customAccessToken
dshukertjr Jan 19, 2025
50448b4
set concurrency to 1 for realtime tests
dshukertjr Jan 19, 2025
8c823e1
fix: failing realtime tests
dshukertjr Jan 19, 2025
86e378e
add stub to realtime
dshukertjr Jan 19, 2025
74f3585
more stubs
dshukertjr Jan 19, 2025
114ca0f
update analyzer check in ci
dshukertjr Jan 19, 2025
166b0f6
Run tests on every PR for every packages and upload combined coverage…
dshukertjr Jan 20, 2025
305164d
Let the coverage workflow take care of everything about test coverage
dshukertjr Jan 21, 2025
13ed886
update coverage workflow to setup test infra
dshukertjr Jan 21, 2025
165f773
add sleep after docker compose up
dshukertjr Jan 24, 2025
51ecc69
move the sleep
dshukertjr Jan 27, 2025
45a8eeb
take down docker after testing
dshukertjr Jan 29, 2025
89c9ab5
go back to the infra directory for taking down docker
dshukertjr Jan 29, 2025
00b6fce
revert changes on the individual CI files
dshukertjr Jan 29, 2025
3d044ee
Properly upload code coverage to coverall
dshukertjr Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Combined Coverage Report

on:
push:
branches:
- main
pull_request:

jobs:
coverage:
name: Generate Combined Coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.x'
channel: 'stable'

- name: Install dependencies
run: |
dart pub global activate melos
dart pub global activate coverage
dart pub global activate combine_coverage
melos bootstrap

- name: Run tests with coverage for all packages
run: |
# Create directory for combined coverage
mkdir coverage

# Run tests for each package and generate coverage
cd packages
for d in */ ; do
cd "$d"
if [ -f "pubspec.yaml" ]; then
echo "Running tests for $d"
if [[ "$d" == "supabase_flutter/"* ]]; then
flutter test --coverage --concurrency=1
else
# Set up Docker containers based on package
if [[ "$d" == "postgrest/"* ]]; then
cd ../../infra/postgrest
docker compose down
docker compose up -d
cd ../../packages/postgrest
dart test --coverage=coverage --concurrency=1
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --lcov -o coverage/lcov.info -i coverage
cd ../../infra/postgrest
docker compose down
sleep 5s
cd ../../packages/postgrest
elif [[ "$d" == "gotrue/"* ]]; then
cd ../../infra/gotrue
docker compose down
docker compose up -d
cd ../../packages/gotrue
dart test --coverage=coverage --concurrency=1
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --lcov -o coverage/lcov.info -i coverage
cd ../../infra/gotrue
docker compose down
sleep 5s
cd ../../packages/gotrue
elif [[ "$d" == "storage_client/"* ]]; then
cd ../../infra/storage_client
docker compose down
docker compose up -d
cd ../../packages/storage_client
dart test --coverage=coverage --concurrency=1
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --lcov -o coverage/lcov.info -i coverage
cd ../../infra/storage_client
docker compose down
sleep 5s
cd ../../packages/storage_client
else
cd ../../packages/$d
dart test --coverage=coverage --concurrency=1
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --report-on=lib --lcov -o coverage/lcov.info -i coverage
fi
fi
fi
cd ..
done
cd ..

- name: Combine coverage reports
run: |
dart pub global run combine_coverage:combine_coverage --repo-path="./" --output-directory="coverage"

- name: Upload combined coverage report
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
5 changes: 5 additions & 0 deletions .github/workflows/functions_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ 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
5 changes: 5 additions & 0 deletions .github/workflows/gotrue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/postgrest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,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
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/realtime_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ 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
5 changes: 5 additions & 0 deletions .github/workflows/storage_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/supabase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ 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
2 changes: 1 addition & 1 deletion .github/workflows/supabase_flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ jobs:
- name: Verify if Flutter web build is successful
run: |
cd example
flutter build web
flutter build web
5 changes: 5 additions & 0 deletions .github/workflows/yet_another_json_isolate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ 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
3 changes: 2 additions & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

2 changes: 1 addition & 1 deletion packages/realtime_client/lib/src/realtime_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class RealtimeClient {
int longpollerTimeout = 20000;
SocketStates? connState;
// This is called `accessToken` in realtime-js
Future<String> Function()? customAccessToken;
Future<String?> Function()? customAccessToken;

/// Initializes the Socket
///
Expand Down
6 changes: 5 additions & 1 deletion packages/realtime_client/test/socket_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand All @@ -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;

Expand Down Expand Up @@ -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();
});
Expand Down