refactor: Disable unsafe code context where it's not needed #40
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: CI and SonarQube Analysis | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| - feat/* | |
| paths: | |
| - "src/**" | |
| - "benchmarks/**" | |
| - "tests/**" | |
| - "**/*.csproj" | |
| - "**/*.slnx" | |
| - ".github/workflows/ci.yml" | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| paths: | |
| - "src/**" | |
| - "benchmarks/**" | |
| - "tests/**" | |
| - "**/*.csproj" | |
| - "**/*.slnx" | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-and-analyze: | |
| name: Test with coverage and analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 21 | |
| distribution: 'zulu' | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Cache SonarQube Cloud packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache SonarQube Cloud scanner | |
| id: cache-sonar-scanner | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ runner.temp }}/scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: Install SonarQube Cloud scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p ${{ runner.temp }}/scanner | |
| dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}/scanner | |
| - name: Begin analysis | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| ${{ runner.temp }}/scanner/dotnet-sonarscanner begin \ | |
| /k:"oas_RedSeaModernLanguage" \ | |
| /o:"oas" \ | |
| /d:sonar.token="$SONAR_TOKEN" \ | |
| /d:sonar.cs.vscoveragexml.reportsPaths="**/TestResults/**/*.xml" \ | |
| /d:sonar.exclusions="**/*.png,**/*.jpg,**/*.jpeg,**/*.ico,**/*.gif" | |
| - name: Build | |
| run: dotnet build --configuration Debug --no-restore | |
| - name: Test | |
| run: dotnet test --framework net10.0 --configuration Debug --no-build -- --coverage --coverage-output-format xml | |
| - name: End analysis | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: ${{ runner.temp }}/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN" |