Skip to content

Commit 6036e2d

Browse files
committed
Add CI workflow to run test suite on push to test_dll_issue branch
1 parent 8ba6c44 commit 6036e2d

1 file changed

Lines changed: 25 additions & 33 deletions

File tree

.github/workflows/run_tests.yml

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,57 +43,50 @@ jobs:
4343
python-version: ${{ matrix.python-version }}
4444

4545
- name: Install ibm_db from source
46-
shell: bash
46+
shell: pwsh
4747
run: |
4848
python -m pip install --upgrade pip
4949
python -m pip install .
5050
51-
- name: Generate config.json from secrets
52-
shell: bash
51+
- name: Generate config files from secrets
52+
shell: pwsh
5353
run: |
54-
cp config.py.sample config.py
55-
cat > config.json <<ENDOFCFG
54+
Copy-Item config.py.sample config.py
55+
@"
5656
{
5757
"database" : "${{ secrets.DB2_DATABASE }}",
5858
"user" : "${{ secrets.DB2_USER }}",
5959
"password" : "${{ secrets.DB2_PASSWD }}",
6060
"hostname" : "${{ secrets.DB2_HOSTNAME }}",
6161
"port" : ${{ secrets.DB2_PORT }}
6262
}
63-
ENDOFCFG
63+
"@ | Set-Content -Path config.json -Encoding UTF8
6464
6565
- name: Write db2dsdriver.cfg into clidriver/cfg
66-
shell: bash
66+
shell: pwsh
6767
run: |
68-
# Find the cfg dir next to the installed ibm_db package
69-
CFG_DIR=$(python -c "
68+
$cfgDir = python -c @"
7069
import os, site, glob
71-
72-
# Search all site-packages for clidriver/cfg or dsdriver/cfg
7370
dirs = site.getsitepackages() + [site.getusersitepackages()]
7471
for sp in dirs:
7572
for pattern in ['ibm_db/clidriver/cfg', 'clidriver/cfg', 'ibm_db/dsdriver/cfg']:
7673
matches = glob.glob(os.path.join(sp, pattern))
7774
if matches:
7875
print(matches[0])
7976
raise SystemExit(0)
80-
81-
# Fallback: IBM_DB_HOME
8277
ibm_db_home = os.environ.get('IBM_DB_HOME', '')
8378
if ibm_db_home:
8479
print(os.path.join(ibm_db_home, 'cfg'))
8580
raise SystemExit(0)
86-
")
87-
88-
if [ -z "$CFG_DIR" ]; then
89-
echo "::error::Could not locate clidriver/cfg directory"
81+
"@
82+
if (-not $cfgDir) {
83+
Write-Error "Could not locate clidriver/cfg directory"
9084
exit 1
91-
fi
92-
93-
echo "Writing db2dsdriver.cfg to $CFG_DIR"
94-
mkdir -p "$CFG_DIR"
95-
96-
cat > "$CFG_DIR/db2dsdriver.cfg" <<EOF
85+
}
86+
$cfgDir = $cfgDir.Trim()
87+
Write-Host "Writing db2dsdriver.cfg to $cfgDir"
88+
New-Item -ItemType Directory -Path $cfgDir -Force | Out-Null
89+
@"
9790
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
9891
<configuration>
9992
<dsncollection>
@@ -107,20 +100,19 @@ jobs:
107100
</database>
108101
</databases>
109102
</configuration>
110-
EOF
111-
112-
echo "--- db2dsdriver.cfg content ---"
113-
cat "$CFG_DIR/db2dsdriver.cfg"
114-
echo "--- end ---"
103+
"@ | Set-Content -Path (Join-Path $cfgDir "db2dsdriver.cfg") -Encoding UTF8
104+
Write-Host "--- db2dsdriver.cfg content ---"
105+
Get-Content (Join-Path $cfgDir "db2dsdriver.cfg")
106+
Write-Host "--- end ---"
115107
116108
- name: Run test suite
117-
shell: bash
109+
shell: pwsh
118110
env:
119111
DB2_USER: ${{ secrets.DB2_USER }}
120112
DB2_PASSWD: ${{ secrets.DB2_PASSWD }}
121113
run: |
122-
TEST_PATTERN="${{ github.event.inputs.test-pattern }}"
123-
if [ -n "$TEST_PATTERN" ]; then
124-
export SINGLE_PYTHON_TEST="$TEST_PATTERN"
125-
fi
114+
$testPattern = "${{ github.event.inputs.test-pattern }}"
115+
if ($testPattern) {
116+
$env:SINGLE_PYTHON_TEST = $testPattern
117+
}
126118
python ibmdb_tests.py

0 commit comments

Comments
 (0)