Skip to content

Commit 011e2c2

Browse files
committed
Add CI workflow to run test suite on push to test_dll_issue branch
1 parent 4e280e2 commit 011e2c2

1 file changed

Lines changed: 27 additions & 46 deletions

File tree

.github/workflows/run_tests.yml

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -76,60 +76,37 @@ jobs:
7676
- name: Write db2dsdriver.cfg into clidriver/cfg
7777
shell: bash
7878
run: |
79+
# Find the cfg dir next to the installed ibm_db package
7980
CFG_DIR=$(python -c "
80-
import os, sys, glob, importlib.util
81-
82-
def find_cfg():
83-
candidates = []
84-
85-
# 1. IBM_DB_HOME env var
86-
ibm_db_home = os.environ.get('IBM_DB_HOME', '').strip('\"')
87-
if ibm_db_home:
88-
candidates.append(os.path.join(ibm_db_home, 'cfg'))
89-
90-
# 2. PATH — look for clidriver or dsdriver bin dirs
91-
for p in os.environ.get('PATH', '').split(os.pathsep):
92-
parent = os.path.dirname(p)
93-
if os.path.basename(p) == 'bin':
94-
for sub in ['clidriver', 'dsdriver', '']:
95-
base = os.path.join(parent, sub) if sub else parent
96-
candidates.append(os.path.join(base, 'cfg'))
97-
98-
# 3. ibm_db site-package (user or system site-packages)
99-
spec = importlib.util.find_spec('ibm_db')
100-
if spec and spec.origin:
101-
pkg_dir = os.path.dirname(spec.origin)
102-
for sub in ['clidriver/cfg', 'dsdriver/cfg']:
103-
candidates.append(os.path.join(pkg_dir, sub))
104-
105-
# 4. Common system install paths
106-
if sys.platform == 'win32':
107-
candidates.append(r'C:\Program Files\IBM\clidriver\cfg')
108-
else:
109-
candidates.extend([
110-
'/opt/ibm/db2/clidriver/cfg',
111-
'/opt/ibm/dsdriver/cfg',
112-
os.path.expanduser('~/sqllib/cfg'),
113-
])
114-
115-
# Return the first candidate whose parent dir exists
116-
for c in candidates:
117-
if os.path.isdir(os.path.dirname(c)):
118-
return c
119-
120-
return ''
121-
122-
print(find_cfg())
81+
import os, site, glob
82+
83+
# Search all site-packages for clidriver/cfg or dsdriver/cfg
84+
dirs = site.getsitepackages() + [site.getusersitepackages()]
85+
for sp in dirs:
86+
for pattern in ['ibm_db/clidriver/cfg', 'clidriver/cfg', 'ibm_db/dsdriver/cfg']:
87+
matches = glob.glob(os.path.join(sp, pattern))
88+
if matches:
89+
print(matches[0])
90+
raise SystemExit(0)
91+
92+
# Fallback: IBM_DB_HOME
93+
ibm_db_home = os.environ.get('IBM_DB_HOME', '')
94+
if ibm_db_home:
95+
print(os.path.join(ibm_db_home, 'cfg'))
96+
raise SystemExit(0)
12397
")
12498
12599
if [ -z "$CFG_DIR" ]; then
126-
echo "::error::Could not locate clidriver/cfg or dsdriver/cfg directory"
100+
echo "::error::Could not locate clidriver/cfg directory"
127101
exit 1
128102
fi
129103
130104
echo "Writing db2dsdriver.cfg to $CFG_DIR"
131105
mkdir -p "$CFG_DIR"
132-
cat > "$CFG_DIR/db2dsdriver.cfg" <<EOF
106+
107+
# Write the XML without leading whitespace
108+
cat > "$CFG_DIR/db2dsdriver.cfg" <<-EOF
109+
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
133110
<configuration>
134111
<dsncollection>
135112
<dsn alias="${{ secrets.DB2_DATABASE }}" name="${{ secrets.DB2_DATABASE }}" host="${{ secrets.DB2_HOSTNAME }}" port="${{ secrets.DB2_PORT }}">
@@ -142,7 +119,11 @@ jobs:
142119
</database>
143120
</databases>
144121
</configuration>
145-
EOF
122+
EOF
123+
124+
echo "--- db2dsdriver.cfg content ---"
125+
cat "$CFG_DIR/db2dsdriver.cfg"
126+
echo "--- end ---"
146127

147128
- name: Run test suite
148129
shell: bash

0 commit comments

Comments
 (0)