fix: resolve critical and major SonarQube code quality issues #1050
Workflow file for this run
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: PR Build | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| # Minimal permissions - forked PRs only get read access anyway. | |
| # Write operations (test reporting, PR comments) are handled in pr-report.yml | |
| # which runs via workflow_run and has access to the base repo token. | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-ui: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'yarn' | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: '**/node_modules' | |
| key: node_modules-${{ hashFiles('**/yarn.lock') }} | |
| - name: Install UI dependencies | |
| run: yarn --cwd ./src/Ombi/ClientApp install | |
| - name: Build UI | |
| run: yarn --cwd ./src/Ombi/ClientApp run build | |
| - name: Run UI Tests | |
| run: yarn --cwd ./src/Ombi/ClientApp run test | |
| unit-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget | |
| - name: Run unit tests | |
| run: | | |
| cd src | |
| dotnet test --configuration "Release" --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" | |
| # Upload .trx files so pr-report.yml can publish them with write permissions | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: '**/test-results.trx' | |
| retention-days: 1 | |
| # Build and test backend for multiple platforms | |
| build-backend: | |
| runs-on: ubuntu-latest | |
| needs: [unit-test] | |
| strategy: | |
| matrix: | |
| include: | |
| - os: win-x64 | |
| format: zip | |
| - os: win-x86 | |
| format: zip | |
| - os: linux-x64 | |
| format: tar.gz | |
| - os: linux-arm | |
| format: tar.gz | |
| - os: linux-arm64 | |
| format: tar.gz | |
| - os: osx-x64 | |
| format: tar.gz | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget | |
| - name: Build backend for ${{ matrix.os }} | |
| run: dotnet publish -c Release -r ${{ matrix.os }} -o "${{ matrix.os }}" --self-contained true -p:PublishSingleFile=true | |
| working-directory: src/Ombi | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-${{ matrix.os }}-${{ github.sha }} | |
| path: ./${{ matrix.os }} | |
| retention-days: 1 | |
| # PR status check - exits non-zero so the workflow_run trigger in pr-report.yml | |
| # can detect success/failure via workflow conclusion. | |
| pr-status: | |
| runs-on: ubuntu-latest | |
| needs: [build-ui, unit-test, build-backend] | |
| if: always() | |
| steps: | |
| - name: Check all jobs status | |
| run: | | |
| if [[ "${{ needs.build-ui.result }}" == "failure" || "${{ needs.unit-test.result }}" == "failure" || "${{ needs.build-backend.result }}" == "failure" ]]; then | |
| echo "❌ Some checks failed" | |
| exit 1 | |
| else | |
| echo "✅ All checks passed" | |
| fi |