Skip to content

GitHub Actions CI #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build and Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
# XXX: macOS
ubuntu:
strategy:
matrix:
version: ['7.3', '7.4', '8.0']
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache DB2 library
id: cache-clidriver
uses: actions/cache@v2
with:
path: clidriver
key: ${{ runner.os }}-clidriver
- name: Install DB2 library
if: steps.cache-clidriver.outputs.cache-hit != 'true'
run: |
wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
tar xvzf linuxx64_odbc_cli.tar.gz
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.version}}
- name: phpize
run: phpize
- name: configure
run: ./configure --with-IBM_DB2=$PWD/clidriver
- name: make
run: make V=1
- name: Cache container
id: cache-docker
uses: actions/cache@v2
with:
path: image-cache
key: ${{ runner.os }}-image-cache
- name: Download container
if: steps.cache-docker.outputs.cache-hit != 'true'
run: |
docker pull ibmcom/db2
mkdir image-cache
docker save -o image-cache/db2.tar ibmcom/db2
- name: Restore container from cache
if: steps.cache-docker.outputs.cache-hit == 'true'
run: docker load -i image-cache/db2.tar
- name: Set up Db2 LUW in Docker
# XXX: Should we be caching the Docker image? Are we creating the necessary things?
# Adapted from the Travis setup with the changes used for the current
# version of the Db2 container.
run: |
set -x
cat <<EOF > db2cli.ini
[SAMPLE]
Hostname=localhost
Protocol=TCPIP
Port=60000
Database=sample
EOF
mkdir database
docker run --name db2 --privileged=true -p 60000:50000 -e DB2INST1_PASSWORD=password -e LICENSE=accept -e DBNAME=sample -v database:/database -itd ibmcom/db2
docker ps -as
while true
do
if (docker logs db2 | grep 'Setup has completed')
then
break
fi
sleep 20
done
- name: Tests
# make test is insufficient to load PDO
# Most of these are either cribbed from the old Travis configuration,
# or required for the tests to use the DSN.
# Note that connection.inc defaults should be mostly sufficient.
run: |
export TEST_PHP_ARGS="-n -d extension=modules/ibm_db2.so"
export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0
export DB2CLIINIPATH=$PWD
export REPORT_EXIT_STATUS=1
php run-tests.php -P --show-diff tests
windows:
defaults:
run:
shell: cmd
strategy:
matrix:
version: ["7.4", "8.0", "8.1"]
arch: [x64]
ts: [ts]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache DB2 library
id: cache-clidriver
uses: actions/cache@v2
with:
path: clidriver
key: ${{ runner.os }}-clidriver
- name: Install DB2 library
if: steps.cache-clidriver.outputs.cache-hit != 'true'
shell: pwsh
run: |
Invoke-WebRequest -Uri 'https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip' -OutFile 'ntx64_odbc_cli.zip'
Expand-Archive 'ntx64_odbc_cli.zip' -DestinationPath '.\'
- name: Setup PHP
id: setup-php
uses: cmb69/[email protected]
with:
version: ${{matrix.version}}
arch: ${{matrix.arch}}
ts: ${{matrix.ts}}
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.arch}}
toolset: ${{steps.setup-php.outputs.toolset}}
- name: phpize
run: phpize
- name: configure
run: configure --with-ibm_db2=%cd%\clidriver --with-prefix=${{steps.setup-php.outputs.prefix}}
- name: make
run: nmake
# XXX: Can we run Docker containers in a Windows runner? That'll be required for tests
#- name: test
# run: nmake test TESTS=tests
2 changes: 1 addition & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (PHP_IBM_DB2 != "no") {
db2_include_paths += PHP_IBM_DB2 + "\\include;";
}

if (CHECK_LIB("db2cli.lib", "ibm_db2",db2_lib_paths)) {
if (CHECK_LIB("db2cli.lib", "ibm_db2", db2_lib_paths) || CHECK_LIB("db2cli64.lib", "ibm_db2", db2_lib_paths)) {
EXTENSION("ibm_db2", "ibm_db2.c");
CHECK_HEADER_ADD_INCLUDE('sql.h', 'CFLAGS_IBM_DB2', db2_include_paths);
CHECK_HEADER_ADD_INCLUDE('sqlext.h', 'CFLAGS_IBM_DB2', db2_include_paths);
Expand Down
2 changes: 2 additions & 0 deletions tests/test_10353_MemLeak.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ IBM-DB2: PECL bug 10353 -- Memory leak testing
<?php
require_once('skipif.inc');
if(version_compare(PHP_VERSION, '7.0.0', '<') == 1) die("skip: Test segfaults on PHP 5.6");
if(ZEND_DEBUG_BUILD == false) die("skip: test is allegedly pointless on release builds");
?>
--FILE--
<?php
Expand Down Expand Up @@ -97,6 +98,7 @@ if ($row) {

/* Testing db2_foreign_keys leaks */
$stmt = db2_foreign_keys($conn, NULL, NULL, NULL);
/* XXX: This will fail with a TypeError in PHP 8.x instead */
$row = db2_fetch_array($stmt);
if ($row) {
echo "Shouldn't be here\n";
Expand Down