Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Use GitHub Actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 10, 2019
1 parent 15dc8f6 commit 4568845
Showing 1 changed file with 184 additions and 0 deletions.
184 changes: 184 additions & 0 deletions .github/workflows/continuous-integration.yml
@@ -0,0 +1,184 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
pull_request:
push:
branches:
- master
tags:
- "**"

name: "Continuous Integration"

jobs:
coding-standards:
name: "Coding Standards"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 7.4

steps:
- name: "Checkout"
uses: actions/checkout@v1

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v1
with:
coverage: none
extensions: "json"
php-version: ${{ matrix.php-version }}

- name: "Validate composer.json and composer.lock"
run: composer validate --strict

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php${{ matrix.php-version }}-composer-locked-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Run localheinz/composer-normalize"
run: composer normalize --dry-run

- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: mkdir -p .build/php-cs-fixer

- name: "Cache cache directory for friendsofphp/php-cs-fixer"
uses: actions/cache@v1
with:
path: .build/php-cs-fixer
key: php${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php${{ matrix.php-version }}-php-cs-fixer-
- name: "Run friendsofphp/php-cs-fixer"
run: vendor/bin/php-cs-fixer fix --diff --diff-format=udiff --dry-run --verbose

static-code-analysis:
name: "Static Code Analysis"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 7.4

steps:
- name: "Checkout"
uses: actions/checkout@v1

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v1
with:
coverage: none
extensions: "json"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: ${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ matrix.php-version }}-composer-locked-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Run phpstan/phpstan"
run: vendor/bin/phpstan analyse

tests:
name: "Tests"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 7.2
- 7.3
- 7.4

dependencies:
- lowest
- highest

steps:
- name: "Checkout"
uses: actions/checkout@v1

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v1
with:
coverage: none
extensions: "json"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- name: "Install lowest dependencies with composer"
if: matrix.dependencies == 'lowest'
run: composer update --no-interaction --no-progress --no-suggest --prefer-lowest

- name: "Install highest dependencies with composer"
if: matrix.dependencies == 'highest'
run: composer update --no-interaction --no-progress --no-suggest

- name: "Run tests with phpunit/phpunit"
run: vendor/bin/phpunit

code-coverage:
name: "Code Coverage"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 7.4

steps:
- name: "Checkout"
uses: actions/checkout@v1

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v1
with:
coverage: pcov
extensions: "json"
php-version: ${{ matrix.php-version }}

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php${{ matrix.php-version }}-composer-locked-
- name: "Install locked dependencies with composer"
run: composer install --no-interaction --no-progress --no-suggest

- name: "Collect code coverage with pcov and phpunit/phpunit"
run: vendor/bin/phpunit -coverage-clover=build/logs/clover.xml

- name: "Send code coverage report to Codecov.io"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)

0 comments on commit 4568845

Please sign in to comment.