Skip to content

Commit

Permalink
ci(analysis): using flutter analyze and checking correct formatting (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
daadu authored Dec 19, 2021
1 parent 0f6ec86 commit 1e54e0f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ jobs:
package-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # required
- uses: axel-op/dart-package-analyzer@v3
with:
# Required:
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Optional:
#relativePath: packages/mypackage/
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Flutter
uses: subosito/flutter-action@v1

- name: Install dependencies
run: |
flutter pub get
(cd demo && flutter pub get)
- name: Analyze Dart
run: flutter analyze . --fatal-infos

- name: Validate Dart formatting
run: |
flutter format .
./.github/workflows/scripts/validate-formatting.sh
30 changes: 30 additions & 0 deletions .github/workflows/scripts/validate-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
if [[ $(git ls-files --modified) ]]; then
echo ""
echo ""
echo "These files are not formatted correctly:"
for f in $(git ls-files --modified); do
echo ""
echo ""
echo "-----------------------------------------------------------------"
echo "$f"
echo "-----------------------------------------------------------------"
echo ""
git --no-pager diff --unified=0 --minimal $f
echo ""
echo "-----------------------------------------------------------------"
echo ""
echo ""
done
if [[ $GITHUB_WORKFLOW ]]; then
git checkout . > /dev/null 2>&1
fi
echo ""
echo "❌ Some files are incorrectly formatted, see above output."
echo ""
echo "To fix these locally, run: 'flutter format .'."
exit 1
else
echo ""
echo "✅ All files are formatted correctly."
fi
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ linter:
- slash_for_doc_comments
# pub related: https://dart.dev/tools/linter-rules#pub-rules
- depend_on_referenced_packages
- secure_pubspec_urls
# TODO: this is currently not available in flutter-stable, uncomment once available
#- secure_pubspec_urls
# import related
- always_use_package_imports
- implementation_imports
Expand Down
2 changes: 1 addition & 1 deletion lib/src/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
/// functionality.
///
/// It is internally implemented using the [AppBar] class. What differs from
/// the [AppBar] implementation is the behaviour of [leading],
/// the [AppBar] implementation is the behaviour of [leading],
/// [automaticallyImplyLeading] and [elevation].
///
/// Usage example:
Expand Down

0 comments on commit 1e54e0f

Please sign in to comment.