Skip to content
Closed
Changes from all commits
Commits
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
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on: [push]

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
php-versions: ['5.4', '5.5', '7.0']
db-image: [mysql:5.5, mariadb:10.0, mariadb:10.1]
services:
mysql:
image: ${{ matrix.db-image }}
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2

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

- name: Fix broken dependencies
run: sudo apt-get install -f -y

- name: Update apt-get
run: sudo apt-get update

- name: Install MySQL client
run: sudo apt-get install -y mysql-client

- name: Setup database
run: |
mysql -h 127.0.0.1 -u root -proot -e "DROP DATABASE IF EXISTS addressbook;"
mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE addressbook;"
mysql -h 127.0.0.1 -u root -proot addressbook < addressbook.sql

- name: Configure database
run: cp .github-offline/db.config.php config/cfg.db.php

- name: Start PHP web server
run: php -S localhost:8000 -t . &

- name: Run tests
env:
SERVER_NAME: "localhost:8000"
REQUEST_URI: "/index.php"
run: |
sleep 2
php test/index.php | tee /tmp/test_output.txt
# Fail the job if the test runner didn't report success
if ! grep -q "Passes:" /tmp/test_output.txt; then
echo "::error::Test runner did not complete successfully."
exit 1
fi
# Fail the job if the test suite reported failures
if grep -q "FAILURES!!!" /tmp/test_output.txt; then
echo "::error::Test suite reported failures."
exit 1
fi
echo "All tests passed!"

- name: Stop PHP web server
if: always()
run: pkill -f "php -S localhost:8000" || true
Loading