Skip to content

chore(workflows): Update workflow for Dart setup and analysis #35

chore(workflows): Update workflow for Dart setup and analysis

chore(workflows): Update workflow for Dart setup and analysis #35

Workflow file for this run

name: "build"
on:
push:
branches: ["main"]
pull_request:
branches: ["main", "feature/*"]
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # or: macos-latest, windows-latest
channel: [stable, beta, dev, main] # or: 'beta', 'dev' or 'main'
steps:
- uses: actions/checkout@v4
- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1.6.4
with:
sdk: ${{ matrix.channel }}
- id: disabled_analytics_dart
name: Disabled Analytics Dart
run: dart --disable-analytics
- name: 📦 Install Dependencies
run: dart pub get
# Verifies if the dart code is formatted well
- name: ✨ Verify formatting
run: dart format --output=none --set-exit-if-changed .
# --set-exit-if-changed stops execution if the any code is not well formatted
# --output=none prints files which needs to be formatted
# Checks for Semantic errors. Can be configured using analysis_options.yaml
- name: 🔍 Analyze project source
run: dart analyze --fatal-infos
# optionally use --fatal-warnings to stop execution if any warnings are found
# Checks for the quality and consistency of Dart code. Can be configured using analysis_options.yaml
- name: 🔍 Analyze project source (Dart code Linter - DCL)
run: dart run dart_code_linter:metrics analyze .
- name: 🔍 Analyze check unused files (DCL)
run: dart run dart_code_linter:metrics check-unused-files lib
- name: 🔍 Analyze check unused l10n (DCL)
run: dart run dart_code_linter:metrics check-unused-l10n .
- name: 🔍 Analyze check unused code (DCL)
run: dart run dart_code_linter:metrics check-unused-code .
- name: 🔍 Analyze check unnecessary nullable (DCL)
run: dart run dart_code_linter:metrics check-unnecessary-nullable .
- name: 🧪 Run Tests
run: |
dart pub global activate coverage
dart pub global run coverage:test_with_coverage
- name: 📦 Pre-publish - dry run
run: dart pub publish --dry-run
- name: 📊 Check Code Coverage
uses: VeryGoodOpenSource/very_good_coverage@v3
with:
path: "./coverage/lcov.info"
min_coverage: 100
- name: ⬆️ Upload Coverage to Coveralls
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage/lcov.info
- name: 💯 Verify Pub Score
run: |
dart pub global activate pana
sudo apt-get install webp
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
echo "score: $PANA_SCORE"
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi