Skip to content

Commit

Permalink
Merge pull request #13 from fga-eps-mds/dartmol203-patch-1
Browse files Browse the repository at this point in the history
Update code-analysis.yml
  • Loading branch information
dartmol203 authored Dec 2, 2024
2 parents d006fd7 + 0877075 commit 5e61f53
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
56 changes: 20 additions & 36 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
name: Build for Sonar
name: SonarQube Cloud
on:
push:
branches:
- dev
pull_request:
branches:
- dev
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
build:
name: Build and analyze
runs-on: ubuntu-latest
container:
image: ghcr.io/cirruslabs/flutter:stable
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
#2 Setup Java
- name: Set Up Java
uses: actions/[email protected]
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
distribution: 'oracle'
java-version: '17'
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.3'
channel: 'stable'
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
#5 Run flutter tests
- name: Run Flutter Tests
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build
run: flutter build
- name: Execute tests
run: flutter test --coverage
#6 Run Sonar cloud scan
- name: SonarCloud Scan
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Download sonar-scanner
run: |
export SONAR_SCANNER_VERSION=6.2.1.4610
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
sonar-scanner \
-Dsonar.organization=fga-eps-mds-1 \
-Dsonar.projectKey=fga-eps-mds_2024.2-ARANDU-APP\
-Dsonar.sources=./lib \
-Dsonar.host.url=https://sonarcloud.io
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: $HOME/.sonar/sonar-scanner-6.2.1.4610-linux-x64/bin/sonar-scanner -Dsonar.projectKey=fga-eps-mds_2024.2-ARANDU-APP -Dsonar.organization=fga-eps-mds-1 -Dsonar.sources=./lib -Dsonar.tests=./test -Dsonar.dart.lcov.reportPaths=./coverage/lcov.info
13 changes: 13 additions & 0 deletions sonar-scanner.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SonarCloud project and organization
sonar.projectKey=fga-eps-mds_2024.2-ARANDU-APP
sonar.organization=fga-eps-mds-1

# Path to source code and test directories
sonar.sources=./lib
sonar.tests=./test

# Path to the coverage report generated by flutter test
sonar.dart.lcov.reportPaths=./coverage/lcov.info

# Exclude specific directories and files from analysis
sonar.exclusions=**/assets/**, .github/**, scripts/**, **/*.g.dart

0 comments on commit 5e61f53

Please sign in to comment.