Skip to content

Commit e827e37

Browse files
authored
Merge pull request #6 from php/ci
GitHub Actions CI
2 parents 6ca647d + 0c75465 commit e827e37

19 files changed

+238
-184
lines changed

.github/workflows/ci.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Build and Test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
# XXX: macOS
11+
ubuntu:
12+
strategy:
13+
matrix:
14+
version: ['7.3', '7.4', '8.0', '8.1']
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
- name: Cache DB2 library
20+
id: cache-clidriver
21+
uses: actions/cache@v2
22+
with:
23+
path: clidriver
24+
key: ${{ runner.os }}-clidriver
25+
- name: Install DB2 library
26+
if: steps.cache-clidriver.outputs.cache-hit != 'true'
27+
run: |
28+
wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
29+
tar xvzf linuxx64_odbc_cli.tar.gz
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{matrix.version}}
34+
extensions: pdo
35+
- name: phpize
36+
run: phpize
37+
- name: configure
38+
run: ./configure --with-pdo-ibm=$PWD/clidriver
39+
- name: make
40+
run: make V=1
41+
- name: Cache container
42+
id: cache-docker
43+
uses: actions/cache@v2
44+
with:
45+
path: image-cache
46+
key: ${{ runner.os }}-image-cache
47+
- name: Download container
48+
if: steps.cache-docker.outputs.cache-hit != 'true'
49+
run: |
50+
docker pull ibmcom/db2
51+
mkdir image-cache
52+
docker save -o image-cache/db2.tar ibmcom/db2
53+
- name: Restore container from cache
54+
if: steps.cache-docker.outputs.cache-hit == 'true'
55+
run: docker load -i image-cache/db2.tar
56+
- name: Set up Db2 LUW in Docker
57+
# XXX: Should we be caching the Docker image? Are we creating the necessary things?
58+
# Adapted from the Travis setup with the changes used for the current
59+
# version of the Db2 container.
60+
run: |
61+
set -x
62+
cat <<EOF > db2cli.ini
63+
[SAMPLE]
64+
Hostname=localhost
65+
Protocol=TCPIP
66+
Port=60000
67+
Database=sample
68+
EOF
69+
mkdir database
70+
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
71+
docker ps -as
72+
while true
73+
do
74+
if (docker logs db2 | grep 'Setup has completed')
75+
then
76+
break
77+
fi
78+
sleep 20
79+
done
80+
- name: Tests
81+
# make test is insufficient to load PDO
82+
# Most of these are either cribbed from the old Travis configuration,
83+
# or required for the tests to use the DSN.
84+
run: |
85+
export TEST_PHP_ARGS="-n -d extension=pdo.so -d extension=modules/pdo_ibm.so"
86+
export DISABLE_SKIP_CACHE=1
87+
export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0
88+
export DB2CLIINIPATH=$PWD
89+
export REPORT_EXIT_STATUS=1
90+
export PDOTEST_DSN=ibm:DSN=SAMPLE
91+
export PDOTEST_USER=db2inst1
92+
export PDOTEST_PASS=password
93+
php run-tests.php -P --show-diff tests
94+
windows:
95+
defaults:
96+
run:
97+
shell: cmd
98+
strategy:
99+
matrix:
100+
version: ["7.4", "8.0", "8.1"]
101+
arch: [x64]
102+
ts: [ts]
103+
runs-on: windows-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v2
107+
- name: Cache DB2 library
108+
id: cache-clidriver
109+
uses: actions/cache@v2
110+
with:
111+
path: clidriver
112+
key: ${{ runner.os }}-clidriver
113+
- name: Install DB2 library
114+
if: steps.cache-clidriver.outputs.cache-hit != 'true'
115+
shell: pwsh
116+
run: |
117+
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'
118+
Expand-Archive 'ntx64_odbc_cli.zip' -DestinationPath '.\'
119+
- name: Setup PHP
120+
id: setup-php
121+
uses: cmb69/setup-php-sdk@v0.2
122+
with:
123+
version: ${{matrix.version}}
124+
arch: ${{matrix.arch}}
125+
ts: ${{matrix.ts}}
126+
- name: Enable Developer Command Prompt
127+
uses: ilammy/msvc-dev-cmd@v1
128+
with:
129+
arch: ${{matrix.arch}}
130+
toolset: ${{steps.setup-php.outputs.toolset}}
131+
- name: phpize
132+
run: phpize
133+
- name: configure
134+
run: configure --with-pdo-ibm=%cd%\clidriver --with-prefix=${{steps.setup-php.outputs.prefix}}
135+
- name: make
136+
run: nmake
137+
# XXX: Can we run Docker containers in a Windows runner? That'll be required for tests
138+
#- name: test
139+
# run: nmake test TESTS=tests

config.m4

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,22 @@ if test "$PHP_PDO_IBM" != "no"; then
6262
done
6363
fi
6464

65-
AC_MSG_CHECKING([for PDO includes])
66-
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
67-
pdo_inc_path=$abs_srcdir/ext
68-
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
69-
pdo_inc_path=$abs_srcdir/ext
70-
elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
71-
pdo_inc_path=$prefix/include/php/ext
72-
else
73-
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
74-
fi
75-
AC_MSG_RESULT($pdo_inc_path)
65+
ifdef([PHP_CHECK_PDO_INCLUDES],
66+
[
67+
PHP_CHECK_PDO_INCLUDES
68+
],[
69+
AC_MSG_CHECKING([for PDO includes])
70+
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
71+
pdo_cv_inc_path=$abs_srcdir/ext
72+
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
73+
pdo_cv_inc_path=$abs_srcdir/ext
74+
elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
75+
pdo_cv_inc_path=$phpincludedir/ext
76+
else
77+
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
78+
fi
79+
AC_MSG_RESULT($pdo_cv_inc_path)
80+
])
7681

7782
dnl Don't forget to add additional source files here
7883
php_pdo_ibm_sources_core="pdo_ibm.c ibm_driver.c ibm_statement.c"
@@ -94,9 +99,9 @@ if test "$PHP_PDO_IBM" != "no"; then
9499
esac
95100

96101
if test -r $LIB_DIR/libdb400.a ; then
97-
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_inc_path -DPASE)
102+
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path -DPASE)
98103
else
99-
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_inc_path)
104+
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
100105
fi
101106

102107
ifdef([PHP_ADD_EXTENSION_DEP],

config.w32

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ ARG_WITH("pdo-ibm", "DB2 support for PDO. Pass the location of the DB2 installat
22

33
if (PHP_PDO_IBM != "no")
44
{
5-
if (CHECK_LIB("db2cli.lib", "pdo_ibm", PHP_PDO_IBM))
5+
/* amd64 version is different name */
6+
if (CHECK_LIB("db2cli.lib", "pdo_ibm", PHP_PDO_IBM) || CHECK_LIB("db2cli64.lib", "pdo_ibm", PHP_PDO_IBM))
67
{
78
CHECK_HEADER_ADD_INCLUDE('sql.h', 'CFLAGS_PDO_IBM', PHP_PDO_IBM + '\\include;' + PHP_PHP_BUILD + '\\include\\db2');
89
CHECK_HEADER_ADD_INCLUDE('sqlext.h', 'CFLAGS_PDO_IBM', PHP_PDO_IBM + '\\include;' + PHP_PHP_BUILD + '\\include\\db2');

ibm_statement.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,11 @@ static int ibm_stmt_get_col(
15571557
if (col_res->returned_type == PDO_PARAM_LOB) {
15581558
php_stream *stream = create_lob_stream(stmt, stmt_res, colno); /* already opened */
15591559
#if PHP_8_1_OR_HIGHER
1560-
php_stream_to_zval(stream, result);
1560+
if (stream != NULL) {
1561+
php_stream_to_zval(stream, result);
1562+
} else {
1563+
ZVAL_NULL(result);
1564+
}
15611565
#else
15621566
if (stream != NULL) {
15631567
*ptr = (char *) stream;
@@ -1711,13 +1715,6 @@ static int ibm_stmt_get_column_meta(
17111715
#else /* not PASE */
17121716

17131717

1714-
/* see if we can retrieve the type name */
1715-
if (SQLColAttribute(stmt_res->hstmt, colno + 1, SQL_DESC_TYPE_NAME,
1716-
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
1717-
(SQLPOINTER) & numericAttribute) != SQL_ERROR) {
1718-
add_assoc_stringl(return_value, "native_type", attribute_buffer, length);
1719-
}
1720-
17211718
/* see if we can retrieve the table name */
17221719
if (SQLColAttribute (stmt_res->hstmt, colno + 1, SQL_DESC_BASE_TABLE_NAME,
17231720
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
@@ -1732,6 +1729,14 @@ static int ibm_stmt_get_column_meta(
17321729
}
17331730

17341731

1732+
/* see if we can retrieve the type name */
1733+
if (SQLColAttribute(stmt_res->hstmt, colno + 1, SQL_DESC_TYPE_NAME,
1734+
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
1735+
(SQLPOINTER) & numericAttribute) != SQL_ERROR) {
1736+
add_assoc_stringl(return_value, "native_type", attribute_buffer, length);
1737+
}
1738+
1739+
17351740
#endif /* not PASE */
17361741

17371742
array_init(&flags);

pdo_ibm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232

3333
/* If you declare any globals in php_pdo_ibm.h uncomment this:
3434
*/
35+
#ifdef PASE
3536
ZEND_DECLARE_MODULE_GLOBALS(pdo_ibm)
37+
#endif
3638

3739
/* True global resources - no need for thread safety here */
3840
static int le_pdo_ibm;
@@ -91,11 +93,11 @@ PHP_INI_END()
9193
#endif /* PASE */
9294

9395

96+
#ifdef PASE /* prior any CLI routine override ascii ccsid */
9497
/* {{{ php_pdo_ibm_init_globals
9598
*/
9699
static void php_pdo_ibm_init_globals(zend_pdo_ibm_globals *pdo_ibm_globals)
97100
{
98-
#ifdef PASE /* prior any CLI routine override ascii ccsid */
99101
if (pdo_ibm_globals->i5_override_ccsid) {
100102
/* This routine should be called by the application prior
101103
* to any other CLI routine to override the ascii ccsid
@@ -105,17 +107,17 @@ static void php_pdo_ibm_init_globals(zend_pdo_ibm_globals *pdo_ibm_globals)
105107
*/
106108
SQLOverrideCCSID400(pdo_ibm_globals->i5_override_ccsid);
107109
}
108-
#endif /* PASE */
109110
}
110111
/* }}} */
112+
#endif /* PASE */
111113

112114
/* {{{ PHP_MINIT_FUNCTION
113115
*/
114116
PHP_MINIT_FUNCTION(pdo_ibm)
115117
{
116-
ZEND_INIT_MODULE_GLOBALS(pdo_ibm, php_pdo_ibm_init_globals, NULL);
117118
#ifdef PASE
118119
/* Only PASE has INI entries right now. */
120+
ZEND_INIT_MODULE_GLOBALS(pdo_ibm, php_pdo_ibm_init_globals, NULL);
119121
REGISTER_INI_ENTRIES();
120122
#endif
121123

php_pdo_ibm.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ PHP_MINFO_FUNCTION(pdo_ibm);
4747
Declare any global variables you may need between the BEGIN
4848
and END macros here:
4949
*/
50-
ZEND_BEGIN_MODULE_GLOBALS(pdo_ibm)
5150
#ifdef PASE /* i5/OS ease of use turn off/on */
51+
ZEND_BEGIN_MODULE_GLOBALS(pdo_ibm)
5252
long i5_ignore_userid; /* blank userid, possible no qsqsrvr */
5353
long i5_override_ccsid; /* prior any CLI routine override ascii ccsid */
5454
long i5_dbcs_alloc; /* if to overallocate buffers for unpredictable conversions */
55-
#endif /* PASE */
5655
ZEND_END_MODULE_GLOBALS(pdo_ibm)
56+
#endif /* PASE */
5757

5858

5959
/*
@@ -73,6 +73,8 @@ ZEND_END_MODULE_GLOBALS(pdo_ibm)
7373
#define PDO_IBM_G(v) (pdo_ibm_globals.v)
7474
#endif
7575

76+
#ifdef PASE /* i5/OS ease of use turn off/on */
7677
ZEND_EXTERN_MODULE_GLOBALS(pdo_ibm)
78+
#endif /* PASE */
7779

7880
#endif /* PHP_PDO_IBM_H */

tests/fvt_006_ErrConditions_01.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Error Code: 00000
4848
Array
4949
\(
5050
\[0\] => 00000
51-
\[1\] => 0
52-
\[2\] => \(\(null\)\[0\] at \(null\):0\)
51+
\[1\] =>
52+
\[2\] =>
5353
\)|Error Code: IX000
5454
Array
5555
\(
@@ -62,7 +62,7 @@ Error Code: 00000
6262
Array
6363
\(
6464
\[0\] => 00000
65-
\[1\] => 0
66-
\[2\] => \(\(null\)\[0\] at \(null\):0\)
65+
\[1\] =>
66+
\[2\] =>
6767
\))
6868

tests/fvt_016_InsertIntegerBindingString.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ pdo_ibm: Insert integer by binding an empty string, a NULL, and an integer strin
103103
$testcase->runTest();
104104
?>
105105
--EXPECT--
106-
Null contents: 0
106+
Null contents:
107107
Null contents with int specified:
108-
Empty string contents: 0
108+
Empty string contents:
109109
Empty string contents with int specified:
110110
Int string contents: 0
111-
Int string contents with int specified:
111+
Int string contents with int specified: 0
112112
done
113113

0 commit comments

Comments
 (0)