Skip to content

ladislas/feature/ci functional system refactor #5829

ladislas/feature/ci functional system refactor

ladislas/feature/ci functional system refactor #5829

# Leka - LekaOS
# Copyright 2021 APF France handicap
# SPDX-License-Identifier: Apache-2.0
name: Code Analysis - Sonarcloud
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run:
runs-on: ubuntu-22.04
steps:
#
# Mark: - Setup
#
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup CI
uses: ./.github/actions/setup
with:
ccache_key: ${{ runner.os }}-ccache-code_analysis-sonarcloud
ccache_restore_keys: |
${{ runner.os }}-ccache-code_analysis-sonarcloud-
${{ runner.os }}-ccache-code_analysis-
${{ runner.os }}-ccache-
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
#
# Mark: - SonarCloud
#
- name: Download SonarCloud build wrapper
run: |
wget ${{ env.SONARCLOUD_BUILD_WRAPPER_URL }}
unzip ${{ env.SONARCLOUD_BUILD_WRAPPER_FILENAME }} && rm -rf ${{ env.SONARCLOUD_BUILD_WRAPPER_FILENAME }}
mv ${{ env.SONARCLOUD_BUILD_WRAPPER_EXTRACT_DIRECTORY }} ~/build-wrapper
echo "~/build-wrapper" >> $GITHUB_PATH
- name: Download sonar-scanner
run: |
wget ${{ env.SONARCLOUD_CLI_URL }}
unzip ${{ env.SONARCLOUD_CLI_FILENAME }} && rm -rf ${{ env.SONARCLOUD_CLI_FILENAME }}
mv ${{ env.SONARCLOUD_CLI_EXTRACT_DIRECTORY }} ~/sonar-scanner
echo "~/sonar-scanner/bin" >> $GITHUB_PATH
- name: Cache sonarcloud cache
id: global_cache-sonarcloud
uses: actions/cache@v4
with:
path: ${{ env.SONARCLOUD_CACHE_DIR}}
key: ${{ runner.os }}-global_cache-sonarcloud-${{ github.event.number }}-${{ env.CACHE_NOW_TIME }}
restore-keys: |
${{ runner.os }}-global_cache-sonarcloud-${{ github.event.number }}
${{ runner.os }}-global_cache-sonarcloud-
#
# Mark: - Build
#
- name: Ccache pre build
run: |
make ccache_prebuild
- name: Config, build LekaOS & al.
run: |
make config config_tools ENABLE_LOG_DEBUG=ON
build-wrapper-linux-x86-64 --out-dir bw-output make
- name: Ccache post build
run: |
make ccache_postbuild
ccache -z
- name: Ccache pre unit tests
run: |
make ccache_prebuild
- name: Config, build & run unit tests
env:
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
make config_unit_tests
make unit_tests
make coverage_sonarqube GCOV_EXEC=/usr/bin/gcov-12
- name: Ccache post unit tests
run: |
make ccache_postbuild
ccache -z
- name: Run sonar-scanner
run: |
sonar-scanner -X -Dsonar.login=${{ secrets.SONAR_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}