Changed actions #428
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SonarCloud | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| SONAR_HOST_URL: "https://sonarcloud.io" | |
| BUILD_WRAPPER_OUT_DIR: bw-out | |
| COVERAGE_FILE: coverage.xml | |
| SONAR_SCANNER_VERSION: 5.0.1.3006 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install gcovr | |
| run: sudo apt-get update && sudo apt-get install -y gcovr | |
| # ----------------------------- | |
| # DOWNLOAD BUILD WRAPPER | |
| # ----------------------------- | |
| - name: Download SonarCloud Build Wrapper | |
| run: | | |
| curl -sSLo build-wrapper.zip "https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip" | |
| unzip build-wrapper.zip -d bw | |
| echo "=== Dump of extracted bw directory ===" | |
| ls -R bw | |
| # ----------------------------- | |
| # COMPILE USING BUILD WRAPPER | |
| # ----------------------------- | |
| - name: Build with Build Wrapper | |
| run: | | |
| BW="$(find bw -type f -name 'build-wrapper-linux-x86*' | head -n 1)" | |
| echo "Using build-wrapper: $BW" | |
| chmod +x "$BW" | |
| "$BW" --out-dir "$BUILD_WRAPPER_OUT_DIR" make clean all | |
| # ----------------------------- | |
| # GENERATE COVERAGE (XML v1) | |
| # ----------------------------- | |
| - name: Run gcovr | |
| run: | | |
| gcovr -r . \ | |
| --xml \ | |
| --output coverage.xml \ | |
| --html \ | |
| --html-details \ | |
| --output coverage.html | |
| # ----------------------------- | |
| # INSTALL SONAR SCANNER | |
| # ----------------------------- | |
| - name: Install SonarScanner (manual) | |
| run: | | |
| curl -sSLo scanner.zip \ | |
| "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip" | |
| unzip scanner.zip -d scanner | |
| mv scanner/sonar-scanner-${SONAR_SCANNER_VERSION}-linux sonar-scanner | |
| echo "${PWD}/sonar-scanner/bin" >> $GITHUB_PATH | |
| # ----------------------------- | |
| # RUN SONAR SCAN | |
| # ----------------------------- | |
| - name: Run SonarScanner | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| sonar-scanner \ | |
| -Dsonar.host.url="${{ env.SONAR_HOST_URL }}" \ | |
| -Dsonar.organization=alpertron \ | |
| -Dsonar.projectKey=alpertron_calculators \ | |
| -Dsonar.sources=. \ | |
| -Dsonar.exclusions="**/*.md, **/docs/**, OldApplets/**, **/build-wrapper-dump.json" \ | |
| -Dsonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \ | |
| -Dsonar.coverageReportPaths="${{ env.COVERAGE_FILE }}" \ | |
| -Dsonar.cfamily.cache.enabled=false |