-
Notifications
You must be signed in to change notification settings - Fork 94
323 lines (291 loc) · 12.5 KB
/
code-coverage.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
name: Code Coverage
on: [push, pull_request]
jobs:
generate-branch-names:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.matrix.outputs.branches }}
steps:
- id: matrix
run: |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
{
echo 'branches<<EOF'
echo "[{
\"extension_branch\":\"BABEL_3_X_DEV\",
\"engine_branch\":\"BABEL_3_X_DEV__PG_15_X\"
}]"
echo EOF
} >> "$GITHUB_OUTPUT"
else
{
echo 'branches<<EOF'
echo "[{
\"extension_branch\":\"BABEL_3_X_DEV\",
\"engine_branch\":\"BABEL_3_X_DEV__PG_15_X\"
},
{
\"extension_branch\":\"BABEL_2_X_DEV\",
\"engine_branch\":\"BABEL_2_X_DEV__PG_14_X\"
}]"
echo EOF
} >> "$GITHUB_OUTPUT"
fi
run-all-tests:
needs: [ generate-branch-names ]
runs-on: ubuntu-20.04
env:
INSTALL_DIR: psql
strategy:
fail-fast: false
matrix:
branch: ${{fromJson(needs.generate-branch-names.outputs.matrix)}}
steps:
- uses: actions/checkout@v2
id: checkout
# with:
# ref: ${{ matrix.branch.extension_branch }}
- name: Install Dependencies
id: install-dependencies
if: always()
uses: ./.github/composite-actions/install-dependencies
- name: Install Code Coverage Dependencies
id: install-code-coverage-dependencies
if: always()
run: |
sudo apt-get install lcov
- name: Build Modified Postgres
id: build-modified-postgres
if: always() && steps.install-dependencies.outcome == 'success'
uses: ./.github/composite-actions/build-modified-postgres
with:
engine_branch: ${{ matrix.branch.engine_branch }}
install_dir: psql
- name: Compile ANTLR
id: compile-antlr
if: always() && steps.build-modified-postgres.outcome == 'success'
uses: ./.github/composite-actions/compile-antlr
with:
install_dir: 'psql'
- name: Build Extensions
id: build-extensions
if: always() && steps.compile-antlr.outcome == 'success'
uses: ./.github/composite-actions/build-extensions
with:
install_dir: 'psql'
- name: Build tds_fdw Extension
id: build-tds_fdw-extension
if: ${{ startsWith(matrix.branch.extension_branch, 'BABEL_3_') && (steps.build-extensions.outcome == 'success') }}
uses: ./.github/composite-actions/build-tds_fdw-extension
- name: Build PostGIS Extension
id: build-postgis-extension
if: ${{ startsWith(matrix.branch.extension_branch, 'BABEL_3_') && (steps.build-tds_fdw-extension.outcome == 'success') }}
uses: ./.github/composite-actions/build-postgis-extension
- name: Install Extensions
id: install-extensions
if: always() && steps.build-extensions.outcome == 'success'
uses: ./.github/composite-actions/install-extensions
with:
install_dir: 'psql'
- name: Run JDBC Tests
id: jdbc
if: always() && steps.install-extensions.outcome == 'success'
timeout-minutes: 60
uses: ./.github/composite-actions/run-jdbc-tests
- name: Install MSSQL Tools
id: install-mssql-tools
if: always() && steps.install-extensions.outcome == 'success'
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
- name: Install Dotnet
id: install-dotnet
if: always() && steps.install-extensions.outcome == 'success'
run: |
cd ~
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get install -y apt-transport-https
sudo apt-get install -y dotnet-sdk-5.0
sudo apt-get install -y apt-transport-https
sudo apt-get install -y aspnetcore-runtime-5.0
- name: Run Dotnet Tests
if: always() && steps.install-dotnet.outcome == 'success'
run: |
cd test/dotnet
dotnet build
babel_URL=localhost \
babel_port=1433 \
babel_databaseName=master \
babel_user=jdbc_user \
babel_password=12345678 \
testName="all---TestUDD.txt;TestChar.txt;TestSqlVariant.txt;TestVarChar.txt;TestAuthentication.txt;TestText.txt" \
dotnet test
- name: Install SQL Server ODBC Driver
id: install-sql-server-odbc-driver
if: always() && steps.install-extensions.outcome == 'success'
run: |
cd ~
sudo apt-get install msodbcsql17
- name: Install unixODBC Driver
id: install-unix-odbc-driver
if: always() && steps.install-extensions.outcome == 'success'
run: |
cd ~
wget http://www.unixodbc.org/unixODBC-2.3.11.tar.gz
gunzip unixODBC*.tar.gz
tar xvf unixODBC*.tar
cd unixODBC-2.3.11
./configure
make
sudo make install
- name: Install psqlODBC Driver
id: install-psql-odbc-driver
if: always() && steps.install-extensions.outcome == 'success' && steps.install-unix-odbc-driver.outcome=='success'
run: |
cd ~
wget https://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-16.00.0000.tar.gz
tar -zxvf psqlodbc-16.00.0000.tar.gz
cd psqlodbc-16.00.0000
./configure
sudo make
sudo make install
echo '[ODBC_Driver_16_for_PostgreSQL]' | sudo tee -a /etc/odbcinst.ini > /dev/null
echo 'Description=ODBC Driver 16 for PostgreSQL Server' | sudo tee -a /etc/odbcinst.ini > /dev/null
echo 'Driver=/usr/local/lib/psqlodbcw.so' | sudo tee -a /etc/odbcinst.ini > /dev/null
echo 'UsageCount=1' | sudo tee -a /etc/odbcinst.ini > /dev/null
- name: Run ODBC Tests
if: always() && steps.install-sql-server-odbc-driver.outcome == 'success' && steps.install-psql-odbc-driver.outcome == 'success'
run: |
cd test/odbc
cmake -S . -B build
cmake --build build
MSSQL_ODBC_DRIVER_NAME="ODBC Driver 17 for SQL Server" \
MSSQL_BABEL_DB_SERVER=localhost \
MSSQL_BABEL_DB_PORT=1433 \
MSSQL_BABEL_DB_USER=jdbc_user \
MSSQL_BABEL_DB_PASSWORD=12345678 \
MSSQL_BABEL_DB_NAME=master \
PSQL_ODBC_DRIVER_NAME=ODBC_Driver_16_for_PostgreSQL \
PSQL_BABEL_DB_SERVER=localhost \
PSQL_BABEL_DB_PORT=5432 \
PSQL_BABEL_DB_USER=jdbc_user \
PSQL_BABEL_DB_PASSWORD=12345678 \
PSQL_BABEL_DB_NAME=jdbc_testdb \
./build/main
- name: Install Python
id: install-python
if: always() && steps.install-extensions.outcome == 'success'
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Configure Python Environment
id: configure-python-environment
if: always() && steps.install-python.outcome == 'success'
run: |
cd ~
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
cd ~/work/babelfish_extensions/babelfish_extensions/test/python
mkdir sqltoolsservice
cd sqltoolsservice
wget https://github.com/microsoft/sqltoolsservice/releases/download/4.4.0.12/Microsoft.SqlTools.ServiceLayer-rhel-x64-net6.0.tar.gz && tar -xzvf Microsoft.SqlTools.ServiceLayer-rhel-x64-net6.0.tar.gz
cd ../
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 python3-dev
pip3 install pyodbc==4.0.35 pymssql pytest pytest-xdist
- name: Drop and re-create Babelfish database
id: re-install-extensions
if: always() && steps.configure-python-environment.outcome == 'success'
run: |
sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql
sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode="single_db" -f .github/scripts/create_extension.sql
sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO"
- name: Run Python Tests
if: always() && steps.re-install-extensions.outcome == 'success'
run: |
cd test/python
compareWithFile=true \
driver=pyodbc \
runInParallel=false \
testName=all \
provider="ODBC Driver 17 for SQL Server" \
fileGenerator_URL=localhost \
fileGenerator_port=1433 \
fileGenerator_databaseName=master \
fileGenerator_user=jdbc_user \
fileGenerator_password=12345678 \
pytest -s --tb=long -q .
- name: Generate code coverage HTML report
id: code-coverage
if: always()
run: |
export PG_CONFIG=~/psql/bin/pg_config
export PG_SRC=~/work/postgresql_modified_for_babelfish
export cmake=$(which cmake)
cd contrib
for ext in babelfishpg_common babelfishpg_money babelfishpg_tds babelfishpg_tsql
do
cd $ext
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -i -d . -d ./ -o lcov_base.info
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -d . -d ./ -o lcov_test.info
rm -rf coverage
/usr/bin/genhtml -q --legend -o coverage --title='$ext' --ignore-errors source --num-spaces=4 lcov_base.info lcov_test.info
touch coverage-html-stamp
cd ..
done
shell: bash
- name: Summarize code coverage
id: code-coverage-summary
if: always()
run: |
cd contrib/
lcov -a babelfishpg_tsql/lcov_test.info -a babelfishpg_tds/lcov_test.info -a babelfishpg_common/lcov_test.info -a babelfishpg_money/lcov_test.info -o lcov.info
lcov --list lcov.info
- name: Upload Coverage Report for babelfishpg_tsql extension
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage_tsql_${{ matrix.branch.extension_branch }}
path: contrib/babelfishpg_tsql/coverage/
- name: Upload Coverage Report for babelfishpg_tds extension
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage_tds_${{ matrix.branch.extension_branch }}
path: contrib/babelfishpg_tds/coverage/
- name: Upload Coverage Report for babelfishpg_common extension
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage_common_${{ matrix.branch.extension_branch }}
path: contrib/babelfishpg_common/coverage/
- name: Upload Coverage Report for babelfishpg_money extension
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage_money_${{ matrix.branch.extension_branch }}
path: contrib/babelfishpg_money/coverage/
- name: Download CSV report from previous run
if: (github.event_name == 'schedule')
uses: dawidd6/action-download-artifact@v2
with:
name: csv_${{ matrix.branch.extension_branch }}
path: contrib/
search_artifacts: true
if_no_artifact_found: warn
- name: Add latest coverage numbers to CSV file
if: (github.event_name == 'schedule')
run: |
cd contrib/
paste -s -d, <(date +"%m/%d/%Y %H:%M:%S";lcov --summary lcov.info | grep -Po "[0-9]+\.[0-9]*") >> ${{ matrix.branch.extension_branch }}.csv
shell: bash
- name: Upload CSV report with latest coverage numbers
if: (github.event_name == 'schedule')
uses: actions/upload-artifact@v3
with:
name: csv_${{ matrix.branch.extension_branch }}
path: contrib/${{ matrix.branch.extension_branch }}.csv