Add CI workflow to run test suite on push to test_dll_issue branch #6
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: | |
| os: | |
| description: 'Runner OS' | |
| required: true | |
| type: choice | |
| options: | |
| - ubuntu-latest | |
| - windows-latest | |
| - macos-latest | |
| - all | |
| default: 'ubuntu-latest' | |
| 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 ${{ matrix.os }} / Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ github.event.inputs.os == 'all' && fromJSON('["ubuntu-latest","windows-latest","macos-latest"]') || fromJSON(format('["{0}"]', github.event.inputs.os || 'ubuntu-latest')) }} | |
| 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: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install . | |
| - name: Generate config.json from secrets | |
| shell: bash | |
| run: | | |
| cp config.py.sample config.py | |
| cat > config.json <<ENDOFCFG | |
| { | |
| "database" : "${{ secrets.DB2_DATABASE }}", | |
| "user" : "${{ secrets.DB2_USER }}", | |
| "password" : "${{ secrets.DB2_PASSWD }}", | |
| "hostname" : "${{ secrets.DB2_HOSTNAME }}", | |
| "port" : ${{ secrets.DB2_PORT }} | |
| } | |
| ENDOFCFG | |
| - name: Write db2dsdriver.cfg into clidriver/cfg | |
| shell: bash | |
| run: | | |
| # Find the cfg dir next to the installed ibm_db package | |
| CFG_DIR=$(python -c " | |
| import os, site, glob | |
| # Search all site-packages for clidriver/cfg or dsdriver/cfg | |
| 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) | |
| # Fallback: IBM_DB_HOME | |
| 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 [ -z "$CFG_DIR" ]; then | |
| echo "::error::Could not locate clidriver/cfg directory" | |
| exit 1 | |
| fi | |
| echo "Writing db2dsdriver.cfg to $CFG_DIR" | |
| mkdir -p "$CFG_DIR" | |
| cat > "$CFG_DIR/db2dsdriver.cfg" <<EOF | |
| <?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> | |
| EOF | |
| echo "--- db2dsdriver.cfg content ---" | |
| cat "$CFG_DIR/db2dsdriver.cfg" | |
| echo "--- end ---" | |
| - name: Run test suite | |
| shell: bash | |
| env: | |
| DB2_USER: ${{ secrets.DB2_USER }} | |
| DB2_PASSWD: ${{ secrets.DB2_PASSWD }} | |
| run: | | |
| TEST_PATTERN="${{ github.event.inputs.test-pattern }}" | |
| if [ -n "$TEST_PATTERN" ]; then | |
| export SINGLE_PYTHON_TEST="$TEST_PATTERN" | |
| fi | |
| python ibmdb_tests.py |