|
| 1 | +name: CI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - master |
| 7 | + paths-ignore: |
| 8 | + - '**/*.md' |
| 9 | + - '.github/FUNDING.yml' |
| 10 | + - '.github/ISSUE_TEMPLATE/**' |
| 11 | + - '.github/PULL_REQUEST_TEMPLATE.md' |
| 12 | + - '.aider/**' |
| 13 | + - '.devcontainer/**' |
| 14 | + - '.vscode/**' |
| 15 | + - 'en-us/**' |
| 16 | + |
| 17 | + pull_request: |
| 18 | + branches-ignore: |
| 19 | + - master |
| 20 | + paths-ignore: |
| 21 | + - '**/*.md' |
| 22 | + - '.github/FUNDING.yml' |
| 23 | + - '.github/ISSUE_TEMPLATE/**' |
| 24 | + - '.github/PULL_REQUEST_TEMPLATE.md' |
| 25 | + - '.aider/**' |
| 26 | + - '.devcontainer/**' |
| 27 | + - '.vscode/**' |
| 28 | + - 'en-us/**' |
| 29 | + |
| 30 | + workflow_dispatch: |
| 31 | + |
| 32 | +# Limit concurrent runs to available runners |
| 33 | +concurrency: |
| 34 | + group: ci-${{ github.ref }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +jobs: |
| 38 | + test: |
| 39 | + name: Test ${{ matrix.scenario }} (${{ matrix.part }}) |
| 40 | + runs-on: [self-hosted, azure-vmss, windows, sqlserver] |
| 41 | + timeout-minutes: 60 |
| 42 | + |
| 43 | + # Skip if commit message contains [skip ci] or if it's a tag |
| 44 | + if: | |
| 45 | + !contains(github.event.head_commit.message, '[skip ci]') && |
| 46 | + !startsWith(github.ref, 'refs/tags/') |
| 47 | +
|
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + max-parallel: 3 # Maximum 3 concurrent runners |
| 51 | + |
| 52 | + matrix: |
| 53 | + include: |
| 54 | + # SQL 2008R2 tests (2 parts) |
| 55 | + - scenario: 2008R2 |
| 56 | + part: "1/2" |
| 57 | + main_instance: "localhost\\SQL2008R2SP2" |
| 58 | + setup_scripts: "\\tests\\runner\\setup-sql2008r2sp2.ps1" |
| 59 | + |
| 60 | + - scenario: 2008R2 |
| 61 | + part: "2/2" |
| 62 | + main_instance: "localhost\\SQL2008R2SP2" |
| 63 | + setup_scripts: "\\tests\\runner\\setup-sql2008r2sp2.ps1" |
| 64 | + |
| 65 | + # SQL 2016 tests (2 parts) |
| 66 | + - scenario: 2016 |
| 67 | + part: "1/2" |
| 68 | + main_instance: "localhost\\SQL2016" |
| 69 | + setup_scripts: "\\tests\\runner\\setup-sql2016.ps1" |
| 70 | + |
| 71 | + - scenario: 2016 |
| 72 | + part: "2/2" |
| 73 | + main_instance: "localhost\\SQL2016" |
| 74 | + setup_scripts: "\\tests\\runner\\setup-sql2016.ps1" |
| 75 | + |
| 76 | + # Service restart tests (2 parts) |
| 77 | + - scenario: service_restarts |
| 78 | + part: "1/2" |
| 79 | + main_instance: "localhost\\SQL2017,localhost\\SQL2016" |
| 80 | + setup_scripts: "\\tests\\runner\\setup-sql2017.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 81 | + |
| 82 | + - scenario: service_restarts |
| 83 | + part: "2/2" |
| 84 | + main_instance: "localhost\\SQL2017,localhost\\SQL2016" |
| 85 | + setup_scripts: "\\tests\\runner\\setup-sql2017.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 86 | + |
| 87 | + # SQL 2016+2017 combined tests (2 parts) |
| 88 | + - scenario: 2016_2017 |
| 89 | + part: "1/2" |
| 90 | + main_instance: "localhost\\SQL2017,localhost\\SQL2016" |
| 91 | + setup_scripts: "\\tests\\runner\\setup-sql2017.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 92 | + |
| 93 | + - scenario: 2016_2017 |
| 94 | + part: "2/2" |
| 95 | + main_instance: "localhost\\SQL2017,localhost\\SQL2016" |
| 96 | + setup_scripts: "\\tests\\runner\\setup-sql2017.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 97 | + |
| 98 | + # Default scenario (2 parts) |
| 99 | + - scenario: default |
| 100 | + part: "1/2" |
| 101 | + main_instance: "localhost\\SQL2008R2SP2,localhost\\SQL2016" |
| 102 | + setup_scripts: "\\tests\\runner\\setup-sql2008r2sp2.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 103 | + |
| 104 | + - scenario: default |
| 105 | + part: "2/2" |
| 106 | + main_instance: "localhost\\SQL2008R2SP2,localhost\\SQL2016" |
| 107 | + setup_scripts: "\\tests\\runner\\setup-sql2008r2sp2.ps1,\\tests\\runner\\setup-sql2016.ps1" |
| 108 | + |
| 109 | + env: |
| 110 | + SCENARIO: ${{ matrix.scenario }} |
| 111 | + PART: ${{ matrix.part }} |
| 112 | + MAIN_INSTANCE: ${{ matrix.main_instance }} |
| 113 | + SETUP_SCRIPTS: ${{ matrix.setup_scripts }} |
| 114 | + GITHUB_WORKSPACE: ${{ github.workspace }} |
| 115 | + GITHUB_EVENT_HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} |
| 116 | + |
| 117 | + steps: |
| 118 | + - name: Checkout code |
| 119 | + uses: actions/checkout@v4 |
| 120 | + with: |
| 121 | + fetch-depth: 20 |
| 122 | + |
| 123 | + - name: Set build version |
| 124 | + shell: pwsh |
| 125 | + run: | |
| 126 | + $version = "2.1.${{ github.run_number }}" |
| 127 | + "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 128 | +
|
| 129 | + - name: Prepare environment |
| 130 | + shell: pwsh |
| 131 | + run: | |
| 132 | + Write-Host "::group::Prepare Environment" |
| 133 | + Set-Service wuauserv -StartupType Manual |
| 134 | + .\tests\runner\prep.ps1 |
| 135 | + Write-Host "::endgroup::" |
| 136 | +
|
| 137 | + - name: Setup SQL Server instances |
| 138 | + shell: pwsh |
| 139 | + run: | |
| 140 | + Write-Host "::group::Setup SQL Server" |
| 141 | + .\tests\runner\sqlserver.ps1 |
| 142 | + Write-Host "::endgroup::" |
| 143 | +
|
| 144 | + - name: Run Pester tests |
| 145 | + shell: pwsh |
| 146 | + run: | |
| 147 | + Write-Host "::group::Run Tests" |
| 148 | + .\tests\runner\pester.ps1 |
| 149 | + Write-Host "::endgroup::" |
| 150 | +
|
| 151 | + - name: Finalize test results |
| 152 | + shell: pwsh |
| 153 | + run: | |
| 154 | + Write-Host "::group::Finalize Tests" |
| 155 | + .\tests\runner\pester.ps1 -Finalize |
| 156 | + Write-Host "::endgroup::" |
| 157 | +
|
| 158 | + - name: Post-test cleanup |
| 159 | + if: always() |
| 160 | + shell: pwsh |
| 161 | + run: | |
| 162 | + Write-Host "::group::Post-test Cleanup" |
| 163 | + .\tests\runner\post.ps1 |
| 164 | + Write-Host "::endgroup::" |
| 165 | +
|
| 166 | + - name: Upload test results |
| 167 | + if: always() |
| 168 | + uses: actions/upload-artifact@v4 |
| 169 | + with: |
| 170 | + name: test-results-${{ matrix.scenario }}-part-${{ matrix.part }} |
| 171 | + path: TestResults*.xml |
| 172 | + if-no-files-found: warn |
| 173 | + retention-days: 30 |
| 174 | + |
| 175 | + - name: Upload coverage reports |
| 176 | + if: always() |
| 177 | + uses: actions/upload-artifact@v4 |
| 178 | + with: |
| 179 | + name: coverage-${{ matrix.scenario }}-part-${{ matrix.part }} |
| 180 | + path: Pester5Coverage*.xml |
| 181 | + if-no-files-found: ignore |
| 182 | + retention-days: 30 |
0 commit comments