Skip to content

Commit

Permalink
update codeql
Browse files Browse the repository at this point in the history
  • Loading branch information
gopi2401 committed Sep 25, 2024
1 parent 6089dd2 commit 3bad080
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 23 deletions.
72 changes: 49 additions & 23 deletions .github/workflows/codeql.yml
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
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: 'melos run format'."
exit 1
else
echo ""
echo "✅ All files are formatted correctly."
fi

0 comments on commit 3bad080

Please sign in to comment.