Skip to content

Commit f3fa3f3

Browse files
authored
Run the complete SQL Server lab in GitHub Actions
* Add end-to-end SQL Server integration workflow * Document SQL Server integration workflow * Document verified GitHub Actions integration * Record CI design decisions and validation evidence * Harden checkout and summarize CI validation
1 parent d17a7e6 commit f3fa3f3

4 files changed

Lines changed: 580 additions & 230 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: SQL Server integration
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- .github/workflows/sql-server-integration.yml
9+
- .env.example
10+
- docker-compose.yml
11+
- scripts/**
12+
- sql/**
13+
push:
14+
branches:
15+
- main
16+
paths:
17+
- .github/workflows/sql-server-integration.yml
18+
- .env.example
19+
- docker-compose.yml
20+
- scripts/**
21+
- sql/**
22+
workflow_dispatch:
23+
24+
permissions:
25+
contents: read
26+
27+
concurrency:
28+
group: sql-server-integration-${{ github.workflow }}-${{ github.ref }}
29+
cancel-in-progress: true
30+
31+
jobs:
32+
sql-server-integration:
33+
name: Provision, verify, and repeat
34+
runs-on: ubuntu-24.04
35+
timeout-minutes: 20
36+
37+
steps:
38+
- name: Check out repository
39+
uses: actions/checkout@v6
40+
with:
41+
persist-credentials: false
42+
43+
- name: Show runner tool versions
44+
shell: pwsh
45+
run: |
46+
Write-Host "PowerShell: $($PSVersionTable.PSVersion)"
47+
Write-Host "Docker server: $(docker version --format '{{.Server.Version}}')"
48+
docker compose version
49+
50+
- name: Validate PowerShell syntax
51+
shell: pwsh
52+
run: |
53+
$parseFailed = $false
54+
55+
Get-ChildItem -LiteralPath ./scripts -Filter *.ps1 | ForEach-Object {
56+
$tokens = $null
57+
$parseErrors = $null
58+
59+
[System.Management.Automation.Language.Parser]::ParseFile(
60+
$_.FullName,
61+
[ref]$tokens,
62+
[ref]$parseErrors
63+
) | Out-Null
64+
65+
if ($parseErrors.Count -gt 0) {
66+
$parseFailed = $true
67+
Write-Error "Syntax error in $($_.Name): $($parseErrors.Message -join '; ')"
68+
}
69+
else {
70+
Write-Host "OK: $($_.Name)"
71+
}
72+
}
73+
74+
if ($parseFailed) {
75+
throw 'At least one PowerShell script contains a syntax error.'
76+
}
77+
78+
- name: Create temporary CI configuration
79+
shell: pwsh
80+
run: |
81+
$ciPassword = "Ci9!$([guid]::NewGuid().ToString('N'))"
82+
83+
@(
84+
"MSSQL_SA_PASSWORD=$ciPassword"
85+
'MSSQL_PID=Developer'
86+
'MSSQL_PORT=14333'
87+
'MSSQL_IMAGE=mcr.microsoft.com/mssql/server:2022-CU26-ubuntu-22.04'
88+
) | Set-Content -LiteralPath ./.env -Encoding utf8NoBOM
89+
90+
- name: Run complete workflow on a fresh runner
91+
shell: pwsh
92+
run: |
93+
& ./scripts/Initialize-Lab.ps1 -TimeoutSeconds 300
94+
95+
- name: Run complete workflow again for repeatability
96+
shell: pwsh
97+
run: |
98+
& ./scripts/Initialize-Lab.ps1 -TimeoutSeconds 300 -SkipImagePull
99+
100+
- name: Write validation summary
101+
shell: pwsh
102+
run: |
103+
@'
104+
## SQL Server integration result
105+
106+
- PowerShell syntax validation: passed
107+
- Fresh SQL Server provisioning: passed
108+
- Relational integrity suite: passed
109+
- Dimensional reporting reconciliation: passed
110+
- Second complete run for repeatability: passed
111+
'@ | Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY
112+
113+
- name: Show SQL Server diagnostics on failure
114+
if: failure()
115+
shell: bash
116+
run: |
117+
docker compose --env-file .env -f docker-compose.yml ps --all || true
118+
docker compose --env-file .env -f docker-compose.yml logs --tail 200 sqlserver || true
119+
120+
- name: Clean up CI containers
121+
if: always()
122+
shell: bash
123+
run: |
124+
if [[ -f .env ]]; then
125+
docker compose --env-file .env -f docker-compose.yml down --remove-orphans || true
126+
fi
127+
rm -f .env

0 commit comments

Comments
 (0)