-
Notifications
You must be signed in to change notification settings - Fork 564
222 lines (195 loc) · 8.63 KB
/
ubuntu_build.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Ubuntu build
on: [push, pull_request]
jobs:
run_tests:
name: Run tests on Python ${{ matrix.python-version }}
# ubuntu-20.04 supports more versions of Python than ubuntu-22.04
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
services:
mssql2017:
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- 1401:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2017
mssql2019:
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- 1402:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2019
mssql2022:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 1403:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2022
postgres:
image: postgres:11
env:
POSTGRES_DB: postgres_db
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: postgres_pwd
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Start MySQL service
run: |
sudo systemctl start mysql.service
- name: Check initial setup
run: |
echo '*** echo $PATH'
echo "$PATH"
echo "*** odbcinst -j"
odbcinst -j
echo '*** ls -l /etc/odbc*.ini'
ls -l /etc/odbc*.ini || true
echo "*** cat /etc/odbcinst.ini"
cat /etc/odbcinst.ini
echo "*** cat /etc/odbc.ini"
cat /etc/odbc.ini
- name: Install ODBC driver and tools for SQL Server
run: |
echo "*** apt-get install the driver"
sudo ACCEPT_EULA=Y apt-get install --yes msodbcsql18 mssql-tools18
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
ls -l /opt/microsoft/msodbcsql18/lib64 || true
- name: Install ODBC driver for PostgreSQL
run: |
echo "*** apt-get install the driver"
sudo apt-get install --yes odbc-postgresql
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
ls -l /usr/lib/x86_64-linux-gnu/odbc || true
echo '*** add full paths to Postgres .so files in /etc/odbcinst.ini'
sudo sed -i 's|Driver=psqlodbca.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so|g' /etc/odbcinst.ini
sudo sed -i 's|Driver=psqlodbcw.so|Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so|g' /etc/odbcinst.ini
sudo sed -i 's|Setup=libodbcpsqlS.so|Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so|g' /etc/odbcinst.ini
- name: Install ODBC driver for MySQL
run: |
cd "$RUNNER_TEMP"
echo "*** download driver zip file"
curl --silent --show-error --write-out "$CURL_OUTPUT_FORMAT" -O "https://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-ODBC/8.0/${MYSQL_DRIVER}.tar.gz"
ls -l "${MYSQL_DRIVER}.tar.gz"
tar -xz -f "${MYSQL_DRIVER}.tar.gz"
echo "*** copy driver file to /usr/lib"
sudo cp -v "${MYSQL_DRIVER}/lib/libmyodbc8a.so" /usr/lib/x86_64-linux-gnu/odbc/
sudo chmod a+r /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
echo "*** create odbcinst.ini entry"
echo '[MySQL ODBC 8.0 ANSI Driver]' > mysql_odbcinst.ini
echo 'Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so' >> mysql_odbcinst.ini
echo 'UsageCount = 1' >> mysql_odbcinst.ini
echo 'Threading = 2' >> mysql_odbcinst.ini
sudo odbcinst -i -d -f mysql_odbcinst.ini
env:
CURL_OUTPUT_FORMAT: '%{http_code} %{filename_effective} %{size_download} %{time_total}\n'
MYSQL_DRIVER: mysql-connector-odbc-8.0.22-linux-glibc2.12-x86-64bit
- name: Check ODBC setup
run: |
echo "*** odbcinst -j"
odbcinst -j
echo "*** cat /etc/odbcinst.ini"
cat /etc/odbcinst.ini
echo "*** cat /etc/odbc.ini"
cat /etc/odbc.ini
echo '*** ls -l /opt/microsoft/msodbcsql17/lib64'
ls -l /opt/microsoft/msodbcsql17/lib64 || true
echo '*** ls -l /opt/microsoft/msodbcsql18/lib64'
ls -l /opt/microsoft/msodbcsql18/lib64 || true
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
ls -l /usr/lib/x86_64-linux-gnu/odbc || true
- name: Create test databases in SQL Server
run: |
echo "*** SQL Server 2017"
docker exec -i "${{ job.services.mssql2017.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2017' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2017.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2017' -Q "CREATE DATABASE test"
echo "*** SQL Server 2019"
docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'StrongPassword2019' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'StrongPassword2019' -Q "CREATE DATABASE test"
echo "*** SQL Server 2022"
docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'StrongPassword2022' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P 'StrongPassword2022' -Q "CREATE DATABASE test"
- name: Create test database in PostgreSQL
run: |
echo "*** get version"
psql -c "SELECT version()"
echo "*** create database"
psql -c "CREATE DATABASE test WITH encoding='UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8'"
echo "*** list databases"
psql -l
env:
PGHOST: localhost
PGPORT: 5432
PGDATABASE: postgres_db
PGUSER: postgres_user
PGPASSWORD: postgres_pwd
- name: Create test database in MySQL
run: |
echo "*** get status"
mysql --user=root --password=root --execute "STATUS"
echo "*** create database"
mysql --user=root --password=root --execute "CREATE DATABASE test"
- uses: actions/checkout@v4.1.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install Python dev dependencies
# pyodbc doesn't have any Python dependencies, but we do need pytest for testing.
run: |
cd "$GITHUB_WORKSPACE"
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Build and install pyodbc
run: |
cd "$GITHUB_WORKSPACE"
echo "*** current python version"
python -VV
echo "*** pip install"
python -m pip install .
echo "*** pip freeze"
python -m pip freeze --all
echo "*** pyodbc version"
python -c "import pyodbc; print(pyodbc.version)"
echo "*** pyodbc drivers"
python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"
- name: Run PostgreSQL tests
env:
PYODBC_POSTGRESQL: "DRIVER={PostgreSQL Unicode};SERVER=localhost;PORT=5432;UID=postgres_user;PWD=postgres_pwd;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/postgresql_test.py"
- name: Run MySQL tests
env:
PYODBC_MYSQL: "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=test;CHARSET=utf8mb4"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/mysql_test.py"
- name: Run SQL Server 2017 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost,1401;UID=sa;PWD=StrongPassword2017;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/sqlserver_test.py"
- name: Run SQL Server 2019 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test;Encrypt=Optional"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/sqlserver_test.py"
- name: Run SQL Server 2022 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1403;UID=sa;PWD=StrongPassword2022;DATABASE=test;Encrypt=Optional"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/sqlserver_test.py"