Skip to content

Commit c2b4085

Browse files
committed
ci: add custom dart_package action
1 parent 3081fdd commit c2b4085

File tree

2 files changed

+110
-4
lines changed

2 files changed

+110
-4
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Dart Package Workflow
2+
description: Build and test Dart packages.
3+
4+
inputs:
5+
codecov_token:
6+
required: true
7+
description: The Codecov token used to upload coverage
8+
collect_coverage:
9+
required: false
10+
default: "true"
11+
description: Whether to collect code coverage
12+
collect_score:
13+
required: false
14+
default: "true"
15+
description: Whether to collect the pana score
16+
concurrency:
17+
required: false
18+
default: "4"
19+
description: The value of the concurrency flag (-j) used when running tests
20+
coverage_excludes:
21+
required: false
22+
default: ""
23+
description: Globs to exclude from coverage
24+
dart_sdk:
25+
required: false
26+
default: "stable"
27+
description: "The dart sdk version to use"
28+
working_directory:
29+
required: false
30+
default: "."
31+
description: The working directory for this workflow
32+
min_coverage:
33+
required: false
34+
default: "100"
35+
description: The minimum coverage percentage value
36+
min_score:
37+
required: false
38+
default: "120"
39+
description: The minimum pana score value
40+
analyze_directories:
41+
required: false
42+
default: "lib test"
43+
description: Directories to analyze
44+
report_on:
45+
required: false
46+
default: "lib"
47+
description: Directories to report on when collecting coverage
48+
49+
runs:
50+
using: "composite"
51+
steps:
52+
- name: 🎯 Setup Dart
53+
uses: dart-lang/setup-dart@v1
54+
with:
55+
sdk: ${{inputs.dart_sdk}}
56+
57+
- name: 📦 Install Dependencies
58+
working-directory: ${{ inputs.working_directory }}
59+
shell: ${{ inputs.shell }}
60+
run: dart pub get
61+
62+
- name: ✨ Format
63+
working-directory: ${{ inputs.working_directory }}
64+
shell: ${{ inputs.shell }}
65+
run: dart format --set-exit-if-changed .
66+
67+
- name: 🔍 Analyze
68+
working-directory: ${{ inputs.working_directory }}
69+
shell: ${{ inputs.shell }}
70+
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}
71+
72+
- name: 🧪 Test
73+
if: ${{ success() && -d '${{ inputs.working_directory }}/test' }}
74+
working-directory: ${{ inputs.working_directory }}
75+
shell: ${{ inputs.shell }}
76+
run: |
77+
dart pub global activate coverage
78+
dart test -j ${{inputs.concurrency}} --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}} --check-ignore
79+
80+
- name: 📊 Verify Coverage
81+
if: inputs.collect_coverage == 'true'
82+
uses: VeryGoodOpenSource/very_good_coverage@v3
83+
with:
84+
path: ${{inputs.working_directory}}/coverage/lcov.info
85+
exclude: ${{inputs.coverage_excludes}}
86+
min_coverage: ${{inputs.min_coverage}}
87+
88+
- name: 💯 Verify Pub Score
89+
if: inputs.collect_score == 'true'
90+
working-directory: ${{ inputs.working_directory }}
91+
shell: ${{ inputs.shell }}
92+
run: |
93+
dart pub global activate pana 0.22.17
94+
sudo apt-get install webp
95+
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
96+
echo "score: $PANA_SCORE"
97+
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
98+
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
99+
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi

.github/workflows/dart_frog_lint.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ on:
1616

1717
jobs:
1818
build:
19-
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
20-
with:
21-
analyze_directories: lib
22-
working_directory: packages/dart_frog_lint
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: 📚 Git Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: 🎯 Build
26+
uses: ./.github/actions/dart_package
27+
with:
28+
analyze_directories: lib
29+
working_directory: packages/dart_frog_lint
2330

2431
pana:
2532
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1

0 commit comments

Comments
 (0)