Mattias Geniar has shared his GitHub Workflow to make GitHub do the CI work for PHP applications:
on: push
name: Run phpunit testsuite
jobs:
phpunit:
runs-on: ubuntu-latest
container:
image: mattiasgeniar/php73
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install composer dependencies
run: |
composer install --prefer-dist --no-scripts -q -o;
- name: Prepare Laravel Application
run: |
cp .env.example .env
php artisan key:generate
- name: Compile assets
run: |
yarn install --pure-lockfile
yarn run production --progress false
- name: Set custom php.ini settings
run: echo 'short_open_tag=off' >> /usr/local/etc/php/php.ini
- name: Run Testsuite
run: vendor/bin/phpunit tests/
Tests get run in a custom mattiasgeniar/php73
Docker container, which contains PHP 7.3 and extensions (including imagick
).
With some fiddling you can easily adjust this to:
- Run these tests for pull requests too (just like you can automatically run linters on pull requests)
- Extend it to become a CI/CD pipeline to automatically deploy your code too