Skip to content

Commit

Permalink
Set up a Sonarcloud workflow (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston authored Sep 10, 2023
1 parent bcdd34a commit 6fdf664
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/sonarcloud.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6fdf664

Please sign in to comment.