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: generate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Dart uses: dart-lang/setup-dart@v1 - name: Install Melos run: dart pub global activate melos - name: Run pub get run: dart pub get - name: Generate code and migrations run: melos generate && melos create-migration - name: Upload generated code uses: actions/upload-artifact@v4 with: name: generated-code path: | **/lib/migrations/** **/lib/src/generated/** **/lib/src/protocol/** **/*_server/migrations/** **/test/**/serverpod_test_tools.dart dart_format: name: dart format runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Dart uses: dart-lang/setup-dart@v1 - name: Run pub get run: dart pub get # Skip code generation for formatting check - name: Verify formatting run: dart format --output=none --set-exit-if-changed . dart_analyze: needs: generate name: dart analyze runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Dart uses: dart-lang/setup-dart@v1 - name: Install Melos run: dart pub global activate melos - name: Download generated code uses: actions/download-artifact@v4 with: name: generated-code - name: Run pub get run: dart pub get - name: Run lint run: melos lint tests: needs: generate name: dart test runs-on: ubuntu-latest permissions: pull-requests: write contents: read steps: - uses: actions/checkout@v4 - name: Set up Dart uses: dart-lang/setup-dart@v1 - name: Install Melos run: dart pub global activate melos - name: Download generated code uses: actions/download-artifact@v4 with: name: generated-code - name: Run pub get run: dart pub get - 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 benchmarks: needs: generate name: run benchmarks runs-on: ubuntu-latest permissions: pull-requests: write contents: write steps: - uses: actions/checkout@v4 - name: Set up Dart uses: dart-lang/setup-dart@v1 - name: Download generated code uses: actions/download-artifact@v4 with: name: generated-code - name: Run pub get run: dart pub get - 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: # needs: generate # name: dart publish check # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 # # - name: Set up Dart # uses: dart-lang/setup-dart@v1 # # - name: Install Melos # run: dart pub global activate melos # # - name: Download generated code # uses: actions/download-artifact@v4 # with: # name: generated-code # # - name: Run pub get # run: dart pub get # # - name: Run publish dry run # run: melos publish-check