sonarcloud.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: SonarCloud
  2. on:
  3. workflow_dispatch:
  4. workflow_run:
  5. workflows: ["Auto CLang format"]
  6. types:
  7. - completed
  8. jobs:
  9. build:
  10. name: Build and analyze
  11. runs-on: ubuntu-latest
  12. env:
  13. SONAR_SCANNER_VERSION: 4.7.0.2747
  14. SONAR_SERVER_URL: "https://sonarcloud.io"
  15. BUILD_WRAPPER_OUT_DIR: "$HOME/.sonar/build_wrapper_output" # Directory where build-wrapper output will be placed
  16. FBT_NO_SYNC: "true"
  17. TARGETS: f7
  18. DEFAULT_TARGET: f7
  19. steps:
  20. - name: 'Decontaminate previous build leftovers'
  21. run: |
  22. if [ -d .git ]; then
  23. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  24. fi
  25. - uses: actions/checkout@v2
  26. with:
  27. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  28. submodules: 'recursive'
  29. - name: Set up JDK 11
  30. uses: actions/setup-java@v1
  31. with:
  32. java-version: 11
  33. - name: Download and set up sonar-scanner
  34. env:
  35. SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
  36. run: |
  37. mkdir -p $HOME/.sonar
  38. curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
  39. unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
  40. echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
  41. - name: Download and set up build-wrapper
  42. env:
  43. BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
  44. run: |
  45. curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
  46. unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
  47. echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
  48. - name: Run build-wrapper
  49. run: |
  50. mkdir $HOME/.sonar/build_wrapper_output
  51. build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ./sonar-build
  52. - name: Run sonar-scanner
  53. env:
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  55. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  56. run: |
  57. sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"