Skip to content

Workflow file for this run

name: Application ON Push & PR DO Code check
on: [push, pull_request]
jobs:
code-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "pubspec.yaml"
- name: Setup flutter
if: steps.check_files.outputs.files_exists == 'true'
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Check flutter sdk version
if: steps.check_files.outputs.files_exists == 'true'
run: flutter --version
- name: Get dependencies
if: steps.check_files.outputs.files_exists == 'true'
run: flutter pub get
- name: Setup Dart Code Metrics
if: steps.check_files.outputs.files_exists == 'true'
run: dart pub get dart_code_metrics
- name: Dart Code Metrics
if: steps.check_files.outputs.files_exists == 'false'
run: |
dirs_to_analyse=""
if [ -d lib ]; then dirs_to_analyse+=" lib"; fi
if [ -d test ]; then dirs_to_analyse+=" test"; fi
if [ -d example ]; then dirs_to_analyse+=" example"; fi
if [ dirs_to_analyse != "" ]
then
dart run dart_code_metrics:metrics \
analyze \
$dirs_to_analyse \
--fatal-warnings \
--fatal-performance \
--fatal-style
dart run dart_code_metrics:metrics \
check-unused-files \
$dirs_to_analyse \
--fatal-unused
dart run dart_code_metrics:metrics \
check-unused-code \
$dirs_to_analyse \
--fatal-unused
fi
- name: Check formatting
if: steps.check_files.outputs.files_exists == 'true'
run: dart format . --set-exit-if-changed
- name: Run tests
if: steps.check_files.outputs.files_exists == 'false'
run: |
# run tests if `test` folder exists
if [ -d test ]
then
flutter test -r expanded
else
echo "Tests not found."
fi