|
| 1 | +#CI/MANUAL TRIGGER |
| 2 | +name: Build / Test |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ main, dev ] |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + pull_request: |
| 10 | + branches: [ main ] |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Build/Test |
| 15 | + OS-NetCore: |
| 16 | + name: Build/Test (.NET Core) |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + os: [ windows-2022, ubuntu-22.04, macOS-14 ] |
| 21 | + dotnet-version: [ '3.1.x', '6.0.x', '7.0.x', '8.0.x' ] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout Repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - name: Dotnet Version (${{ matrix.dotnet-version }}) |
| 30 | + uses: actions/setup-dotnet@v4 |
| 31 | + with: |
| 32 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 33 | + |
| 34 | + - name: Find And Replace Values (App Config) |
| 35 | + uses: abhinavminhas/replace-tokens@main |
| 36 | + with: |
| 37 | + files: '${{ github.workspace }}/QueryDB.Core.Tests/App.config' |
| 38 | + replacements: '__DB_PASSWORD__=${{ secrets.DB_PASSWORD }},__DB_PASSWORD__=${{ secrets.DB_PASSWORD }},__DB_PASSWORD__=${{ secrets.DB_PASSWORD }}' |
| 39 | + |
| 40 | + - name: Build |
| 41 | + run: dotnet build QueryDB.Core.Tests/QueryDB.Core.Tests.csproj --configuration Release |
| 42 | + |
| 43 | + - name: Docker Compose (Start - DB Containers) |
| 44 | + if: ${{ (matrix.os == 'ubuntu-22.04') && (matrix.dotnet-version == '3.1.x') }} |
| 45 | + uses: ./.github/workflows/docker-compose-start-dbs |
| 46 | + with: |
| 47 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 48 | + |
| 49 | + - name: Docker Inspect (Health Check - DB Containers) |
| 50 | + if: ${{ (matrix.os == 'ubuntu-22.04') && (matrix.dotnet-version == '3.1.x') }} |
| 51 | + uses: ./.github/workflows/docker-inspect-health-check |
| 52 | + with: |
| 53 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 54 | + |
| 55 | + - name: Docker Execute (Seed Data) |
| 56 | + if: ${{ (matrix.os == 'ubuntu-22.04') && (matrix.dotnet-version == '3.1.x') }} |
| 57 | + uses: ./.github/workflows/docker-execute-seed-data |
| 58 | + with: |
| 59 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 60 | + |
| 61 | + - name: Test |
| 62 | + if: ${{ (matrix.os == 'ubuntu-22.04') && (matrix.dotnet-version == '3.1.x') }} |
| 63 | + run: dotnet test --no-build --verbosity normal --configuration Release --filter TestCategory=DB-TESTS |
| 64 | + |
| 65 | + - name: Docker Compose (Tear Down - DB Containers) |
| 66 | + if: ${{ (matrix.os == 'ubuntu-22.04') && (matrix.dotnet-version == '3.1.x') && always() }} |
| 67 | + uses: ./.github/workflows/docker-compose-teardown-dbs |
| 68 | + |
| 69 | + # Code Coverage |
| 70 | + Code-Coverage: |
| 71 | + name: Code Coverage (Codecov) |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + os: [ ubuntu-22.04 ] |
| 76 | + dotnet-version: [ '3.1.x' ] |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout Repository |
| 80 | + uses: actions/checkout@v4 |
| 81 | + with: |
| 82 | + fetch-depth: 0 |
| 83 | + |
| 84 | + - name: Dotnet Version (${{ matrix.dotnet-version }}) |
| 85 | + uses: actions/setup-dotnet@v4 |
| 86 | + with: |
| 87 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 88 | + |
| 89 | + - name: Find And Replace Values (App Config) |
| 90 | + uses: abhinavminhas/replace-tokens@main |
| 91 | + with: |
| 92 | + files: '${{ github.workspace }}/QueryDB.Core.Tests/App.config' |
| 93 | + replacements: '__DB_PASSWORD__=${{ secrets.DB_PASSWORD }},__DB_PASSWORD__=${{ secrets.DB_PASSWORD }},__DB_PASSWORD__=${{ secrets.DB_PASSWORD }}' |
| 94 | + |
| 95 | + - name: Build |
| 96 | + run: dotnet build QueryDB.Core.Tests/QueryDB.Core.Tests.csproj --configuration Release |
| 97 | + |
| 98 | + - name: Docker Compose (Start - DB Containers) |
| 99 | + uses: ./.github/workflows/docker-compose-start-dbs |
| 100 | + with: |
| 101 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 102 | + |
| 103 | + - name: Docker Inspect (Health Check - DB Containers) |
| 104 | + uses: ./.github/workflows/docker-inspect-health-check |
| 105 | + with: |
| 106 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 107 | + |
| 108 | + - name: Docker Execute (Seed Data) |
| 109 | + uses: ./.github/workflows/docker-execute-seed-data |
| 110 | + with: |
| 111 | + dbPassword: ${{ secrets.DB_PASSWORD }} |
| 112 | + |
| 113 | + - name: Test |
| 114 | + run: dotnet test --no-build --verbosity normal --configuration Release --filter TestCategory=DB-TESTS /p:CollectCoverage=true /p:CoverletOutputFormat=lcov |
| 115 | + |
| 116 | + - name: Docker Compose (Tear Down - DB Containers) |
| 117 | + if: always() |
| 118 | + uses: ./.github/workflows/docker-compose-teardown-dbs |
| 119 | + |
| 120 | + - name: Upload Coverage To Codecov |
| 121 | + uses: codecov/codecov-action@v4 |
| 122 | + with: |
| 123 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 124 | + |
| 125 | + # Code Quality |
| 126 | + Code-Quality: |
| 127 | + name: Code Quality (SonarCloud) |
| 128 | + runs-on: windows-2022 |
| 129 | + steps: |
| 130 | + - name: Set Up JDK 17 |
| 131 | + uses: actions/setup-java@v4 |
| 132 | + with: |
| 133 | + java-version: 17 |
| 134 | + distribution: 'zulu' |
| 135 | + - uses: actions/checkout@v4 |
| 136 | + with: |
| 137 | + fetch-depth: 0 |
| 138 | + - name: Cache SonarCloud Packages |
| 139 | + uses: actions/cache@v4 |
| 140 | + with: |
| 141 | + path: ~\sonar\cache |
| 142 | + key: ${{ runner.os }}-sonar |
| 143 | + restore-keys: ${{ runner.os }}-sonar |
| 144 | + - name: Cache SonarCloud Scanner |
| 145 | + id: cache-sonar-scanner |
| 146 | + uses: actions/cache@v4 |
| 147 | + with: |
| 148 | + path: .\.sonar\scanner |
| 149 | + key: ${{ runner.os }}-sonar-scanner |
| 150 | + restore-keys: ${{ runner.os }}-sonar-scanner |
| 151 | + - name: Install SonarCloud Scanner |
| 152 | + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
| 153 | + shell: powershell |
| 154 | + run: | |
| 155 | + New-Item -Path .\.sonar\scanner -ItemType Directory |
| 156 | + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner |
| 157 | + - name: Build And Analyze |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 161 | + shell: powershell |
| 162 | + run: | |
| 163 | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"abhinavminhas_QueryDB" /o:"abhinavminhas" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" |
| 164 | + dotnet build |
| 165 | + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
0 commit comments