Skip to content

Commit 9eaf6ff

Browse files
committed
Add CI workflow to run test suite on push to test_dll_issue branch
1 parent 6332168 commit 9eaf6ff

3 files changed

Lines changed: 162 additions & 8 deletions

File tree

.github/workflows/bld_wheels_and_upload.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Build and upload to PyPI
1+
2+
me: Build and upload to PyPI
23
# Build on every workflow_dispatch, branch push, tag push, and pull request change
34
on:
45
workflow_dispatch:
56
pull_request:
67
push:
78
branches:
89
- master
9-
- test_dll_issue
1010
# Sequence of patterns matched against refs/tags
1111
tags:
1212
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
@@ -30,7 +30,7 @@ jobs:
3030
- name: Inject ibm_db_dll.pth into wheels
3131
run: python scripts/inject_pth_into_wheel.py wheelhouse
3232

33-
- uses: actions/upload-artifact@v4.4.3
33+
- uses: actions/upload-artifact@v4
3434
with:
3535
name: ibmdb-wheels64-${{ matrix.os }}
3636
path: wheelhouse/*.whl
@@ -53,7 +53,7 @@ jobs:
5353
- name: Inject ibm_db_dll.pth into wheels
5454
run: python scripts/inject_pth_into_wheel.py wheelhouse
5555

56-
- uses: actions/upload-artifact@v4.4.3
56+
- uses: actions/upload-artifact@v4
5757
with:
5858
name: ibmdb-wheels32-${{ matrix.os }}
5959
path: wheelhouse/*.whl
@@ -88,7 +88,7 @@ jobs:
8888
--wheel-dir {dest_dir}
8989
{wheel}
9090

91-
- uses: actions/upload-artifact@v4.4.3
91+
- uses: actions/upload-artifact@v4
9292
with:
9393
name: ibmdb-wheels-${{ matrix.os }}
9494
path: wheelhouse/*.whl
@@ -108,7 +108,7 @@ jobs:
108108
CIBW_SKIP: "cp38-*"
109109
MACOSX_DEPLOYMENT_TARGET: 14.0
110110

111-
- uses: actions/upload-artifact@v4.4.3
111+
- uses: actions/upload-artifact@v4
112112
with:
113113
name: ibmdb-wheelsarm64
114114
path: wheelhouse/*.whl
@@ -129,7 +129,7 @@ jobs:
129129
CIBW_SKIP: "cp38-*"
130130
MACOSX_DEPLOYMENT_TARGET: 10.15
131131

132-
- uses: actions/upload-artifact@v4.4.3
132+
- uses: actions/upload-artifact@v4
133133
with:
134134
name: ibmdb-wheelsx86-${{ matrix.os }}
135135
path: wheelhouse/*.whl
@@ -155,7 +155,7 @@ jobs:
155155
rm -rf "$DIRNAME"
156156
157157
- name: Upload sdist
158-
uses: actions/upload-artifact@v4.4.3
158+
uses: actions/upload-artifact@v4
159159
with:
160160
name: ibmdb-sdist
161161
path: dist/*.tar.gz

.github/workflows/run_tests.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Run Test Suite
2+
3+
on:
4+
push:
5+
branches:
6+
- test_dll_issue
7+
workflow_dispatch:
8+
inputs:
9+
os:
10+
description: 'Runner OS'
11+
required: true
12+
type: choice
13+
options:
14+
- ubuntu-latest
15+
- windows-latest
16+
- macos-latest
17+
- all
18+
default: 'ubuntu-latest'
19+
python-version:
20+
description: 'Python version'
21+
required: true
22+
type: choice
23+
options:
24+
- '3.9'
25+
- '3.10'
26+
- '3.11'
27+
- '3.12'
28+
- '3.13'
29+
- '3.14'
30+
- 'all'
31+
default: '3.14'
32+
test-pattern:
33+
description: 'Test glob pattern (e.g. test_001*.py). Leave empty to run all.'
34+
required: false
35+
type: string
36+
default: ''
37+
38+
jobs:
39+
run_tests:
40+
name: Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: ${{ github.event.inputs.os == 'all' && fromJSON('["ubuntu-latest","windows-latest","macos-latest"]') || fromJSON(format('["{0}"]', github.event.inputs.os || 'ubuntu-latest')) }}
46+
python-version: ${{ github.event.inputs.python-version == 'all' && fromJSON('["3.9","3.10","3.11","3.12","3.13","3.14"]') || fromJSON(format('["{0}"]', github.event.inputs.python-version || '3.14')) }}
47+
48+
steps:
49+
- uses: actions/checkout@v5
50+
51+
- name: Set up Python ${{ matrix.python-version }}
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: ${{ matrix.python-version }}
55+
56+
- name: Install ibm_db from source
57+
shell: bash
58+
run: |
59+
python -m pip install --upgrade pip
60+
python -m pip install .
61+
62+
- name: Generate config.json from secrets
63+
shell: bash
64+
run: |
65+
cat > config.json <<ENDOFCFG
66+
{
67+
"database" : "${{ secrets.DB2_DATABASE }}",
68+
"user" : "${{ secrets.DB2_USER }}",
69+
"password" : "${{ secrets.DB2_PASSWD }}",
70+
"hostname" : "${{ secrets.DB2_HOSTNAME }}",
71+
"port" : ${{ secrets.DB2_PORT }}
72+
}
73+
ENDOFCFG
74+
75+
- name: Write db2dsdriver.cfg into clidriver/cfg
76+
shell: bash
77+
run: |
78+
CFG_DIR=$(python -c "
79+
import os, sys, glob, importlib.util
80+
81+
def find_cfg():
82+
candidates = []
83+
84+
# 1. IBM_DB_HOME env var
85+
ibm_db_home = os.environ.get('IBM_DB_HOME', '').strip('\"')
86+
if ibm_db_home:
87+
candidates.append(os.path.join(ibm_db_home, 'cfg'))
88+
89+
# 2. PATH — look for clidriver or dsdriver bin dirs
90+
for p in os.environ.get('PATH', '').split(os.pathsep):
91+
parent = os.path.dirname(p)
92+
if os.path.basename(p) == 'bin':
93+
for sub in ['clidriver', 'dsdriver', '']:
94+
base = os.path.join(parent, sub) if sub else parent
95+
candidates.append(os.path.join(base, 'cfg'))
96+
97+
# 3. ibm_db site-package (user or system site-packages)
98+
spec = importlib.util.find_spec('ibm_db')
99+
if spec and spec.origin:
100+
pkg_dir = os.path.dirname(spec.origin)
101+
for sub in ['clidriver/cfg', 'dsdriver/cfg']:
102+
candidates.append(os.path.join(pkg_dir, sub))
103+
104+
# 4. Common system install paths
105+
if sys.platform == 'win32':
106+
candidates.append(r'C:\Program Files\IBM\clidriver\cfg')
107+
else:
108+
candidates.extend([
109+
'/opt/ibm/db2/clidriver/cfg',
110+
'/opt/ibm/dsdriver/cfg',
111+
os.path.expanduser('~/sqllib/cfg'),
112+
])
113+
114+
# Return the first candidate whose parent dir exists
115+
for c in candidates:
116+
if os.path.isdir(os.path.dirname(c)):
117+
return c
118+
119+
return ''
120+
121+
print(find_cfg())
122+
")
123+
124+
if [ -z "$CFG_DIR" ]; then
125+
echo "::error::Could not locate clidriver/cfg or dsdriver/cfg directory"
126+
exit 1
127+
fi
128+
129+
echo "Writing db2dsdriver.cfg to $CFG_DIR"
130+
mkdir -p "$CFG_DIR"
131+
cat > "$CFG_DIR/db2dsdriver.cfg" <<EOF
132+
<configuration>
133+
<dsncollection>
134+
<dsn alias="${{ secrets.DB2_DATABASE }}" name="${{ secrets.DB2_DATABASE }}" host="${{ secrets.DB2_HOSTNAME }}" port="${{ secrets.DB2_PORT }}">
135+
<parameter name="Protocol" value="TCPIP"/>
136+
</dsn>
137+
</dsncollection>
138+
<databases>
139+
<database name="${{ secrets.DB2_DATABASE }}" host="${{ secrets.DB2_HOSTNAME }}" port="${{ secrets.DB2_PORT }}">
140+
<parameter name="Protocol" value="TCPIP"/>
141+
</database>
142+
</databases>
143+
</configuration>
144+
EOF
145+
146+
- name: Run test suite
147+
shell: bash
148+
env:
149+
DB2_USER: ${{ secrets.DB2_USER }}
150+
DB2_PASSWD: ${{ secrets.DB2_PASSWD }}
151+
SINGLE_PYTHON_TEST: ${{ github.event.inputs.test-pattern }}
152+
run: python ibmdb_tests.py

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ dist
44
ibm_db.egg-info
55
*.pyc
66
config.py
7+
config.json
8+
clidriver/
79
libdsnao64c.*
810
*~
911
*.out

0 commit comments

Comments
 (0)