-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gopi2401
committed
Sep 25, 2024
1 parent
6089dd2
commit 3bad080
Showing
2 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,60 @@ | ||
name: Dart and Flutter Static Analysis | ||
name: Code QL | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze Dart Code | ||
runs-on: ubuntu-latest | ||
|
||
# Set up Flutter with a specific version | ||
- name: Set up Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.10.5' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
run: flutter pub get | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: beta | ||
- name: Activate melos | ||
run: | | ||
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH | ||
dart pub global activate melos | ||
- name: Bootstrap melos | ||
run: melos bs | ||
- name: Analyze package | ||
run: melos exec -- flutter analyze --no-fatal-infos | ||
|
||
# Run Dart/Flutter static analysis | ||
- name: Run Flutter Analyze | ||
run: flutter analyze | ||
format: | ||
name: Format Dart Code | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: beta | ||
- name: Activate melos | ||
run: | | ||
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH | ||
dart pub global activate melos 2.9.0 | ||
- name: Bootstrap melos | ||
run: melos bs | ||
- name: Validate formatting | ||
run: | | ||
melos exec -- dart format -o write . | ||
./.github/workflows/scripts/validate-formatting.sh | ||
# Run Dart Unit tests | ||
- name: Run Flutter tests | ||
run: flutter test | ||
test: | ||
name: Test Dart Code | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
channel: beta | ||
- name: Activate melos | ||
run: | | ||
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH | ||
dart pub global activate melos 2.9.0 | ||
- name: Bootstrap melos | ||
run: melos bs | ||
- name: Run tests | ||
run: melos exec --dir-exists=test -- flutter test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'melos run format'." | ||
exit 1 | ||
else | ||
echo "" | ||
echo "✅ All files are formatted correctly." | ||
fi |