2019-11-21 16:59:07 +00:00
|
|
|
name: Unit Tests
|
|
|
|
|
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: PHP ${{ matrix.php }} / DB ${{ matrix.database }}
|
|
|
|
strategy:
|
2019-11-21 17:30:19 +00:00
|
|
|
max-parallel: 3
|
2019-11-22 23:03:34 +00:00
|
|
|
fail-fast: false
|
2019-11-21 16:59:07 +00:00
|
|
|
matrix:
|
2019-11-21 17:30:19 +00:00
|
|
|
php: ['7.3']
|
2019-11-21 17:28:02 +00:00
|
|
|
database: ['pgsql', 'mysql', 'sqlite']
|
2019-11-21 16:59:07 +00:00
|
|
|
|
2019-11-25 00:24:45 +00:00
|
|
|
runs-on: ubuntu-latest
|
2019-11-21 16:59:07 +00:00
|
|
|
steps:
|
2019-11-25 00:24:45 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v1
|
2019-11-21 16:59:07 +00:00
|
|
|
|
|
|
|
- name: Set up PHP
|
|
|
|
uses: shivammathur/setup-php@master
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php }}
|
|
|
|
coverage: pcov
|
2020-01-26 16:40:52 +00:00
|
|
|
extensions: mbstring
|
2019-11-21 16:59:07 +00:00
|
|
|
|
2019-11-21 17:42:31 +00:00
|
|
|
- name: Set up database
|
2019-11-21 16:59:07 +00:00
|
|
|
run: |
|
2019-11-23 11:54:54 +00:00
|
|
|
sudo apt update
|
2019-11-21 16:59:07 +00:00
|
|
|
mkdir -p data/config
|
|
|
|
if [[ "${{ matrix.database }}" == "pgsql" ]]; then
|
2019-11-23 12:00:45 +00:00
|
|
|
sudo apt-get install -y postgresql postgresql-client ;
|
2019-11-21 17:34:07 +00:00
|
|
|
psql --version ;
|
2019-11-23 12:09:18 +00:00
|
|
|
sudo -u postgres psql -c "SELECT set_config('log_statement', 'all', false);" -U postgres ;
|
|
|
|
sudo -u postgres psql -c "CREATE USER shimmie WITH PASSWORD 'shimmie';" -U postgres ;
|
|
|
|
sudo -u postgres psql -c "CREATE DATABASE shimmie WITH OWNER shimmie;" -U postgres ;
|
2019-11-23 12:15:16 +00:00
|
|
|
echo '<?php define("DATABASE_DSN", "pgsql:user=shimmie;password=shimmie;host=127.0.0.1;dbname=shimmie");' > data/config/auto_install.conf.php ;
|
2019-11-21 16:59:07 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "mysql" ]]; then
|
2019-11-21 17:34:07 +00:00
|
|
|
mysql --version ;
|
2019-11-22 23:03:34 +00:00
|
|
|
mysql -e "SET GLOBAL general_log = 'ON';" -uroot -proot ;
|
|
|
|
mysql -e "CREATE DATABASE shimmie;" -uroot -proot ;
|
|
|
|
echo '<?php define("DATABASE_DSN", "mysql:user=root;password=root;host=127.0.0.1;dbname=shimmie");' > data/config/auto_install.conf.php ;
|
2019-11-21 16:59:07 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "sqlite" ]]; then
|
2019-11-23 00:09:15 +00:00
|
|
|
sudo apt-get install -y sqlite3 ;
|
2019-11-21 17:34:07 +00:00
|
|
|
sqlite3 --version ;
|
2019-11-21 16:59:07 +00:00
|
|
|
echo '<?php define("DATABASE_DSN", "sqlite:data/shimmie.sqlite");' > data/config/auto_install.conf.php ;
|
|
|
|
fi
|
2019-11-21 17:34:07 +00:00
|
|
|
|
2019-11-21 17:42:31 +00:00
|
|
|
- name: Check versions
|
|
|
|
run: php -v && composer -V
|
|
|
|
|
|
|
|
- name: Validate composer.json and composer.lock
|
|
|
|
run: composer validate
|
|
|
|
|
|
|
|
- name: Install PHP dependencies
|
|
|
|
run: composer install --prefer-dist --no-progress --no-suggest
|
|
|
|
|
2019-11-21 17:34:07 +00:00
|
|
|
- name: Install shimmie
|
|
|
|
run: php index.php
|
2019-11-21 16:59:07 +00:00
|
|
|
|
|
|
|
- name: Run test suite
|
|
|
|
run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=data/coverage.clover
|
|
|
|
|
|
|
|
- name: Upload coverage
|
|
|
|
run: |
|
|
|
|
wget https://scrutinizer-ci.com/ocular.phar
|
|
|
|
php ocular.phar code-coverage:upload --format=php-clover data/coverage.clover
|