diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35d2f06f8..9fc3eefc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,12 +6,28 @@ on: push: branches: [ master, ] paths: - - '**.dart' + - '**/*.dart' - 'pubspec.yaml' + - 'pubspec.lock' + - 'lib/l10n/*.arb' + - 'test/fixtures/**' + - 'test/**/goldens/**' + - 'dart_test.yaml' + - 'build.yaml' + - 'l10n.yaml' + - 'analysis_options.yaml' pull_request: paths: - '**/*.dart' - 'pubspec.yaml' + - 'pubspec.lock' + - 'lib/l10n/*.arb' + - 'test/fixtures/**' + - 'test/**/goldens/**' + - 'dart_test.yaml' + - 'build.yaml' + - 'l10n.yaml' + - 'analysis_options.yaml' - '.github/actions/flutter-common/action.yml' - '.github/workflows/ci.yml' workflow_call: @@ -28,6 +44,7 @@ jobs: test: name: Run tests (shard ${{ matrix.shard }}) runs-on: ubuntu-latest + timeout-minutes: 20 strategy: fail-fast: false matrix: @@ -45,12 +62,24 @@ jobs: - name: Install system dependencies run: sudo apt install libsqlite3-dev lcov --no-install-recommends - # Removing some folders from the coverage since these files are not really - # part of the app code and just get in the way of the report + # The random order catches tests that depend on state an earlier test left + # behind. The seed is printed in the first log line; rerun locally with + # --test-randomize-ordering-seed= to reproduce a failure. + # + # Generated code (l10n, json_serializable, freezed, drift) and the drift + # table declarations, which only the code generator reads, are removed + # from the coverage, they would only distort the number. Not every shard + # loads a file for every pattern, hence --ignore-errors unused. - name: Test app run: | - flutter test --coverage --total-shards 6 --shard-index ${{ matrix.shard }} - lcov --remove coverage/lcov.info 'lib/l10n/generated/*' 'lib/theme/*' -o coverage/lcov.info + flutter test --coverage --test-randomize-ordering-seed=random --total-shards 6 --shard-index ${{ matrix.shard }} + lcov --remove coverage/lcov.info \ + 'lib/l10n/generated/*' \ + '*.g.dart' \ + '*.freezed.dart' \ + 'lib/database/powersync/tables/*' \ + --ignore-errors unused \ + -o coverage/lcov.info - name: Upload coverage to Coveralls uses: coverallsapp/github-action@v2 @@ -59,10 +88,38 @@ jobs: flag-name: shard-${{ matrix.shard }} parallel: true + # A second time zone catches tests that only hold in the one the main job + # pins: Auckland has a southern-hemisphere DST and is a calendar day ahead + # of UTC for half the day. + test-timezone: + name: Run tests (TZ ${{ matrix.tz }}) + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + tz: [ Pacific/Auckland ] + env: + TZ: ${{ matrix.tz }} + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Common flutter setup + uses: ./.github/actions/flutter-common + + - name: Install system dependencies + run: sudo apt install libsqlite3-dev --no-install-recommends + + - name: Test app + run: flutter test --test-randomize-ordering-seed=random + finish: name: Finish coverage needs: test runs-on: ubuntu-latest + timeout-minutes: 5 if: ${{ always() }} steps: - name: Close parallel Coveralls build diff --git a/dart_test.yaml b/dart_test.yaml index cfa1c9fd2..df14cbdd8 100644 --- a/dart_test.yaml +++ b/dart_test.yaml @@ -1,2 +1,5 @@ tags: - golden: { } \ No newline at end of file + # Tests that compare against a golden image (matchesGoldenFile). The goldens + # are rendered on Linux, as in CI; font rendering differs on other platforms, + # so locally skip them there with `flutter test --exclude-tags golden`. + golden: { }