Skip to content

GitHub Actions CI #6

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 28 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f1b5253
Use PHP 7.x style PDO include check
NattyNarwhal Feb 9, 2022
c278699
Initial GitHub Actions CI
NattyNarwhal Feb 9, 2022
addd471
Basic Windows support
NattyNarwhal Feb 10, 2022
2374199
Only run CI on our main branch and PRs targeting it
NattyNarwhal Feb 10, 2022
f597c06
Attempt to work around that amd64 version of clidriver uses a differe…
NattyNarwhal Feb 10, 2022
baf74e0
Break up Ubuntu steps and use verbose make
NattyNarwhal Feb 10, 2022
3a1b190
Don't have an empty globals on non-i
NattyNarwhal Feb 11, 2022
97d68f9
Fix PDO include path when using modern m4 macro
NattyNarwhal Feb 17, 2022
359efea
Attempt to run the Db2 container
NattyNarwhal Mar 1, 2022
a6bf66e
Attempt to fix loading PDO when running tests
NattyNarwhal Mar 1, 2022
a3d5671
Fix broken variable in PASE part of tests
NattyNarwhal Mar 1, 2022
0d39d0e
Set PDO test variables as needed
NattyNarwhal Mar 1, 2022
04496f3
Attempt to actually create the database
NattyNarwhal Mar 1, 2022
9d8bc0b
Make options appendable in connection string
NattyNarwhal Mar 2, 2022
2d0975e
Start test adaptations for PHP 8 and modern Db2
NattyNarwhal Mar 3, 2022
959d7cd
The workstation name is the hostname
NattyNarwhal Mar 3, 2022
213540a
We can't copy from a string to a stream
NattyNarwhal Mar 3, 2022
b13bee7
PDO changed error reporting message keys
NattyNarwhal Mar 4, 2022
deb1cda
Db2 has changed this message nowadays
NattyNarwhal Mar 7, 2022
9b6effa
Replace the LUW version of the test with IBM i one
NattyNarwhal Mar 7, 2022
8397c44
Attempt to cache the Docker container
NattyNarwhal Mar 14, 2022
a89356a
Trusted user context requires setup
NattyNarwhal Mar 14, 2022
06dd54f
7.3 has been dropped from Windows support
NattyNarwhal Mar 14, 2022
ee10e48
Flip order of adding native_type/table
NattyNarwhal Mar 17, 2022
9f6f201
Workaround: Disable the skip cache on PHP 8.1
NattyNarwhal Mar 17, 2022
f79f0dd
Fix crash if stream for LOB is null on 8.1
NattyNarwhal Mar 17, 2022
617f25d
Suppress 8.1 deprecation message for NULL in PDO arg
NattyNarwhal Mar 17, 2022
0c75465
Suppress 8.1 deprecation msg, fix indentation
NattyNarwhal Mar 17, 2022
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
139 changes: 139 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
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', '8.1']
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}}
extensions: pdo
- name: phpize
run: phpize
- name: configure
run: ./configure --with-pdo-ibm=$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.
run: |
export TEST_PHP_ARGS="-n -d extension=pdo.so -d extension=modules/pdo_ibm.so"
export DISABLE_SKIP_CACHE=1
export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0
export DB2CLIINIPATH=$PWD
export REPORT_EXIT_STATUS=1
export PDOTEST_DSN=ibm:DSN=SAMPLE
export PDOTEST_USER=db2inst1
export PDOTEST_PASS=password
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-pdo-ibm=%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
31 changes: 18 additions & 13 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ if test "$PHP_PDO_IBM" != "no"; then
done
fi

AC_MSG_CHECKING([for PDO includes])
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
pdo_inc_path=$abs_srcdir/ext
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
pdo_inc_path=$abs_srcdir/ext
elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
pdo_inc_path=$prefix/include/php/ext
else
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
fi
AC_MSG_RESULT($pdo_inc_path)
ifdef([PHP_CHECK_PDO_INCLUDES],
[
PHP_CHECK_PDO_INCLUDES
],[
AC_MSG_CHECKING([for PDO includes])
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$abs_srcdir/ext
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$abs_srcdir/ext
elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$phpincludedir/ext
else
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
fi
AC_MSG_RESULT($pdo_cv_inc_path)
])

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

if test -r $LIB_DIR/libdb400.a ; then
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_inc_path -DPASE)
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path -DPASE)
else
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_inc_path)
PHP_NEW_EXTENSION(pdo_ibm, $php_pdo_ibm_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
fi

ifdef([PHP_ADD_EXTENSION_DEP],
Expand Down
3 changes: 2 additions & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ARG_WITH("pdo-ibm", "DB2 support for PDO. Pass the location of the DB2 installat

if (PHP_PDO_IBM != "no")
{
if (CHECK_LIB("db2cli.lib", "pdo_ibm", PHP_PDO_IBM))
/* amd64 version is different name */
if (CHECK_LIB("db2cli.lib", "pdo_ibm", PHP_PDO_IBM) || CHECK_LIB("db2cli64.lib", "pdo_ibm", PHP_PDO_IBM))
{
CHECK_HEADER_ADD_INCLUDE('sql.h', 'CFLAGS_PDO_IBM', PHP_PDO_IBM + '\\include;' + PHP_PHP_BUILD + '\\include\\db2');
CHECK_HEADER_ADD_INCLUDE('sqlext.h', 'CFLAGS_PDO_IBM', PHP_PDO_IBM + '\\include;' + PHP_PHP_BUILD + '\\include\\db2');
Expand Down
21 changes: 13 additions & 8 deletions ibm_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,11 @@ static int ibm_stmt_get_col(
if (col_res->returned_type == PDO_PARAM_LOB) {
php_stream *stream = create_lob_stream(stmt, stmt_res, colno); /* already opened */
#if PHP_8_1_OR_HIGHER
php_stream_to_zval(stream, result);
if (stream != NULL) {
php_stream_to_zval(stream, result);
} else {
ZVAL_NULL(result);
}
#else
if (stream != NULL) {
*ptr = (char *) stream;
Expand Down Expand Up @@ -1711,13 +1715,6 @@ static int ibm_stmt_get_column_meta(
#else /* not PASE */


/* see if we can retrieve the type name */
if (SQLColAttribute(stmt_res->hstmt, colno + 1, SQL_DESC_TYPE_NAME,
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
(SQLPOINTER) & numericAttribute) != SQL_ERROR) {
add_assoc_stringl(return_value, "native_type", attribute_buffer, length);
}

/* see if we can retrieve the table name */
if (SQLColAttribute (stmt_res->hstmt, colno + 1, SQL_DESC_BASE_TABLE_NAME,
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
Expand All @@ -1732,6 +1729,14 @@ static int ibm_stmt_get_column_meta(
}


/* see if we can retrieve the type name */
if (SQLColAttribute(stmt_res->hstmt, colno + 1, SQL_DESC_TYPE_NAME,
(SQLPOINTER) attribute_buffer, ATTRIBUTEBUFFERSIZE, &length,
(SQLPOINTER) & numericAttribute) != SQL_ERROR) {
add_assoc_stringl(return_value, "native_type", attribute_buffer, length);
}


#endif /* not PASE */

array_init(&flags);
Expand Down
8 changes: 5 additions & 3 deletions pdo_ibm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

/* If you declare any globals in php_pdo_ibm.h uncomment this:
*/
#ifdef PASE
ZEND_DECLARE_MODULE_GLOBALS(pdo_ibm)
#endif

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


#ifdef PASE /* prior any CLI routine override ascii ccsid */
/* {{{ php_pdo_ibm_init_globals
*/
static void php_pdo_ibm_init_globals(zend_pdo_ibm_globals *pdo_ibm_globals)
{
#ifdef PASE /* prior any CLI routine override ascii ccsid */
if (pdo_ibm_globals->i5_override_ccsid) {
/* This routine should be called by the application prior
* to any other CLI routine to override the ascii ccsid
Expand All @@ -105,17 +107,17 @@ static void php_pdo_ibm_init_globals(zend_pdo_ibm_globals *pdo_ibm_globals)
*/
SQLOverrideCCSID400(pdo_ibm_globals->i5_override_ccsid);
}
#endif /* PASE */
}
/* }}} */
#endif /* PASE */

/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(pdo_ibm)
{
ZEND_INIT_MODULE_GLOBALS(pdo_ibm, php_pdo_ibm_init_globals, NULL);
#ifdef PASE
/* Only PASE has INI entries right now. */
ZEND_INIT_MODULE_GLOBALS(pdo_ibm, php_pdo_ibm_init_globals, NULL);
REGISTER_INI_ENTRIES();
#endif

Expand Down
6 changes: 4 additions & 2 deletions php_pdo_ibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ PHP_MINFO_FUNCTION(pdo_ibm);
Declare any global variables you may need between the BEGIN
and END macros here:
*/
ZEND_BEGIN_MODULE_GLOBALS(pdo_ibm)
#ifdef PASE /* i5/OS ease of use turn off/on */
ZEND_BEGIN_MODULE_GLOBALS(pdo_ibm)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to define a "uses globals" flag instead of hardcoding to PASE in case other platforms need it in the future, eg.

#if defined(PASE)
#define PDO_IBM_USES_GLOBALS
#endif

#ifdef PDO_IBM_USES_GLOBALS
ZEND_BEGIN_MODULE_GLOBALS(pdo_ibm)
...
#endif

Of course, that might be needless future-proofing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad idea, but considering ibm_db2 went a long while without any non-PASE globals, might also be needless, yeah.

long i5_ignore_userid; /* blank userid, possible no qsqsrvr */
long i5_override_ccsid; /* prior any CLI routine override ascii ccsid */
long i5_dbcs_alloc; /* if to overallocate buffers for unpredictable conversions */
#endif /* PASE */
ZEND_END_MODULE_GLOBALS(pdo_ibm)
#endif /* PASE */


/*
Expand All @@ -73,6 +73,8 @@ ZEND_END_MODULE_GLOBALS(pdo_ibm)
#define PDO_IBM_G(v) (pdo_ibm_globals.v)
#endif

#ifdef PASE /* i5/OS ease of use turn off/on */
ZEND_EXTERN_MODULE_GLOBALS(pdo_ibm)
#endif /* PASE */

#endif /* PHP_PDO_IBM_H */
8 changes: 4 additions & 4 deletions tests/fvt_006_ErrConditions_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Error Code: 00000
Array
\(
\[0\] => 00000
\[1\] => 0
\[2\] => \(\(null\)\[0\] at \(null\):0\)
\[1\] =>
\[2\] =>
\)|Error Code: IX000
Array
\(
Expand All @@ -62,7 +62,7 @@ Error Code: 00000
Array
\(
\[0\] => 00000
\[1\] => 0
\[2\] => \(\(null\)\[0\] at \(null\):0\)
\[1\] =>
\[2\] =>
\))

6 changes: 3 additions & 3 deletions tests/fvt_016_InsertIntegerBindingString.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ pdo_ibm: Insert integer by binding an empty string, a NULL, and an integer strin
$testcase->runTest();
?>
--EXPECT--
Null contents: 0
Null contents:
Null contents with int specified:
Empty string contents: 0
Empty string contents:
Empty string contents with int specified:
Int string contents: 0
Int string contents with int specified:
Int string contents with int specified: 0
done

Loading