github: Use provided actions for SonarQube installation and scan

Also switch to the cloud cache (which doesn't seem to work either way
anyway).
This commit is contained in:
Tobias Brunner
2025-08-05 10:27:32 +02:00
parent ff06159099
commit 2560146204
3 changed files with 14 additions and 41 deletions
+11 -19
View File
@@ -33,7 +33,6 @@ jobs:
with: with:
path: | path: |
~/.cache/ccache ~/.cache/ccache
~/.sonar-cache
key: ccache-sonarcloud-${{ github.sha }} key: ccache-sonarcloud-${{ github.sha }}
restore-keys: | restore-keys: |
ccache-sonarcloud- ccache-sonarcloud-
@@ -41,24 +40,17 @@ jobs:
sudo apt-get install -qq ccache sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z ccache -z
# using SonarSource/sonarcloud-github-action is currently not recommended - uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
# for C builds, so we follow the "any CI" instructions - run: |
- name: Install sonar-scanner echo "BUILD_WRAPPER_OUT_DIR=$HOME/bw-output" >> $GITHUB_ENV
- uses: ./.github/actions/default
- uses: SonarSource/sonarqube-scan-action@v4
env: env:
SONAR_SCANNER_VERSION: 5.0.1.3006
run: |
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ github.run_id }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }} with:
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} args: >
uses: ./.github/actions/default -Dsonar.projectKey=${{ secrets.SONAR_PROJECT }}
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.cfamily.threads=2
-Dsonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json
- run: ccache -s - run: ccache -s
+1 -22
View File
@@ -273,13 +273,6 @@ printf-builtin)
fi fi
;; ;;
all|alpine|codeql|coverage|sonarcloud|no-dbg|no-testable-ke) all|alpine|codeql|coverage|sonarcloud|no-dbg|no-testable-ke)
if [ "$TEST" = "sonarcloud" ]; then
if [ -z "$SONAR_PROJECT" -o -z "$SONAR_ORGANIZATION" -o -z "$SONAR_TOKEN" ]; then
echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
"environment variables are required to run this test"
exit 1
fi
fi
if [ "$TEST" = "codeql" ]; then if [ "$TEST" = "codeql" ]; then
# don't run tests, only analyze built code # don't run tests, only analyze built code
TARGET= TARGET=
@@ -552,7 +545,7 @@ case "$TEST" in
sonarcloud) sonarcloud)
# without target, coverage is currently not supported anyway because # without target, coverage is currently not supported anyway because
# sonarqube only supports gcov, not lcov # sonarqube only supports gcov, not lcov
build-wrapper-linux-x86-64 --out-dir bw-output make -j$(nproc) || exit $? build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR make -j$(nproc) || exit $?
;; ;;
*) *)
make -j$(nproc) $TARGET || exit $? make -j$(nproc) $TARGET || exit $?
@@ -567,20 +560,6 @@ apidoc)
fi fi
rm make.warnings rm make.warnings
;; ;;
sonarcloud)
sonar-scanner \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.projectKey=${SONAR_PROJECT} \
-Dsonar.organization=${SONAR_ORGANIZATION} \
-Dsonar.token=${SONAR_TOKEN} \
-Dsonar.projectVersion=$(git describe --exclude 'android-*')+${BUILD_NUMBER} \
-Dsonar.sources=. \
-Dsonar.cfamily.threads=2 \
-Dsonar.cfamily.analysisCache.mode=fs \
-Dsonar.cfamily.analysisCache.path=$HOME/.sonar-cache \
-Dsonar.cfamily.build-wrapper-output=bw-output || exit $?
rm -r bw-output .scannerwork
;;
android) android)
rm -r strongswan-* rm -r strongswan-*
cd $SRC_DIR/src/frontends/android cd $SRC_DIR/src/frontends/android
+2
View File
@@ -1,3 +1,5 @@
sonar.sources=.
# exclude these files completely # exclude these files completely
sonar.exclusions=\ sonar.exclusions=\
src/manager/templates/static/jquery.js, \ src/manager/templates/static/jquery.js, \