Skip to content

Commit

Permalink
GH Actions workflow with Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Aug 31, 2022
1 parent 21a3102 commit ab0f267
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
73 changes: 41 additions & 32 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Tests
name: Test Suite

on:
# Controls when the action will be triggered.
push: # A push to any branch.
pull_request: # A pull request to the main/master branch.
pull_request: # A pull request to the trunk (main/master branch).
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
Expand All @@ -13,25 +13,29 @@ on:
jobs:
php-tests:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]

include:
- php: '7.2'
- php: '7.3'
- php: '7.4'
composer-flags: '--prefer-lowest'
- php: '7.4'
- php: '8.0'
- php: '8.1'
# Steps represent a sequence of tasks that will be executed as part of the job
name: Run tests @ PHP ${{ matrix.php-versions }}
name: "PHP${{ matrix.php }} ${{ matrix.composer-flags }}"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
- name: Checkout source
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
# extensions: json
# ini-values: "post_max_size=256M" #optional
php-version: ${{ matrix.php }}
# extensions: json
# ini-values: "post_max_size=256M" #optional
coverage: pcov

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand All @@ -42,30 +46,35 @@ jobs:
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
restore-keys: ${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Update composer dependencies
run: composer update -o --no-interaction --no-progress --prefer-dist ${{ matrix.composer-flags }}

- name: Run TEST suite
run: composer run-script test:ci -- -C
run: composer run-script test:ci -- -C --coverage tests/output/coverage.xml --coverage-src=src
#run: vendor/bin/tester tests -C --coverage tests/output/coverage.xml --coverage-src=src

- name: Install php-coveralls
run: composer global require -o --no-interaction --no-progress --prefer-dist php-coveralls/php-coveralls

- name: Upload coverage results to Coveralls
uses: nick-invision/retry@v2
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: "PHP${{ matrix.php }}"
with:
timeout_seconds: 60
max_attempts: 3
command: php-coveralls -x tests/output/coverage.xml -o tests/output/upload.json -v

lowest-deps:
name: Lowest dependencies
coveralls-finish:
needs: php-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
- name: Notify Coveralls when build is finished
uses: coverallsapp/github-action@master
with:
php-version: 7.2
coverage: none
- run: composer update --prefer-dist --no-progress --prefer-lowest --prefer-stable
- name: Run TEST suite
run: composer run-script test:ci -- -C


#
# I gave up on Coveralls since I have no idea how to set it up given the error with json_path. Pity.
# https://github.com/php-coveralls/php-coveralls/issues/339
#
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Slim factory helper for Slim v4

![PHP from Packagist](https://img.shields.io/packagist/php-v/dakujem/slim-factory)
[![Tests](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml/badge.svg)](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml)
[![Test Suite](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml/badge.svg)](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/dakujem/slim-factory/badge.svg?branch=main)](https://coveralls.io/github/dakujem/slim-factory?branch=main)

> 💿 `composer require dakujem/slim-factory`
Expand Down

0 comments on commit ab0f267

Please sign in to comment.