Files
flutter/.github/workflows/ci.yml
2026-12-03 12:58:24 +01:00

130 lines
3.7 KiB
YAML

name: Continuous Integration
on:
# Direct pushes are only validated on master (post-merge); everything else
# is covered by the pull_request trigger, avoiding duplicate runs for
# same-repo PR branches.
push:
branches: [ master, ]
paths:
- '**/*.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:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Run tests (shard ${{ matrix.shard }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5]
env:
TZ: Europe/Berlin
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 lcov --no-install-recommends
# 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=<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 --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
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
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
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true