Skip to content

Commit 6857232

Browse files
committed
ci(sqlserver): add Python 3.9 + SQL Server 2017 test job
1 parent 1422edb commit 6857232

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,95 @@ jobs:
106106
export PYTHONPATH=src:tests
107107
python -m pytest tests/
108108
109+
test-py39-sqlserver2017:
110+
name: Run tests with Python 3.9 and SQL Server 2017
111+
runs-on: ubuntu-latest
112+
services:
113+
sqlserver:
114+
image: mcr.microsoft.com/mssql/server:2017-latest
115+
env:
116+
ACCEPT_EULA: Y
117+
MSSQL_SA_PASSWORD: Password123!
118+
ports:
119+
- 1442:1433
120+
options: >-
121+
--name sqlserver
122+
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Password123!' -Q 'SELECT 1' || exit 1"
123+
--health-interval 10s
124+
--health-timeout 5s
125+
--health-retries 15
126+
127+
steps:
128+
- name: Check out the repository
129+
uses: actions/checkout@v6
130+
131+
- name: Set up Python 3.9
132+
uses: actions/setup-python@v6
133+
with:
134+
python-version: "3.9"
135+
136+
- name: Install ODBC Driver 17 for SQL Server
137+
run: |
138+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
139+
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
140+
sudo apt-get update
141+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev
142+
143+
- name: Install dependencies
144+
run: |
145+
pip install -r requirements.txt
146+
pip install -r requirements-dev.txt
147+
148+
- name: Install activerecord and testsuite from PyPI
149+
run: |
150+
pip install git+https://github.com/rhosocial/python-activerecord.git@release/v1.0.0.dev29#egg=rhosocial-activerecord
151+
pip install git+https://github.com/rhosocial/python-activerecord-testsuite.git@release/v1.0.0.dev16#egg=rhosocial-activerecord-testsuite
152+
153+
- name: Create test database
154+
run: |
155+
python -c "
156+
import pyodbc
157+
158+
connection_string = (
159+
'DRIVER={ODBC Driver 17 for SQL Server};'
160+
'SERVER=localhost,1442;'
161+
'DATABASE=master;'
162+
'UID=sa;'
163+
'PWD=Password123!;'
164+
'TrustServerCertificate=yes;'
165+
'Encrypt=no;'
166+
)
167+
168+
conn = pyodbc.connect(connection_string, autocommit=True)
169+
cursor = conn.cursor()
170+
cursor.execute('CREATE DATABASE test_db')
171+
print('Successfully created test_db')
172+
cursor.close()
173+
conn.close()
174+
"
175+
176+
- name: Create SQL Server scenario config
177+
run: |
178+
cat > sqlserver_scenarios.yaml << EOF
179+
scenarios:
180+
sqlserver_2017:
181+
host: localhost
182+
port: 1442
183+
database: test_db
184+
username: sa
185+
password: Password123!
186+
driver: "ODBC Driver 17 for SQL Server"
187+
encrypt: false
188+
trust_server_certificate: true
189+
autocommit: true
190+
EOF
191+
echo "SQLSERVER_SCENARIOS_CONFIG_PATH=$(pwd)/sqlserver_scenarios.yaml" >> $GITHUB_ENV
192+
193+
- name: Run tests
194+
run: |
195+
export PYTHONPATH=src:tests
196+
python -m pytest tests/
197+
109198
test-py310-sqlserver2019:
110199
name: Run tests with Python 3.10 and SQL Server 2019
111200
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)