-
Notifications
You must be signed in to change notification settings - Fork 14
145 lines (124 loc) · 5.08 KB
/
Copy pathintegration-sqlserver.yml
File metadata and controls
145 lines (124 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Integration - SQL Server
# DEV-1564: per-dialect CI for SQL Server — pytest suite + verify.py
# end-to-end check. Path-gated to T-SQL dialect file, the SQL Server
# example, the shared SQL generator + dialect base, and this file.
#
# SQL Server is the only Tier-1 dialect that had no CI before this
# workflow existed.
on:
pull_request:
branches: [main]
paths:
- 'slayer/sql/dialects/tsql.py'
- 'slayer/sql/dialects/base.py'
- 'slayer/sql/generator.py'
- 'examples/sqlserver/**'
- 'tests/integration/test_integration_sqlserver.py'
- '.github/workflows/integration-sqlserver.yml'
push:
branches: [main]
paths:
- 'slayer/sql/dialects/tsql.py'
- 'slayer/sql/dialects/base.py'
- 'slayer/sql/generator.py'
- 'examples/sqlserver/**'
- 'tests/integration/test_integration_sqlserver.py'
- '.github/workflows/integration-sqlserver.yml'
workflow_dispatch:
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install ODBC Driver 18 for SQL Server
# The pytest suite uses pyodbc IN-PROCESS on the runner host (unlike
# verify-example, where pyodbc lives only inside Docker containers
# built from examples/sqlserver/Dockerfile). Microsoft's apt repo
# is the canonical install path on Ubuntu — derive the version from
# /etc/os-release so this keeps working when `ubuntu-latest` rolls
# from 24.04 → 26.04 etc.
run: |
UBUNTU_VERSION="$(. /etc/os-release && echo "$VERSION_ID")"
echo "Installing msodbcsql18 for Ubuntu ${UBUNTU_VERSION}"
curl -sSL https://packages.microsoft.com/keys/microsoft.asc \
| sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null
curl -sSL "https://packages.microsoft.com/config/ubuntu/${UBUNTU_VERSION}/prod.list" \
| sudo tee /etc/apt/sources.list.d/mssql-release.list > /dev/null
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install -E all --with dev
- name: Verify testcontainers[mssql] extra is importable
run: poetry run python -c "import testcontainers.mssql"
- name: Verify ODBC Driver 18 is visible to pyodbc
run: |
poetry run python -c "import pyodbc; \
drivers = pyodbc.drivers(); \
assert 'ODBC Driver 18 for SQL Server' in drivers, \
f'Missing ODBC Driver 18 — installed: {drivers!r}'; \
print('ODBC drivers:', drivers)"
- name: Run SQL Server integration tests
timeout-minutes: 25
run: |
poetry run pytest tests/integration/test_integration_sqlserver.py \
-v -m integration --timeout=300
verify-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install verify.py dependencies
# verify.py talks HTTP to the slayer container; the ODBC driver lives
# inside the container (built from examples/sqlserver/Dockerfile) so
# the runner host doesn't need msodbcsql18 here.
run: pip install sqlalchemy
- name: Make slayer_data writable for container user
working-directory: examples/sqlserver
run: chmod -R 777 slayer_data
- name: Build images
working-directory: examples/sqlserver
run: docker compose build
- name: Start DB + seed
working-directory: examples/sqlserver
run: docker compose up -d --wait --wait-timeout 300 seed
- name: Start slayer service
working-directory: examples/sqlserver
run: docker compose up -d slayer
- name: Wait for SLayer API to accept connections
working-directory: examples/sqlserver
run: |
for i in $(seq 1 120); do
if curl -sf http://localhost:5143/datasources >/dev/null; then
echo "SLayer API ready after ${i} attempts"
exit 0
fi
if [ "$(docker compose ps -q slayer | xargs -r docker inspect -f '{{.State.Running}}')" = "false" ]; then
echo "slayer container exited before becoming ready — logs:" >&2
docker compose logs --no-color slayer
exit 1
fi
sleep 2
done
echo "SLayer API never came up — logs:" >&2
docker compose logs --no-color slayer
exit 1
- name: Run verify.py
timeout-minutes: 5
run: python examples/sqlserver/verify.py
- name: Dump all container logs
if: always()
working-directory: examples/sqlserver
run: docker compose logs --no-color
- name: Tear down stack
if: always()
working-directory: examples/sqlserver
run: docker compose down -v