Skip to content

Commit

Permalink
GitHub actions (#36)
Browse files Browse the repository at this point in the history
* feat: github actions php workflow
  • Loading branch information
didoda authored Feb 2, 2021
1 parent 1e52187 commit fd3a54a
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 51 deletions.
177 changes: 177 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: 'php'

on:
pull_request:
paths:
- '**/*.php'
push:
paths:
- '**/*.php'

jobs:
cs:
name: 'Check coding style'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-18.04'

strategy:
matrix:
php-version: [7.2]

steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
tools: 'composer:v1'
extensions: 'mbstring, intl'
coverage: 'none'

- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'

- name: 'Share Composer cache across runs'
uses: 'actions/cache@v2'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

- name: 'Run PHP CodeSniffer'
run: |
vendor/bin/phpcs -n -p --extensions=php \
--standard=vendor/cakephp/cakephp-codesniffer/CakePHP \
./config ./src ./tests
stan:
name: 'Static code analyzer'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-18.04'
continue-on-error: true

strategy:
matrix:
php-version: [7.2, 7.3, 7.4]

steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
tools: 'composer:v1, phpstan'
extensions: 'mbstring, intl'
coverage: 'none'

- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'

- name: 'Share Composer cache across runs'
uses: 'actions/cache@v2'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

- name: 'Run PHP STAN'
run: |
phpstan analyse --no-progress src
unit:
name: 'Run unit tests'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-18.04'
env:
BEDITA_API_KEY: 12345
BEDITA_API: http://127.0.0.1:8080
BEDITA_ADMIN_USR: admin
BEDITA_ADMIN_PWD: admin
BEDITA_DOCKER_IMG: bedita/bedita:4.2.1

strategy:
matrix:
php-version: [7.2, 7.3, 7.4]

steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v2'

- name: 'Composer config GH token if available'
run: 'if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi'

- name: 'Docker pull bedita image'
run: 'docker pull ${BEDITA_DOCKER_IMG}'

- name: 'Docker inspect bedita image'
run: 'docker inspect ${BEDITA_DOCKER_IMG}'

- name: 'Docker run bedita image'
run: 'docker run --name api -d -p 127.0.0.1:8080:80 --env BEDITA_API_KEY=${BEDITA_API_KEY} --env BEDITA_ADMIN_USR=${BEDITA_ADMIN_USR} --env BEDITA_ADMIN_PWD=${BEDITA_ADMIN_PWD} ${BEDITA_DOCKER_IMG}'

- name: 'Wait for 10'
run: 'sleep 10'

- name: 'Docker ps - show all containers'
run: 'docker ps -a'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
tools: 'composer:v1'
extensions: 'mbstring, intl'

- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'

- name: 'Share Composer cache across runs'
uses: 'actions/cache@v2'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ matrix.php-version }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'

- name: 'Run PHPUnit with coverage'
run: 'vendor/bin/phpunit --coverage-clover=clover.xml'

- name: Check test coverage
id: test-coverage
uses: johanvanhelden/gha-clover-test-coverage-check@v1
with:
percentage: '85'
filename: 'clover.xml'

- name: 'Export coverage results'
uses: 'codecov/codecov-action@v1'
with:
file: './clover.xml'
env_vars: PHP_VERSION

- name: 'Archive code coverage results'
uses: 'actions/upload-artifact@v2'
with:
name: 'PHP ${{ matrix.php }}'
path: 'clover.xml'
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BEdita/WebTools plugin for CakePHP web apps using BEdita 4 API

[![Build Status](https://travis-ci.com/bedita/web-tools.svg?branch=master)](https://travis-ci.com/bedita/web-tools)
[![Github Actions](https://github.com/bedita/dev-tools/workflows/php/badge.svg)](https://github.com/bedita/dev-tools/actions?query=workflow%3Aphp)
[![codecov](https://codecov.io/gh/bedita/web-tools/branch/master/graph/badge.svg)](https://codecov.io/gh/bedita/web-tools)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bedita/web-tools/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bedita/web-tools/?branch=master)
[![image](https://img.shields.io/packagist/v/bedita/web-tools.svg?label=stable)](https://packagist.org/packages/bedita/web-tools)
Expand Down

0 comments on commit fd3a54a

Please sign in to comment.