sonarcloud.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. name: SonarCloud analysis
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. types: [opened, synchronize, reopened]
  8. jobs:
  9. build:
  10. name: Build
  11. runs-on: ubuntu-22.04
  12. container: ghcr.io/nextcloud/continuous-integration-client:client-5.15-11
  13. env:
  14. SONAR_SERVER_URL: "https://sonarcloud.io"
  15. BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
  16. steps:
  17. - uses: actions/checkout@v2
  18. with:
  19. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  20. - name: Restore cache
  21. uses: actions/cache@v2
  22. with:
  23. path: /cache
  24. key: ${{ runner.os }}
  25. - name: Run build-wrapper
  26. run: |
  27. mkdir build
  28. cd build
  29. cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DBUILD_COVERAGE=ON -DOPENSSL_ROOT_DIR=/usr/local/lib64
  30. build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja
  31. - name: Run tests
  32. run: |
  33. cd build
  34. useradd -m -s /bin/bash test
  35. chown -R test:test .
  36. su -c 'xvfb-run ctest --output-on-failure --output-junit testResult.xml' test
  37. - name: Generate coverage report
  38. run: |
  39. cd build
  40. su -c 'ctest -T Coverage' test
  41. - name: Run sonar-scanner
  42. env:
  43. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  44. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  45. run: |
  46. cp sonar-project.properties build
  47. cd build
  48. sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"