Sonar-Cloud #527
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sonar-Cloud | |
| on: | |
| push: | |
| paths-ignore: | |
| - '.github/resources/**' | |
| - '**.md' | |
| - '**.txt' | |
| pull_request: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '.github/resources/**' | |
| - '**.md' | |
| - '**.txt' | |
| schedule: | |
| - cron: '23 17 * * 3' | |
| jobs: | |
| build: | |
| name: Sonar Cloud Build for Dist | |
| runs-on: windows-latest | |
| env: | |
| SOLUTION_FILE_PATH: "Arc.sln" | |
| SONAR_SCANNER_VERSION: 4.7.0.2747 | |
| SONAR_SERVER_URL: "https://sonarcloud.io" | |
| BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| submodules: true | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: 11 | |
| - name: Download and set up sonar-scanner | |
| env: | |
| SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-windows.zip | |
| run: | | |
| New-Item -Force -ItemType directory -Path $HOME\.sonar | |
| curl -sSLo $HOME\.sonar\sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | |
| unzip -o $HOME\.sonar\sonar-scanner.zip -d $HOME\.sonar\ | |
| echo "$HOME\.sonar\sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 | |
| - name: Download and set up build-wrapper | |
| env: | |
| BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-win-x86.zip | |
| run: | | |
| curl -sSLo $HOME\.sonar\build-wrapper.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} | |
| unzip -o $HOME\.sonar\build-wrapper.zip -d $HOME\.sonar\ | |
| echo "$HOME\.sonar\build-wrapper-win-x86" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 | |
| - name: Set up msbuild | |
| uses: microsoft/setup-msbuild@v1.3 | |
| - name: Set up NuGet CLI | |
| uses: nuget/setup-nuget@v1 | |
| - name: Generate Project Files | |
| run: "./scripts/GenerateSolution.bat" | |
| - name: Restoring Nuget Packages | |
| run: | | |
| nuget restore | |
| - name: Cache SonarCloud packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~\sonar\cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache SonarCloud scanner | |
| id: cache-sonar-scanner | |
| uses: actions/cache@v3 | |
| with: | |
| path: .\.sonar\scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: Install SonarCloud scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| shell: powershell | |
| run: | | |
| New-Item -Path .\.sonar\scanner -ItemType Directory | |
| dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
| - name: Build and analyze | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| shell: powershell | |
| run: | | |
| dotnet restore | |
| .\.sonar\scanner\dotnet-sonarscanner begin /k:"MohitSethi99_ArcGameEngine" /o:"mohitsethi99" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /n:"ArcGameEngine" /v:"1.0" /d:sonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }} /d:sonar.exclusions="Arc/vendor/**, Arc-ScriptCore/src/Math/Mathfs.cs, Arc-ScriptCore/src/Math/Extensions.cs, Arc-ScriptCore/vendor/**, Sandbox/**" | |
| build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild /m /p:Configuration=Dist ${{env.SOLUTION_FILE_PATH}} /t:rebuild /nodeReuse:false | |
| .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" |