Skip to content

Adjust icon show for player #25

Adjust icon show for player

Adjust icon show for player #25

name: Analysis - SonarCloud
on:
pull_request_target:
types: [opened, synchronize, reopened]
push:
branches:
- main
env:
VCPKG_BUILD_TYPE: release
CMAKE_BUILD_PARALLEL_LEVEL: 2
MAKEFLAGS: '-j 2'
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }}
repository: ${{ github.event_name == 'push' && github.repository || github.event.pull_request.head.repo.full_name }}
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ccache libglew-dev libx11-dev linux-headers-$(uname -r)
- name: Switch to GCC 11
run: |
sudo apt install -y gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-11 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: Detect CPU core count
id: cpu-count
run: echo "count=$(nproc)" >> "$GITHUB_OUTPUT"
- name: Cache CCache
uses: actions/cache@v4
with:
path: $HOME/.ccache
key: ccache-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'vcpkg.json', 'src/**/*.cpp', 'src/**/*.h') }}
restore-keys: |
ccache-${{ runner.os }}-
- name: Cache SonarCloud analysis data
uses: actions/cache@v4
with:
path: $HOME/.cfamily
key: sonar-cfamily-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'vcpkg.json', 'src/**/*.cpp', 'src/**/*.h') }}
restore-keys: |
sonar-cfamily-${{ runner.os }}-
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: $HOME/.sonar/cache
key: sonar-packages-${{ runner.os }}
restore-keys: |
sonar-packages-${{ runner.os }}-
- name: Extract vcpkg commit ID
id: vcpkg-step
run: |
vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ')
echo "vcpkgGitCommitId=$vcpkgCommitId" >> "$GITHUB_OUTPUT"
- name: Cache vcpkg installed packages
uses: actions/cache@v4
with:
path: build/vcpkg_installed
key: vcpkg-installed-${{ runner.os }}-${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}
restore-keys: |
vcpkg-installed-${{ runner.os }}-
- name: Setup vcpkg with baseline
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}
vcpkgJsonIgnores: "['**/vcpkg/**', '**/browser/overlay-ports/**']"
- name: Install sonar-scanner
uses: SonarSource/sonarcloud-github-c-cpp@v1
- name: Generate compilation database
run: |
mkdir -p build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DOPTIONS_ENABLE_CCACHE=ON \
-DSPEED_UP_BUILD_UNITY=OFF \
-S . -B build
- name: Run PR sonar-scanner
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
sonar-scanner \
--define sonar.cfamily.threads=${{ steps.cpu-count.outputs.count }} \
--define sonar.cfamily.cache.enabled=true \
--define sonar.cfamily.cache.path="$HOME/.cfamily" \
--define sonar.cfamily.compile-commands=build/compile_commands.json \
--define sonar.pullrequest.key=${{ github.event.pull_request.number }} \
--define sonar.pullrequest.branch=$BRANCH \
--define sonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
- name: Run sonar-scanner
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.threads=${{ steps.cpu-count.outputs.count }} \
--define sonar.cfamily.cache.enabled=true \
--define sonar.cfamily.cache.path="$HOME/.cfamily" \
--define sonar.cfamily.compile-commands=build/compile_commands.json