sonarcloud.yml 2.4 KB

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