@@ -22,12 +22,12 @@ jobs:
2222 - name : Checkout code
2323 uses : actions/checkout@v4
2424 with :
25- fetch-depth : 0 # Quan trọng để SonarCloud so sánh code
25+ fetch-depth : 0
2626
2727 - name : Setup Java
2828 uses : actions/setup-java@v4
2929 with :
30- java-version : 17 # Gradle và SonarCloud cho Android chạy trên Java 17
30+ java-version : 17
3131 distribution : ' zulu'
3232
3333 - name : Setup Flutter
@@ -36,20 +36,37 @@ jobs:
3636 channel : ' stable'
3737 flutter-version : ' any'
3838 cache : true
39+
40+ # Cache cho dữ liệu phân tích của SonarCloud (Sensor Cache)
41+ - name : Cache SonarCloud packages
42+ uses : actions/cache@v4
43+ with :
44+ path : ~/.sonar/cache
45+ key : ${{ runner.os }}-sonar
46+ restore-keys : ${{ runner.os }}-sonar
47+
48+ # Cache cho bộ cài đặt Sonar Scanner CLI để không phải tải lại mỗi lần
49+ - name : Cache Sonar Scanner CLI
50+ id : cache-sonar-scanner
51+ uses : actions/cache@v4
52+ with :
53+ path : src/sonar-scanner-5.0.1.3006-linux
54+ key : ${{ runner.os }}-sonar-scanner-5.0.1.3006
3955
4056 - name : Install dependencies
4157 run : flutter pub get
4258
4359 - name : Run Sonar Scanner Native OS
4460 env :
45- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Bắt buộc để SonarCloud tự động comment báo cáo
46- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }} # Token cấp quyền từ SonarCloud
61+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
4763 run : |
48- # 1. Tải Sonar Scanner CLI (bản gốc cho Linux) trực tiếp từ máy chủ
49- wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
50- unzip -q sonar-scanner-cli-5.0.1.3006-linux.zip
64+ # Chỉ tải và giải nén nếu chưa có trong cache
65+ if [ ! -d "sonar-scanner-5.0.1.3006-linux" ]; then
66+ wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
67+ unzip -q sonar-scanner-cli-5.0.1.3006-linux.zip
68+ fi
5169
52- # 2. Chạy lệnh quét trực tiếp trên Ubuntu
5370 ./sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
5471 -Dsonar.organization=tqha1011 \
5572 -Dsonar.projectKey=tqha1011_taskmanagementapp \
0 commit comments