Skip to content

Commit

Permalink
Improved GitHub Actions Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
divineniiquaye committed Apr 11, 2022
1 parent 326dcf8 commit 7378e66
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
64 changes: 28 additions & 36 deletions .github/workflows/tests.yml
@@ -1,13 +1,10 @@
# GitHub Actions Documentation: https://docs.github.com/en/actions

name: Tests
name: build
on: [push, pull_request]

env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

jobs:
build:
tests:
strategy:
fail-fast: false
matrix:
Expand All @@ -17,63 +14,56 @@ jobs:
runs-on: ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set git to use LF on Windows
if: matrix.operating-system == 'windows-latest'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, curl
coverage: xdebug
tools: composer
tools: composer:v2

- name: Get Composer Cache Directory
id: composer-cache
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
shell: bash
run: |
composer_flags=""
if [ ${{ matrix.php-versions }} == 8.1 ]; then composer_flags="--ignore-platform-req=php"; fi;
run: composer install --no-progress --optimize-autoloader

composer install --no-progress --optimize-autoloader $composer_flags
- name: Run unit tests (PHPUnit)
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

- name: Setup Code Climate test-reporter
if: matrix.operating-system == 'ubuntu-latest' && matrix.php-versions == 8.0
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: "Upload coverage report to Codecov"
uses: codecov/codecov-action@v2
continue-on-error: true
with:
files: ./coverage.clover

- name: "Upload coverage report to CodeClimate"
uses: paambaati/codeclimate-action@v3.0.0
continue-on-error: true
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

- name: Check coding standards (PHP_CodeSniffer)
run: vendor/bin/phpcs

- name: Run unit tests (PHPUnit)
continue-on-error: ${{ matrix.php-versions == 8.1 }}
run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml

- name: Publish coverage report to Codecov
if: matrix.operating-system == 'ubuntu-latest'
run: |
bash <(curl -s https://codecov.io/bash) -f clover.xml
if [ ${{ matrix.php-versions }} == 8.0 ]; then ./cc-test-reporter after-build --coverage-input-type clover; fi;
- name: "Statically analyze code (PHPStan)"
- name: Statically analyze code (Phpstan)
run: vendor/bin/phpstan analyse

- name: Statically analyze code (Psalm)
Expand All @@ -84,6 +74,8 @@ jobs:
with:
sarif_file: "build/logs/psalm.sarif"

- name: "Benchmark Router for Performance"
- name: "Benchmark for Performance"
if: matrix.operating-system != 'macos-latest'
run: composer require phpbench/phpbench -W && vendor/bin/phpbench run --report default
run: |
composer require phpbench/phpbench -W
vendor/bin/phpbench run --report=default -l none
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -4,7 +4,7 @@

[![PHP Version](https://img.shields.io/packagist/php-v/divineniiquaye/flight-routing.svg?style=flat-square&colorB=%238892BF)](http://php.net)
[![Latest Version](https://img.shields.io/packagist/v/divineniiquaye/flight-routing.svg?style=flat-square)](https://packagist.org/packages/divineniiquaye/flight-routing)
[![Workflow Status](https://img.shields.io/github/workflow/status/divineniiquaye/flight-routing/Tests?style=flat-square)](https://github.com/divineniiquaye/flight-routing/actions?query=workflow%3ATests)
[![Workflow Status](https://img.shields.io/github/workflow/status/divineniiquaye/flight-routing/build?style=flat-square)](https://github.com/divineniiquaye/flight-routing/actions?query=workflow%3Abuild)
[![Code Maintainability](https://img.shields.io/codeclimate/maintainability/divineniiquaye/flight-routing?style=flat-square)](https://codeclimate.com/github/divineniiquaye/flight-routing)
[![Coverage Status](https://img.shields.io/codecov/c/github/divineniiquaye/flight-routing?style=flat-square)](https://codecov.io/gh/divineniiquaye/flight-routing)
[![Psalm Type Coverage](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Fdivineniiquaye%2Frade-di%2Fcoverage)](https://shepherd.dev/github/divineniiquaye/flight-routing)
Expand Down

0 comments on commit 7378e66

Please sign in to comment.