Skip to content

Commit 47e847a

Browse files
initial
1 parent 5d4e101 commit 47e847a

21 files changed

Lines changed: 1076 additions & 61 deletions

.github/workflows/ci.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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

.github/workflows/vmss-deploy.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Deploy VMSS Infrastructure
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ['**']
7+
paths:
8+
- 'gh-runners/**'
9+
- '.github/workflows/vmss-deploy.yml'
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
terraform:
17+
name: Deploy Azure VMSS
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Azure Login
25+
uses: azure/login@v1
26+
with:
27+
creds: ${{ secrets.VMSS_AZURE_CREDENTIALS }}
28+
29+
- name: Setup Terraform
30+
uses: hashicorp/setup-terraform@v3
31+
with:
32+
terraform_version: "1.5.0"
33+
34+
- name: Terraform Init
35+
working-directory: ./gh-runners
36+
run: terraform init
37+
38+
- name: Terraform Validate
39+
working-directory: ./gh-runners
40+
run: terraform validate
41+
42+
- name: Terraform Plan
43+
working-directory: ./gh-runners
44+
run: |
45+
terraform plan \
46+
-var-file="variables.tfvars" \
47+
-var="github_token=${{ secrets.VMSS_GH_PAT }}" \
48+
-out=tfplan
49+
50+
- name: Terraform Apply
51+
if: github.event_name == 'push'
52+
working-directory: ./gh-runners
53+
run: terraform apply -auto-approve tfplan
54+
55+
- name: Deployment Summary
56+
if: github.event_name == 'push'
57+
working-directory: ./gh-runners
58+
run: |
59+
echo "## VMSS Deployment Complete 🚀" >> $GITHUB_STEP_SUMMARY
60+
echo "" >> $GITHUB_STEP_SUMMARY
61+
echo "- Resource Group: dbatools-ci-runners" >> $GITHUB_STEP_SUMMARY
62+
echo "- VMSS Name: dbatools-runner-vmss" >> $GITHUB_STEP_SUMMARY
63+
echo "- Max Instances: 3" >> $GITHUB_STEP_SUMMARY
64+
echo "- Runner Group: azure-vmss-runners" >> $GITHUB_STEP_SUMMARY
65+
echo "" >> $GITHUB_STEP_SUMMARY
66+
echo "Next: Scale VMSS to 1 instance to test runner registration" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)