diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/sonarcloud.yaml new file mode 100644 index 000000000..475bbf978 --- /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.SONARCLOUD_TOKEN }} # Put the name of your token here + 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..75758c71e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectName=NUClear +sonar.projectKey=NUClear +sonar.organization=Fastcode +sonar.projectVersion=1.0 +sonar.sources=src +sonar.sourceEncoding=UTF-8