Skip to content

Commit de3ef0f

Browse files
authored
Merge pull request #21 from php/ci
GitHub Actions CI
2 parents e103c68 + 1f7db15 commit de3ef0f

File tree

3 files changed

+138
-1
lines changed

3 files changed

+138
-1
lines changed

.github/workflows/ci.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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']
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+
- name: phpize
35+
run: phpize
36+
- name: configure
37+
run: ./configure --with-IBM_DB2=$PWD/clidriver
38+
- name: make
39+
run: make V=1
40+
- name: Cache container
41+
id: cache-docker
42+
uses: actions/cache@v2
43+
with:
44+
path: image-cache
45+
key: ${{ runner.os }}-image-cache
46+
- name: Download container
47+
if: steps.cache-docker.outputs.cache-hit != 'true'
48+
run: |
49+
docker pull ibmcom/db2
50+
mkdir image-cache
51+
docker save -o image-cache/db2.tar ibmcom/db2
52+
- name: Restore container from cache
53+
if: steps.cache-docker.outputs.cache-hit == 'true'
54+
run: docker load -i image-cache/db2.tar
55+
- name: Set up Db2 LUW in Docker
56+
# XXX: Should we be caching the Docker image? Are we creating the necessary things?
57+
# Adapted from the Travis setup with the changes used for the current
58+
# version of the Db2 container.
59+
run: |
60+
set -x
61+
cat <<EOF > db2cli.ini
62+
[SAMPLE]
63+
Hostname=localhost
64+
Protocol=TCPIP
65+
Port=60000
66+
Database=sample
67+
EOF
68+
mkdir database
69+
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
70+
docker ps -as
71+
while true
72+
do
73+
if (docker logs db2 | grep 'Setup has completed')
74+
then
75+
break
76+
fi
77+
sleep 20
78+
done
79+
- name: Tests
80+
# make test is insufficient to load PDO
81+
# Most of these are either cribbed from the old Travis configuration,
82+
# or required for the tests to use the DSN.
83+
# Note that connection.inc defaults should be mostly sufficient.
84+
run: |
85+
export TEST_PHP_ARGS="-n -d extension=modules/ibm_db2.so"
86+
export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0
87+
export DB2CLIINIPATH=$PWD
88+
export REPORT_EXIT_STATUS=1
89+
php run-tests.php -P --show-diff tests
90+
windows:
91+
defaults:
92+
run:
93+
shell: cmd
94+
strategy:
95+
matrix:
96+
version: ["7.4", "8.0", "8.1"]
97+
arch: [x64]
98+
ts: [ts]
99+
runs-on: windows-latest
100+
steps:
101+
- name: Checkout
102+
uses: actions/checkout@v2
103+
- name: Cache DB2 library
104+
id: cache-clidriver
105+
uses: actions/cache@v2
106+
with:
107+
path: clidriver
108+
key: ${{ runner.os }}-clidriver
109+
- name: Install DB2 library
110+
if: steps.cache-clidriver.outputs.cache-hit != 'true'
111+
shell: pwsh
112+
run: |
113+
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'
114+
Expand-Archive 'ntx64_odbc_cli.zip' -DestinationPath '.\'
115+
- name: Setup PHP
116+
id: setup-php
117+
uses: cmb69/[email protected]
118+
with:
119+
version: ${{matrix.version}}
120+
arch: ${{matrix.arch}}
121+
ts: ${{matrix.ts}}
122+
- name: Enable Developer Command Prompt
123+
uses: ilammy/msvc-dev-cmd@v1
124+
with:
125+
arch: ${{matrix.arch}}
126+
toolset: ${{steps.setup-php.outputs.toolset}}
127+
- name: phpize
128+
run: phpize
129+
- name: configure
130+
run: configure --with-ibm_db2=%cd%\clidriver --with-prefix=${{steps.setup-php.outputs.prefix}}
131+
- name: make
132+
run: nmake
133+
# XXX: Can we run Docker containers in a Windows runner? That'll be required for tests
134+
#- name: test
135+
# run: nmake test TESTS=tests

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (PHP_IBM_DB2 != "no") {
99
db2_include_paths += PHP_IBM_DB2 + "\\include;";
1010
}
1111

12-
if (CHECK_LIB("db2cli.lib", "ibm_db2",db2_lib_paths)) {
12+
if (CHECK_LIB("db2cli.lib", "ibm_db2", db2_lib_paths) || CHECK_LIB("db2cli64.lib", "ibm_db2", db2_lib_paths)) {
1313
EXTENSION("ibm_db2", "ibm_db2.c");
1414
CHECK_HEADER_ADD_INCLUDE('sql.h', 'CFLAGS_IBM_DB2', db2_include_paths);
1515
CHECK_HEADER_ADD_INCLUDE('sqlext.h', 'CFLAGS_IBM_DB2', db2_include_paths);

tests/test_10353_MemLeak.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IBM-DB2: PECL bug 10353 -- Memory leak testing
44
<?php
55
require_once('skipif.inc');
66
if(version_compare(PHP_VERSION, '7.0.0', '<') == 1) die("skip: Test segfaults on PHP 5.6");
7+
if(ZEND_DEBUG_BUILD == false) die("skip: test is allegedly pointless on release builds");
78
?>
89
--FILE--
910
<?php
@@ -97,6 +98,7 @@ if ($row) {
9798

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

0 commit comments

Comments
 (0)