name: CI on: workflow_dispatch: push: branches: - main - stable-* paths-ignore: - '**/*.md' pull_request: branches: - main - stable-* paths-ignore: - '**/*.md' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: verify_generated: name: verify generated code runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Generate code run: melos generate - name: Verify generated code is committed run: git diff --exit-code verify_migrations: name: verify migrations runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Create migrations run: melos create-migration - name: Verify migrations are committed run: git diff --exit-code dart_format: name: dart format runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Verify formatting run: dart format . --output=none --set-exit-if-changed dart_analyze: name: dart analyze runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Run lint run: melos lint tests: name: dart test runs-on: ubuntu-latest permissions: pull-requests: write contents: read steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Run tests run: melos test # TODO: Find a way to make coverage work with the tests running from a # test project and not as part of the module. # # - name: Activate coverage package # run: dart install coverage # # - name: Format coverage # run: dart run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib --check-ignore --ignore-files="**/*.g.dart" # # - name: Generate coverage report # run: dart scripts/coverage_report.dart --ci > coverage-results.txt # # - name: Comment on PR # if: github.event_name == 'pull_request' # uses: thollander/actions-comment-pull-request@v3 # with: # file-path: coverage-results.txt # comment-tag: coverage-results browser_tests: name: dart test (Chrome) runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Prepare SQLite web assets run: bash scripts/setup_sqlite_web_assets.sh - name: Run browser regressions working-directory: test/serverpod_offline_sync_test_server run: dart test test/browser --platform chrome --concurrency=1 simulation: name: deterministic simulation (${{ matrix.topology }}, ${{ matrix.delivery }}) runs-on: ubuntu-latest timeout-minutes: 60 # Deliberately not on pull requests. The suite seeds from the clock, so it # searches fresh schedules on every run and can fail for a defect unrelated # to the change under review - which is what makes it worth running, and # what makes it a poor merge gate. It runs on pushes to the release # branches and on demand, where a failure is a finding rather than a # blocked review. if: github.event_name != 'pull_request' strategy: fail-fast: false matrix: # Keep the topology files below and shared ownership controls exhaustive # when adding a new test file tagged dst. topology: [convergence, cross_space] delivery: [full, delta] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Run the simulation topology and ownership controls # Four ten-minute simulation ceilings fit within each 60-minute job. working-directory: test/serverpod_offline_sync_test_server run: >- dart test -P dst test/dst/dst_${{ matrix.topology }}_test.dart test/dst/dst_ownership_collision_test.dart --concurrency=1 env: # Depth matters: 200 rounds reproduces deferred engine failures that # 20-round empty worlds missed. Alternate populated conflict graphs # and sparse exploration; publish DST_METRICS even for failing seeds. DST_SEEDS: 4 DST_ROUNDS: 200 DST_PROFILE: mixed DST_GRAPH_WIDTH: 2 DST_DELIVERY: ${{ matrix.delivery }} benchmarks: name: run benchmarks runs-on: ubuntu-latest permissions: pull-requests: write contents: write steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - name: Configure Git run: | git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" - name: Fetch Existing Benchmark Data run: git fetch origin refs/notes/benchmarks:refs/notes/benchmarks || true - name: Run benchmarks working-directory: benchmark # --verbosity=error avoids "Running build hooks..." on stdout (pollutes PR comment). run: dart run --verbosity=error run.dart --ci > ../benchmark-results.txt - name: Comment on PR if: github.event_name == 'pull_request' uses: thollander/actions-comment-pull-request@v3 with: file-path: benchmark-results.txt comment-tag: benchmark-results - name: Store Benchmark Data in Git Notes run: | if [ "${{ github.event_name }}" = "pull_request" ]; then COMMIT_SHA=${{ github.event.pull_request.head.sha }} else COMMIT_SHA=${{ github.sha }} fi git notes --ref=benchmarks add -f -F benchmark-results.txt $COMMIT_SHA - name: Push Benchmark Data if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork != true run: git push origin refs/notes/benchmarks # TODO: Re-enable the publish check when the package is ready for first # public version. # # publish_check: # name: dart publish check # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 # - uses: ./.github/actions/setup # # - name: Run publish dry run # run: melos publish-check