Skip to content

Commit 2a3c83a

Browse files
committed
Add github actions for tests run
1 parent a6fd3e7 commit 2a3c83a

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

.github/workflows/test.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- README.md
9+
pull_request:
10+
11+
jobs:
12+
phpunit:
13+
runs-on: ubuntu-latest
14+
services:
15+
firebird:
16+
image: >-
17+
${{ (matrix.fb == '3.0' && 'firebirdsql/firebird:3') ||
18+
(matrix.fb == '4.0' && 'firebirdsql/firebird:4') }}
19+
ports:
20+
- 3050:3050
21+
env:
22+
ISC_PASSWORD: masterkey # Used by the Firebird service
23+
24+
strategy:
25+
matrix:
26+
php: ['5.6', '7.0', '7.4', '8.0', '8.1', '8.2', 'nightly']
27+
fb: ['3.0', '4.0']
28+
fail-fast: false
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
34+
- name: Setup PHP ${{ matrix.php }}
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
coverage: xdebug
39+
extensions: pdo # pdo itself, pdo_firebird is compiled manually
40+
41+
- name: Install Firebird client and dev files
42+
run: |
43+
sudo apt-get update -qq
44+
# firebird-utils for isql-fb, firebird-dev for compiling pdo_firebird
45+
# This will likely install dev files for a newer Firebird (e.g., FB 3.0/4.0 on Ubuntu runner)
46+
sudo apt-get install -y firebird-utils firebird-dev
47+
48+
- name: Prepare Firebird Server and Database
49+
run: |
50+
# Common network configuration, may or may not be needed with service containers
51+
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
52+
53+
echo "Using service container for Firebird ${{ matrix.fb }} on localhost:3050"
54+
echo "CREATE DATABASE 'localhost:/tmp/TEST.FDB' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 16384 DEFAULT CHARACTER SET UTF8;" > /tmp/create_test.sql
55+
# isql-fb (from firebird-utils on runner) connects to the service on localhost:3050
56+
# The CREATE DATABASE statement includes credentials.
57+
# Wait a few seconds for the service to be fully up (optional, GitHub usually waits for port)
58+
sleep 15
59+
isql-fb -i /tmp/create_test.sql
60+
cat /tmp/create_test.sql
61+
62+
- name: Build PDO_Firebird extension
63+
run: |
64+
export BRANCH=PHP-${{ matrix.php }}
65+
if [[ "${{ matrix.php }}" == "nightly" ]]; then export BRANCH=master; fi
66+
git clone --depth=1 -b ${BRANCH} --single-branch https://github.com/php/php-src.git php-src
67+
(cd php-src/ext/pdo_firebird && phpize && ./configure && make && sudo make install)
68+
69+
- name: Enable PDO_Firebird extension
70+
run: |
71+
echo "extension=pdo_firebird.so" >> $(php --ini | sed -n 's|.*:\s*\(.*php.ini\)|\1|p')
72+
php -m | grep -i pdo
73+
74+
- name: Cache Composer dependencies
75+
uses: actions/cache@v3
76+
with:
77+
path: ~/.composer/cache
78+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
79+
restore-keys: ${{ runner.os }}-composer-
80+
81+
- name: Install Composer dependencies
82+
run: |
83+
composer self-update
84+
composer global require "fxp/composer-asset-plugin:~1.2.2" --prefer-dist --no-interaction
85+
composer install --prefer-dist --no-interaction
86+
composer require "phpunit/php-invoker" --dev --prefer-dist --no-interaction
87+
88+
- name: Run PHPUnit
89+
env:
90+
PHPUNIT_FLAGS: ${{ matrix.php == '7.0' && matrix.fb == '3.0' && '--coverage-clover=coverage.clover' }}
91+
run: vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --enforce-time-limit
92+
93+
- name: Upload Code Coverage
94+
if: matrix.php == '7.0' && matrix.fb == '3.0'
95+
uses: codecov/codecov-action@v3

0 commit comments

Comments
 (0)