Skip to content

Commit bf82654

Browse files
committed
feat(dart_frog_lint): add pkg:dart_frog_lint
1 parent 1338886 commit bf82654

File tree

13 files changed

+294
-0
lines changed

13 files changed

+294
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
run_tests:
49+
required: false
50+
default: "true"
51+
description: Whether to run tests for the package.
52+
53+
runs:
54+
using: "composite"
55+
steps:
56+
- name: 🎯 Setup Dart
57+
uses: dart-lang/setup-dart@v1
58+
with:
59+
sdk: ${{inputs.dart_sdk}}
60+
61+
- name: 📦 Install Dependencies
62+
working-directory: ${{ inputs.working_directory }}
63+
shell: ${{ inputs.shell }}
64+
run: dart pub get
65+
66+
- name: ✨ Format
67+
working-directory: ${{ inputs.working_directory }}
68+
shell: ${{ inputs.shell }}
69+
run: dart format --set-exit-if-changed .
70+
71+
- name: 🔍 Analyze
72+
working-directory: ${{ inputs.working_directory }}
73+
shell: ${{ inputs.shell }}
74+
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}
75+
76+
- name: 🧪 Test
77+
if: inputs.run_tests == 'true'
78+
working-directory: ${{ inputs.working_directory }}
79+
shell: ${{ inputs.shell }}
80+
run: |
81+
dart pub global activate coverage
82+
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
83+
84+
- name: 📊 Verify Coverage
85+
if: inputs.run_tests == 'true' && inputs.collect_coverage == 'true'
86+
uses: VeryGoodOpenSource/very_good_coverage@v3
87+
with:
88+
path: ${{inputs.working_directory}}/coverage/lcov.info
89+
exclude: ${{inputs.coverage_excludes}}
90+
min_coverage: ${{inputs.min_coverage}}
91+
92+
- name: 💯 Verify Pub Score
93+
if: inputs.collect_score == 'true'
94+
working-directory: ${{ inputs.working_directory }}
95+
shell: ${{ inputs.shell }}
96+
run: |
97+
dart pub global activate pana 0.22.17
98+
sudo apt-get install webp
99+
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
100+
echo "score: $PANA_SCORE"
101+
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
102+
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
103+
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: dart_frog_lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/dart_frog_lint.yaml"
7+
- "packages/dart_frog_lint/lib/**"
8+
- "packages/dart_frog_lint/pubspec.yaml"
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- ".github/workflows/dart_frog_lint.yaml"
14+
- "packages/dart_frog_lint/lib/**"
15+
- "packages/dart_frog_lint/pubspec.yaml"
16+
17+
jobs:
18+
build:
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+
run_tests: false # there aren't any tests since this is just a single yaml file.
30+
working_directory: packages/dart_frog_lint
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: publish/dart_frog_lint
2+
3+
on:
4+
push:
5+
tags:
6+
- "dart_frog_lint-v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
publish:
10+
environment: pub.dev
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # Required for authentication using OIDC
14+
15+
steps:
16+
- name: 📚 Git Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: 📦 Publish
20+
uses: ./.github/actions/pub_publish
21+
with:
22+
working_directory: packages/dart_frog_lint

packages/dart_frog_lint/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See https://www.dartlang.org/guides/libraries/private-files
2+
3+
# Files and directories created by pub
4+
.dart_tool/
5+
.packages
6+
build/
7+
pubspec.lock
8+
9+
# Test related files
10+
coverage/

packages/dart_frog_lint/CHANGELOG.md

Whitespace-only changes.

packages/dart_frog_lint/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Dart Frog Dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/dart_frog_lint/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[<img src="https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog.png" align="left" height="63.5px" />](https://dart-frog.dev/)
2+
3+
### Dart Frog Lint
4+
5+
<br clear="left"/>
6+
7+
[![discord][discord_badge]][discord_link]
8+
[![dart][dart_badge]][dart_link]
9+
10+
[![ci][ci_badge]][ci_link]
11+
[![coverage][coverage_badge]][ci_link]
12+
[![pub package][pub_badge]][pub_link]
13+
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
14+
[![License: MIT][license_badge]][license_link]
15+
16+
A collection of lint rules built specifically for the Dart Frog backend framework.
17+
18+
## Documentation 📝
19+
20+
For official documentation, please visit [dart-frog.dev][docs_link].
21+
22+
## Quick Start 🚀
23+
24+
1. Install `dart_frog_lint`
25+
26+
`dart pub add --dev dart_frog_lint`
27+
28+
1. Add an `analysis_options.yaml` to the root of your project with the recommended rules
29+
30+
```yaml
31+
include: package:dart_frog_lint/recommended.yaml
32+
```
33+
34+
[ci_badge]: https://github.com/dart-frog-dev/dart_frog/actions/workflows/dart_frog_lint.yaml/badge.svg?branch=main
35+
[ci_link]: https://github.com/dart-frog-dev/dart_frog/actions/workflows/dart_frog_lint.yaml
36+
[coverage_badge]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/packages/dart_frog_lint/coverage_badge.svg
37+
[dart_badge]: https://img.shields.io/badge/Dart-%230175C2.svg?style=for-the-badge&logo=dart&logoColor=5BB4F0&color=1E2833
38+
[dart_link]: https://dart.dev
39+
[discord_badge]: https://img.shields.io/discord/1394707782271238184?style=for-the-badge&logo=discord&color=1C2A2E&logoColor=1DF9D2
40+
[discord_link]: https://discord.gg/dart-frog
41+
[docs_link]: https://dart-frog.dev
42+
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
43+
[license_link]: https://opensource.org/licenses/MIT
44+
[logo_black]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog_logo_black.png#gh-light-mode-only
45+
[logo_white]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog_logo_white.png#gh-dark-mode-only
46+
[pub_badge]: https://img.shields.io/pub/v/dart_frog.svg
47+
[pub_link]: https://pub.dartlang.org/packages/dart_frog
48+
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
49+
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ./lib/recommended.yaml
23.4 KB
Loading
Lines changed: 20 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)