From 98e2f10408e441c507e1cedb02a35a559a741e69 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Fri, 3 May 2024 00:21:45 -0500 Subject: [PATCH] chore(workflows): Update workflow for Dart setup and analysis Add new branches trigger, update setup step with emojis, add code analysis steps, run tests, check coverage, and verify Pub Score. --- .github/workflows/build.yml | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9df3290..2ac263a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: ["main"] pull_request: - branches: ["main"] + branches: ["main", "feature/*"] workflow_dispatch: jobs: @@ -19,7 +19,8 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@v1.6.4 + - name: ๐ŸŽฏ Setup Dart + uses: dart-lang/setup-dart@v1.6.4 with: sdk: ${{ matrix.channel }} @@ -27,33 +28,62 @@ jobs: 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/github-action@v2.2.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: coverage/lcov.info \ No newline at end of file + 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 \ No newline at end of file