Skip to content

Commit 1e54e0f

Browse files
authored
ci(analysis): using flutter analyze and checking correct formatting (#107)
* ci(analysis): using `flutter analyze` and failing on warnings * using `flutter analyze` for analysis and added step for check if formatted properly * [analysis] disable `secure_pubspec_urls` * formatting
1 parent 0f6ec86 commit 1e54e0f

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

.github/workflows/analysis.yml

+18-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ jobs:
55
package-analysis:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2 # required
9-
- uses: axel-op/dart-package-analyzer@v3
10-
with:
11-
# Required:
12-
githubToken: ${{ secrets.GITHUB_TOKEN }}
13-
# Optional:
14-
#relativePath: packages/mypackage/
8+
- name: Checkout code
9+
uses: actions/checkout@v2
10+
11+
- name: Setup Flutter
12+
uses: subosito/flutter-action@v1
13+
14+
- name: Install dependencies
15+
run: |
16+
flutter pub get
17+
(cd demo && flutter pub get)
18+
19+
- name: Analyze Dart
20+
run: flutter analyze . --fatal-infos
21+
22+
- name: Validate Dart formatting
23+
run: |
24+
flutter format .
25+
./.github/workflows/scripts/validate-formatting.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
if [[ $(git ls-files --modified) ]]; then
3+
echo ""
4+
echo ""
5+
echo "These files are not formatted correctly:"
6+
for f in $(git ls-files --modified); do
7+
echo ""
8+
echo ""
9+
echo "-----------------------------------------------------------------"
10+
echo "$f"
11+
echo "-----------------------------------------------------------------"
12+
echo ""
13+
git --no-pager diff --unified=0 --minimal $f
14+
echo ""
15+
echo "-----------------------------------------------------------------"
16+
echo ""
17+
echo ""
18+
done
19+
if [[ $GITHUB_WORKFLOW ]]; then
20+
git checkout . > /dev/null 2>&1
21+
fi
22+
echo ""
23+
echo "❌ Some files are incorrectly formatted, see above output."
24+
echo ""
25+
echo "To fix these locally, run: 'flutter format .'."
26+
exit 1
27+
else
28+
echo ""
29+
echo "✅ All files are formatted correctly."
30+
fi

analysis_options.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ linter:
2929
- slash_for_doc_comments
3030
# pub related: https://dart.dev/tools/linter-rules#pub-rules
3131
- depend_on_referenced_packages
32-
- secure_pubspec_urls
32+
# TODO: this is currently not available in flutter-stable, uncomment once available
33+
#- secure_pubspec_urls
3334
# import related
3435
- always_use_package_imports
3536
- implementation_imports

lib/src/app_bar.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
88
/// functionality.
99
///
1010
/// It is internally implemented using the [AppBar] class. What differs from
11-
/// the [AppBar] implementation is the behaviour of [leading],
11+
/// the [AppBar] implementation is the behaviour of [leading],
1212
/// [automaticallyImplyLeading] and [elevation].
1313
///
1414
/// Usage example:

0 commit comments

Comments
 (0)