sonarcloud.yml 2.4 KB

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