name: CI/CD Pipeline on: push: branches: [ main, develop ] pull_request: branches: [ main, develop ] jobs: build-and-test: runs-on: ubuntu-latest services: postgres: image: postgres:16 env: POSTGRES_USER: test POSTGRES_PASSWORD: test POSTGRES_DB: swp_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore --configuration Release - name: Run unit tests run: dotnet test --no-build --configuration Release --filter "TestCategory!=Integration" --logger "trx;LogFileName=unit-test-results.trx" --settings Tests/.runsettings - name: Run integration tests run: dotnet test --no-build --configuration Release --filter "TestCategory=Integration" --logger "trx;LogFileName=integration-test-results.trx" env: TEST_DB_CONNECTION: "Host=localhost;Port=5432;Database=swp_test;Username=test;Password=test" - name: Upload test results uses: actions/upload-artifact@v4 if: always() with: name: test-results path: | **/TestResults/*.trx **/TestResults/*.coverage - name: Code Coverage Report uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: '**/TestResults/*.coverage' badge: true format: markdown hide_branch_rate: false hide_complexity: true indicators: true output: both thresholds: '60 80' code-quality: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x - name: Install dotnet tools run: | dotnet tool install --global dotnet-format dotnet tool install --global security-scan - name: Check formatting run: dotnet format --verify-no-changes - name: Security scan run: security-scan --project SWP.Core.sln - name: Run code analysis run: dotnet build /p:RunAnalyzersDuringBuild=true /p:TreatWarningsAsErrors=true