Skip to content

Merge branch '133-support-newer-analyzer-and-source_gen-versions' int… #18

Merge branch '133-support-newer-analyzer-and-source_gen-versions' int…

Merge branch '133-support-newer-analyzer-and-source_gen-versions' int… #18

Workflow file for this run

name: Code analysis
# Avoid duplicate builds for pull requests, allow manual trigger.
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Minimal access by default
permissions:
contents: read
env:
# Do code analysis with latest SDK.
# Pick a concrete version instead of "latest" to avoid builds breaking due to changes in new SDKs.
FLUTTER_VERSION: 3.29.2 # Available versions: https://docs.flutter.dev/release/archive
DART_VERSION: 3.7.2 # Available versions: https://dart.dev/get-dart/archive
jobs:
format-and-analyze:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.0
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Get dependencies
run: |
dart pub get --directory=benchmark
dart pub get --directory=generator
dart pub get --directory=objectbox
dart pub get --directory=objectbox_test
flutter pub get --directory=flutter_libs
flutter pub get --directory=sync_flutter_libs
# Since Dart 3.7, dart format needs pub get to run before formatting,
# so to check formatting of Flutter packages run pub get for them as well.
# Also run before generating code to exclude generated code.
- name: Check formatting of all packages
run: dart format --set-exit-if-changed .
- name: Generate code (benchmark)
working-directory: benchmark
run: dart run build_runner build
- name: Generate code (objectbox_test)
working-directory: objectbox_test
run: dart run build_runner build
- name: Analyze Dart packages
run: |
dart analyze benchmark
dart analyze generator
dart analyze objectbox
dart analyze objectbox_test
pana:
runs-on: ubuntu-24.04
permissions:
checks: write # to publish the report
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: axel-op/dart-package-analyzer@7a6c3c66bce78d82b729a1ffef2d9458fde6c8d2 # v3
id: analysis # set an id for the current step
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
relativePath: objectbox
# You can then use this id to retrieve the outputs in the next steps.
# The following step shows how to exit the workflow with an error if a score is below 100:
- name: Check scores
shell: bash
run: |
if (( ${{ steps.analysis.outputs.total }} < 100 )); then
echo "Expected score 130, got ${{ steps.analysis.outputs.total }}, please check the analysis report and resolve the issues"
exit 1
fi
test-coverage:
runs-on: ubuntu-24.04
permissions:
checks: write # to publish the report
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
# Prefer running on Ubuntu over Dart Docker image
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 # v1.6.5
with:
sdk: ${{ env.DART_VERSION }}
- name: Install coverage tools
run: |
./tool/apt-install.sh lcov
dart pub global activate coverage
- name: Prepare objectbox_test
working-directory: objectbox_test
run: |
dart pub get
dart run build_runner build
- name: Prepare objectbox
working-directory: objectbox
run: |
../install.sh
dart pub get
- name: Generate test coverage
working-directory: objectbox
run: ./tool/coverage.sh
- uses: devmasx/coverage-check-action@4a754f8957c6824e0a0d44bf9168fdbdf47e7e2f # v1.2.0
with:
type: lcov
result_path: objectbox/coverage/lcov.info
min_coverage: 90
token: ${{ github.token }}
- uses: danielpalme/ReportGenerator-GitHub-Action@b7115d212c0f7814a0cb17fb43ec36983c707ccb # v5.3.10
with:
reports: 'objectbox/coverage/lcov.info'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline' # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
sourcedirs: 'objectbox'
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: CoverageReport # Artifact name
path: coveragereport # Directory containing files to upload