2021-12-13 01:04:47 +00:00
|
|
|
name: Tests
|
2019-11-21 16:59:07 +00:00
|
|
|
|
2020-03-20 16:59:11 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
|
|
|
schedule:
|
|
|
|
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
|
2019-11-21 16:59:07 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-11-15 13:29:06 +00:00
|
|
|
format:
|
|
|
|
name: Format
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2021-03-15 00:25:30 +00:00
|
|
|
- name: Set Up Cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
vendor
|
|
|
|
key: php-cs-fixer-${{ hashFiles('composer.lock') }}
|
|
|
|
|
|
|
|
- name: Validate composer.json and composer.lock
|
|
|
|
run: composer validate
|
|
|
|
|
|
|
|
- name: Install PHP dependencies
|
|
|
|
run: composer update && composer install --prefer-dist --no-progress
|
|
|
|
|
|
|
|
- name: Set up PHP
|
|
|
|
uses: shivammathur/setup-php@master
|
|
|
|
with:
|
2022-10-27 16:18:28 +00:00
|
|
|
php-version: 8.1
|
|
|
|
|
|
|
|
- name: Log Versions
|
|
|
|
run: ./vendor/bin/php-cs-fixer --version
|
2021-03-15 00:25:30 +00:00
|
|
|
|
2020-11-15 13:29:06 +00:00
|
|
|
- name: Check format
|
2021-03-15 00:31:53 +00:00
|
|
|
run: ./vendor/bin/php-cs-fixer fix --dry-run
|
2020-11-15 13:29:06 +00:00
|
|
|
|
2020-03-19 13:44:56 +00:00
|
|
|
test:
|
2019-11-21 16:59:07 +00:00
|
|
|
name: PHP ${{ matrix.php }} / DB ${{ matrix.database }}
|
|
|
|
strategy:
|
2019-11-22 23:03:34 +00:00
|
|
|
fail-fast: false
|
2019-11-21 16:59:07 +00:00
|
|
|
matrix:
|
2022-10-27 16:22:26 +00:00
|
|
|
php: ['7.4', '8.0', '8.1']
|
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
|
2020-03-16 15:05:29 +00:00
|
|
|
uses: actions/checkout@v2
|
2019-11-21 16:59:07 +00:00
|
|
|
|
2020-10-24 21:55:04 +00:00
|
|
|
- name: Set Up Cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
vendor
|
2020-10-27 01:50:56 +00:00
|
|
|
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
|
2020-10-24 21:55:04 +00:00
|
|
|
|
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: |
|
|
|
|
mkdir -p data/config
|
|
|
|
if [[ "${{ matrix.database }}" == "pgsql" ]]; then
|
2020-06-22 15:19:11 +00:00
|
|
|
sudo systemctl start postgresql ;
|
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-21 16:59:07 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "mysql" ]]; then
|
2020-03-16 15:22:22 +00:00
|
|
|
sudo systemctl start mysql ;
|
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 ;
|
2019-11-21 16:59:07 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "sqlite" ]]; then
|
2020-03-13 09:54:14 +00:00
|
|
|
sudo apt update && sudo apt-get install -y sqlite3 ;
|
2019-11-21 17:34:07 +00:00
|
|
|
sqlite3 --version ;
|
2019-11-21 16:59:07 +00:00
|
|
|
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
|
2020-10-24 22:16:16 +00:00
|
|
|
run: composer update && composer install --prefer-dist --no-progress
|
2019-11-21 17:42:31 +00:00
|
|
|
|
2019-11-21 16:59:07 +00:00
|
|
|
- name: Run test suite
|
2020-01-27 19:40:14 +00:00
|
|
|
run: |
|
|
|
|
if [[ "${{ matrix.database }}" == "pgsql" ]]; then
|
2020-03-22 15:23:23 +00:00
|
|
|
export TEST_DSN="pgsql:user=shimmie;password=shimmie;host=127.0.0.1;dbname=shimmie"
|
2020-01-27 19:40:14 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "mysql" ]]; then
|
2020-03-22 15:23:23 +00:00
|
|
|
export TEST_DSN="mysql:user=root;password=root;host=127.0.0.1;dbname=shimmie"
|
2020-01-27 19:40:14 +00:00
|
|
|
fi
|
|
|
|
if [[ "${{ matrix.database }}" == "sqlite" ]]; then
|
2020-03-22 15:23:23 +00:00
|
|
|
export TEST_DSN="sqlite:data/shimmie.sqlite"
|
2020-01-27 19:40:14 +00:00
|
|
|
fi
|
|
|
|
vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=data/coverage.clover
|
2020-09-16 12:51:29 +00:00
|
|
|
|
2019-11-21 16:59:07 +00:00
|
|
|
- name: Upload coverage
|
2020-09-16 12:51:29 +00:00
|
|
|
if: matrix.php == '7.4'
|
2019-11-21 16:59:07 +00:00
|
|
|
run: |
|
|
|
|
wget https://scrutinizer-ci.com/ocular.phar
|
|
|
|
php ocular.phar code-coverage:upload --format=php-clover data/coverage.clover
|