164 lines
4.8 KiB
YAML
164 lines
4.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- stable-*
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- stable-*
|
|
|
|
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: Run pub get
|
|
run: dart pub get
|
|
- name: Generate code
|
|
run: dart run build_runner build --delete-conflicting-outputs
|
|
- name: Upload generated code
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: generated-code
|
|
path: |
|
|
**/*.g.dart
|
|
**/*.freezed.dart
|
|
lib/**/*.part.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: Run pub get
|
|
run: dart pub get
|
|
- name: Download generated code
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: generated-code
|
|
- name: Run lint
|
|
run: dart analyze .
|
|
|
|
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
|
|
with:
|
|
sdk: stable
|
|
- name: Run pub get
|
|
run: dart pub get
|
|
- name: Download generated code
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: generated-code
|
|
- name: Run tests with coverage
|
|
run: dart test --coverage=coverage --reporter=failures-only
|
|
- name: Activate coverage package
|
|
run: dart pub global activate coverage
|
|
- name: Format coverage
|
|
run: dart pub global 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
|
|
with:
|
|
sdk: stable
|
|
- name: Run pub get
|
|
run: dart pub get
|
|
- name: Download generated code
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: generated-code
|
|
- 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
|
|
run: dart benchmark/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
|
|
|
|
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
|
|
with:
|
|
sdk: stable
|
|
- name: Run pub get
|
|
run: dart pub get
|
|
- name: Download generated code
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: generated-code
|
|
- name: Run publish dry run
|
|
run: dart pub publish --dry-run
|