Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code-analysis.yml #13

Merged
merged 8 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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