diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 370927a..9698d40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,51 @@ jobs: - uses: actions/checkout@v2 - name: Check all entangled files are in sync with Markdown run: make check + sonarcloud: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + architecture: "x64" + - name: Install Python dependencies + run: make py-deps + - name: Install emscripten + uses: mymindstorm/setup-emsdk@v5 + with: + version: 1.39.17 + actions-cache-folder: 'emsdk-cache' + - name: Cache SonarCloud Build Wrapper + id: cache-bw + uses: actions/cache@v2 + with: + path: build-wrapper-linux-x86 + key: ${{ runner.os }}-bw + - name: Install SonarCloud Build Wrapper + if: steps.cache-bw.outputs.cache-hit != 'true' + run: | + wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip + unzip build-wrapper-linux-x86.zip + rm -f build-wrapper-linux-x86.zip + - name: Remove all compiled files + run: make clean-compiled + - name: Compile C++ files using wrapper + run: ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all + - name: Restore wasm + # As we want to analyse files in git not files we just build + run: git restore src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm + - name: Relativize bw-output + # Build wrapper runs on CI server while sonar-scanner runs in Docker container need to adjust paths + run: perl -pi -e 's@/home/runner/work/cpp2wasm/cpp2wasm@/github/workspace@g' bw-output/build-wrapper-dump.json + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} cpp: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -44,7 +89,7 @@ jobs: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: "x64" @@ -99,7 +144,10 @@ jobs: - uses: actions/checkout@v2 - name: Install emscripten - uses: mymindstorm/setup-emsdk@v4 + uses: mymindstorm/setup-emsdk@v5 + with: + version: 1.39.17 + actions-cache-folder: 'emsdk-cache' - name: Build WebAssembly module run: make build-wasm diff --git a/.gitignore b/.gitignore index ebebfeb..88dc57b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,9 @@ apache2/cgi-bin/newtonraphson # other ignores node_modules + +# SonarCloud +.scannerwork +build-wrapper-linux-x86.zip +build-wrapper-linux-x86/ +bw-output/ diff --git a/.sonarcloud.properties b/.sonarcloud.properties deleted file mode 100644 index 6c281b2..0000000 --- a/.sonarcloud.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Path to sources -#sonar.sources=. -sonar.exclusions=src/js/newtonraphsonwasm.js # This is generated by the Makefile and should not be checked by Sonarcloud. -#sonar.inclusions= - -# Path to tests -#sonar.tests= -#sonar.test.exclusions= -#sonar.test.inclusions= - -# Source encoding -#sonar.sourceEncoding=UTF-8 - -# Exclusions for copy-paste detection -sonar.cpd.exclusions=src/js/newtonraphsonwasm.js # This is generated by the Makefile and should not be checked by Sonarcloud. diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b739a..6dacae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +* C++ in SonarCloud analysis ([#73](https://github.com/NLESC-JCER/cpp2wasm/issues/73)) + ## [0.2.0] - 2020-06-09 ### Added diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..7ba6a6e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.organization=nlesc-jcer +sonar.projectKey=NLESC-JCER_cpp2wasm + +# excluded files generated by emscripten and 3rd party dependencies +sonar.exclusions=src/js/newtonraphsonwasm.js,deps/nlohmann/json.hpp +sonar.cpd.exclusions=src/js/newtonraphsonwasm.js,deps/nlohmann/json.hpp + +# Ignore C++ until sonar.cfamily.build-wrapper-output is configured +sonar.cfamily.build-wrapper-output=bw-output +sonar.cfamily.threads=1 +sonar.cfamily.cache.enabled=false + +# No coverage possible, so ignore all files +sonar.coverage.exclusions=**/*