Skip to content

Update to Java 17 in SonarCI #437

Update to Java 17 in SonarCI

Update to Java 17 in SonarCI #437

Workflow file for this run

name: Sonar Source Analysis
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Sonar Source Analysis
runs-on: ubuntu-20.04
env:
SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in the "Linux" link on this page:
# https://sonarcloud.io/documentation/analysis/scan/sonarscanner/
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- name: Download BioDynaMo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libopenmpi-dev libomp5 libomp-dev libnuma-dev freeglut3-dev \
libreadline-dev libsqlite3-dev tk-dev python3-openssl ninja-build libblas-dev \
liblapack-dev kcov libgit2-dev
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh
chmod +x cmake-3.19.3-Linux-x86_64.sh
sudo ./cmake-3.19.3-Linux-x86_64.sh --skip-license --prefix=/usr/local
- name: Start Xvfb
run: |
set -e
sudo apt-get -y install xvfb
XVFBARGS=":99 -ac -screen 0 2560x1440x24"
/usr/bin/Xvfb $XVFBARGS >> /tmp/Xvfb.out 2>&1 &
disown -ar
sleep 3
- name: Install pyenv dependency
run: |
if [ ! -f "$HOME/.pyenv/bin/pyenv" ]; then
curl https://pyenv.run | bash
fi
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.1
pyenv shell 3.9.1
- name: Run build-wrapper
run: |
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
pyenv shell 3.9.1
mkdir build
cmake -G Ninja \
-Dparaview=ON \
-Dcoverage=ON \
-Dlibgit2=ON \
-B build
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --parallel
- name: Analyze coverage
run: |
source $(find /home -path "*/bin/*" -name "*thisbdm.sh")
cd build
ninja coverage-gha
mkdir coverage/coverage_data
cp $(find "coverage" -name "*sonarqube.xml") coverage/coverage_data/sonar_coverage.xml
echo "\n Filecontent sonar_coverage.xml:"
FILE=$(find "coverage" -name "*sonar_coverage.xml")
tail -n +2 "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
head -n 30 "$FILE"
echo "\n ... \n"
tail -n 7 "$FILE"
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
source $(find /home -path "*/bin/*" -name "*thisbdm.sh")
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"