From fb2f16dd7bec77eed4cc9a982890409c29445ab4 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Mon, 8 Aug 2022 13:55:31 +0200 Subject: feat: Sonarcloud Signed-off-by: Luca Muscariello Change-Id: I2da6c9dfa1d05968555e8f43176de6a0ab37892e --- scripts/Dockerfile.sonarcloud | 19 +++++++++++++++++++ scripts/build-sonar.sh | 27 +++++++++++++++++++++++++++ scripts/docker-compose-sonar.yml | 13 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 scripts/Dockerfile.sonarcloud create mode 100755 scripts/build-sonar.sh create mode 100644 scripts/docker-compose-sonar.yml (limited to 'scripts') diff --git a/scripts/Dockerfile.sonarcloud b/scripts/Dockerfile.sonarcloud new file mode 100644 index 000000000..ad8b30ef7 --- /dev/null +++ b/scripts/Dockerfile.sonarcloud @@ -0,0 +1,19 @@ +FROM ubuntu:focal +ENV DEBIAN_FRONTEND=noninteractive +WORKDIR /workspace +COPY Makefile versions.cmake ./ +COPY scripts scripts/ + +RUN apt update && apt-get install -y \ + make \ + sudo \ + curl \ + git + +RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - + +RUN apt update && apt-get install -y \ + nodejs \ + unzip + +RUN make deps debug-tools \ No newline at end of file diff --git a/scripts/build-sonar.sh b/scripts/build-sonar.sh new file mode 100755 index 000000000..ac1f878b4 --- /dev/null +++ b/scripts/build-sonar.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# SONAR_HOST_URL=https://sonarcloud.io +# PROJECT_KEY=fdio_hicn +# PROJECT_ORGANIZATION=fdio + +export SONAR_TOKEN=$API_TOKEN +export SONAR_SCANNER_VERSION=4.7.0.2747 +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/ +export PATH=$SONAR_SCANNER_HOME/bin:$PATH +export SONAR_SCANNER_OPTS="-server" +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/ +export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH + +cd /workspace + +$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make build + +$SONAR_SCANNER_HOME/bin/sonar-scanner \ +-Dsonar.organization=$PROJECT_ORGANIZATION \ +-Dsonar.projectKey=$PROJECT_KEY \ +-Dsonar.sources=/workspace \ +-Dsonar.cfamily.build-wrapper-output=bw-output \ +-Dsonar.host.url=$SONAR_HOST_URL \ No newline at end of file diff --git a/scripts/docker-compose-sonar.yml b/scripts/docker-compose-sonar.yml new file mode 100644 index 000000000..310107241 --- /dev/null +++ b/scripts/docker-compose-sonar.yml @@ -0,0 +1,13 @@ +version: "3" +services: + sonar: + build: + context: ../ + dockerfile: scripts/Dockerfile.sonarcloud + container_name: sonarcloud + hostname: sonarcloud + volumes: + - ..:/workspace + command: + - | + /workspace/scripts/build-sonar.sh \ No newline at end of file -- cgit 1.2.3-korg