From 6fdf66487a00ebbcafb42c223b1cbf69862554a2 Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Sun, 10 Sep 2023 11:26:17 +1000 Subject: [PATCH] Set up a Sonarcloud workflow (#80) --- .github/workflows/sonarcloud.yaml | 30 ++++++++++++++++++++++++++++++ CMakeLists.txt | 3 +++ sonar-project.properties | 9 +++++++++ 3 files changed, 42 insertions(+) create mode 100644 .github/workflows/sonarcloud.yaml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/sonarcloud.yaml new file mode 100644 index 000000000..ed3cc22e4 --- /dev/null +++ b/.github/workflows/sonarcloud.yaml @@ -0,0 +1,30 @@ +name: Sonar +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - 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@v1 + - name: Run build-wrapper + run: | + mkdir build + cmake -S . -B build + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cf0e30a2..e500f8ab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,9 @@ project( LANGUAGES C CXX ) +# NUClear targets c++14 +set(CMAKE_CXX_STANDARD 14) + # Determine if NUClear is built as a subproject (using add_subdirectory) or if it is the master project. set(MASTER_PROJECT OFF) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..60dc88e40 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.projectName=NUClear +sonar.projectKey=Fastcode_NUClear +sonar.organization=fastcode +sonar.projectVersion=1.0 + +sonar.sources=src +sonar.tests=tests + +sonar.sourceEncoding=UTF-8