sonarcloud.yml 2.4 KB

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