Skip to content

Commit

Permalink
Setup PHPUnit tests on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 30, 2020
1 parent 9fc37b8 commit 087623f
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/tests-mongodb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Tests: MongoDB"

on:
- pull_request

jobs:
mongodb:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
matrix:
php:
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"

services:
mongodb:
image: percona/percona-server-mongodb:3.6
ports:
- 27017:27017/tcp

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mongodb

- name: Install dependencies
run: composer install

- name: Run PHPUnit tests
run: composer test
env:
XHGUI_SAVE_HANDLER: "mongodb"

- name: MongoDB Service logs
run: docker logs ${{ job.services.mongodb.id }}
if: always()

# vim:ft=yaml:et:ts=2:sw=2
56 changes: 56 additions & 0 deletions .github/workflows/tests-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Tests: MySQL"

on:
- pull_request

jobs:
mysql:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
matrix:
php:
- "7.0"
- "7.1"
- "7.2"
- "7.3"

services:
mysql:
image: percona/percona-server:5.7
ports:
- 3306:3306
env:
MYSQL_USER: "xhgui"
MYSQL_PASSWORD: "password"
MYSQL_DATABASE: "xhgui"
MYSQL_ALLOW_EMPTY_PASSWORD: "1"
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo, pdo_mysql
coverage: none

- name: Install dependencies
run: composer install

- name: Run PHPUnit tests
run: composer test
env:
XHGUI_SAVE_HANDLER: "pdo"
XHGUI_PDO_DSN: "mysql:host=127.0.0.1;dbname=xhgui"
XHGUI_PDO_USER: "xhgui"
XHGUI_PDO_PASS: "password"

- name: MySQL Service logs
run: docker logs ${{ job.services.mysql.id }}
if: always()

# vim:ft=yaml:et:ts=2:sw=2
53 changes: 53 additions & 0 deletions .github/workflows/tests-pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Tests: PostgreSQL"

on:
- pull_request

jobs:
pgsql:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
matrix:
php:
- "7.0"
- "7.1"
- "7.2"
- "7.3"

services:
# https://docs.github.com/en/free-pro-team@latest/actions/guides/creating-postgresql-service-containers
pgsql:
image: postgres:9.2
ports:
- 5432:5432
env:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password"
POSTGRES_DB: "xhgui"

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo, pdo_pgsql
coverage: none

- name: Install dependencies
run: composer install

- name: Run PHPUnit tests
run: composer test
env:
XHGUI_SAVE_HANDLER: "pdo"
XHGUI_PDO_DSN: "pgsql:host=127.0.0.1;dbname=xhgui user=postgres password=password"

- name: PostgreSQL service logs
run: docker logs ${{ job.services.pgsql.id }}
if: always()

# vim:ft=yaml:et:ts=2:sw=2
38 changes: 38 additions & 0 deletions .github/workflows/tests-sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Tests: Sqlite"

on:
- pull_request

jobs:
sqlite:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
matrix:
php:
- "7.0"
- "7.1"
- "7.2"
- "7.3"

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo, pdo_sqlite
coverage: none

- name: Install dependencies
run: composer install

- name: Run PHPUnit tests
run: composer test
env:
XHGUI_SAVE_HANDLER: "pdo"
XHGUI_PDO_DSN: "sqlite:/tmp/xhgui.sqlite3"

# vim:ft=yaml:et:ts=2:sw=2

0 comments on commit 087623f

Please sign in to comment.