Add CI workflow to run test suite on push to test_dll_issue branch #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Test Suite | |
| on: | |
| push: | |
| branches: | |
| - test_dll_issue | |
| workflow_dispatch: | |
| inputs: | |
| python-version: | |
| description: 'Python version' | |
| required: true | |
| type: choice | |
| options: | |
| - '3.9' | |
| - '3.10' | |
| - '3.11' | |
| - '3.12' | |
| - '3.13' | |
| - '3.14' | |
| - 'all' | |
| default: '3.14' | |
| test-pattern: | |
| description: 'Test glob pattern (e.g. test_001*.py). Leave empty to run all.' | |
| required: false | |
| type: string | |
| default: '' | |
| jobs: | |
| run_tests: | |
| name: Test on self-hosted / Python ${{ matrix.python-version }} | |
| runs-on: self-hosted | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| 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')) }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install ibm_db from source | |
| shell: pwsh | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install . | |
| - name: Generate config files from secrets | |
| shell: pwsh | |
| run: | | |
| Copy-Item config.py.sample config.py | |
| @" | |
| { | |
| "database" : "${{ secrets.DB2_DATABASE }}", | |
| "user" : "${{ secrets.DB2_USER }}", | |
| "password" : "${{ secrets.DB2_PASSWD }}", | |
| "hostname" : "${{ secrets.DB2_HOSTNAME }}", | |
| "port" : ${{ secrets.DB2_PORT }} | |
| } | |
| "@ | Set-Content -Path config.json -Encoding UTF8 | |
| - name: Write db2dsdriver.cfg into clidriver/cfg | |
| shell: pwsh | |
| run: | | |
| $cfgDir = python -c @" | |
| import os, site, glob | |
| dirs = site.getsitepackages() + [site.getusersitepackages()] | |
| for sp in dirs: | |
| for pattern in ['ibm_db/clidriver/cfg', 'clidriver/cfg', 'ibm_db/dsdriver/cfg']: | |
| matches = glob.glob(os.path.join(sp, pattern)) | |
| if matches: | |
| print(matches[0]) | |
| raise SystemExit(0) | |
| ibm_db_home = os.environ.get('IBM_DB_HOME', '') | |
| if ibm_db_home: | |
| print(os.path.join(ibm_db_home, 'cfg')) | |
| raise SystemExit(0) | |
| "@ | |
| if (-not $cfgDir) { | |
| Write-Error "Could not locate clidriver/cfg directory" | |
| exit 1 | |
| } | |
| $cfgDir = $cfgDir.Trim() | |
| Write-Host "Writing db2dsdriver.cfg to $cfgDir" | |
| New-Item -ItemType Directory -Path $cfgDir -Force | Out-Null | |
| @" | |
| <?xml version="1.0" encoding="UTF-8" standalone="no" ?> | |
| <configuration> | |
| <dsncollection> | |
| <dsn alias="${{ secrets.DB2_DATABASE }}" name="${{ secrets.DB2_DATABASE }}" host="${{ secrets.DB2_HOSTNAME }}" port="${{ secrets.DB2_PORT }}"> | |
| <parameter name="Protocol" value="TCPIP"/> | |
| </dsn> | |
| </dsncollection> | |
| <databases> | |
| <database name="${{ secrets.DB2_DATABASE }}" host="${{ secrets.DB2_HOSTNAME }}" port="${{ secrets.DB2_PORT }}"> | |
| <parameter name="Protocol" value="TCPIP"/> | |
| </database> | |
| </databases> | |
| </configuration> | |
| "@ | Set-Content -Path (Join-Path $cfgDir "db2dsdriver.cfg") -Encoding UTF8 | |
| Write-Host "--- db2dsdriver.cfg content ---" | |
| Get-Content (Join-Path $cfgDir "db2dsdriver.cfg") | |
| Write-Host "--- end ---" | |
| - name: Run test suite | |
| shell: pwsh | |
| env: | |
| DB2_USER: ${{ secrets.DB2_USER }} | |
| DB2_PASSWD: ${{ secrets.DB2_PASSWD }} | |
| run: | | |
| $testPattern = "${{ github.event.inputs.test-pattern }}" | |
| if ($testPattern) { | |
| $env:SINGLE_PYTHON_TEST = $testPattern | |
| } | |
| python ibmdb_tests.py |