Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
branches: ["main", "feature/*"]
workflow_dispatch:

jobs:
Expand All @@ -19,41 +19,71 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/[email protected]
- name: 🎯 Setup Dart
uses: dart-lang/[email protected]
with:
sdk: ${{ matrix.channel }}

- id: disabled_analytics_dart
name: Disabled Analytics Dart
run: dart --disable-analytics

- name: Install dependencies
- name: 📦 Install Dependencies
run: dart pub get

# Verifies if the dart code is formatted well
- name: Verify formatting
- 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
- name: 🔍 Analyze project source
run: dart analyze --fatal-infos
# optionally use --fatal-warnings to stop execution if any warnings are found

- name: Run Tests
# 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: Check Code 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: Coveralls GitHub Action
- name: ⬆️ Upload Coverage to Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage/lcov.info
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