.github/workflows/test.yml
name: Build
on:
push:
pull_request:
jobs:
tests:
name: Test & Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php: '8.1'
publish: true
exclude:
- php: '8.1'
publish: false
php:
- '8.0'
- '8.1'
- '8.2'
publish:
- false
continue-on-error: ${{ matrix.php == '8.1' }}
env:
PHP_VERSION: ${{ matrix.php }}
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--prefer-dist --prefer-stable"
- name: Build phar
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
composer build-phar
- name: Run tests
run: |
composer test-coverage
- name: Publish code coverage to codeclimate
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: Prepare docs
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
curl -L https://phar.phpunit.de/phploc.phar > ./phploc;
chmod +x ./phploc;
./phploc --log-json=phploc.json src;
composer prepare-docs
- name: Setup Python
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Setup mkdocs-material
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
pip install mkdocs-material mkdocs-awesome-pages-plugin
- name: Generate & publish docs
if: matrix.publish == true && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
mkdocs gh-deploy --force
- name: Draft Release
uses: softprops/action-gh-release@v1
if: matrix.publish == true && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
bin/dog.phar