Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 176 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: 'CI'
on: # Build any PRs and main branch changes
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
pull_request:
types:
- opened
- edited
- synchronize
push:
branches: [ master ]
schedule:
- cron: '0 0 1 * *' # Every month

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true

env:
# Cache params
CACHE_VERSION: 2022061905 # To be able to create a new cache (YYYYMMDDXX)
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader
CODACY_CACHE_PATH: ~/.cache/codacy
CODACY_BIN: ~/.cache/codacy/codacy.sh


#permissions:
# actions: write # Required to be able to trigger sub CI workflows

jobs:
tests:
name: UTs & FTs - PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
env:
COVERAGE_TYPE: none
strategy:
fail-fast: true
max-parallel: 4
matrix:
php-version:
- '8.2' # Latest supported
- '8.1'
- '8.0' # First php 8 version
- '7.4' # Latest php 7 version
- '7.3'
- '7.2'
- '7.1'
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Enable coverage
if: ${{ matrix.php-version == '8.1' }}
run: |
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
tools: composer
coverage: ${{ env.COVERAGE_TYPE }}
env:
# Always use latest available patch for the version
update: true

- name: Setup cache
id: cache
uses: actions/cache@v2
with:
path: |
~/.composer
./vendor
${{ env.CODACY_CACHE_PATH }}
build/behat-code-coverage-cache
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
&& chmod +x ${{ env.CODACY_BIN }} \
&& ${{ env.CODACY_BIN }} download

- name: Build
run: |
make build

- name: Tests
run: make test-technical && make test-functional

# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-server-sdk
- name: Upload unit tests coverage to codecov
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: codecov/codecov-action@v3
with:
file: "build/coverage-phpunit/unit.clover"
name: "unit-tests-${{ matrix.php-version }}"
flags: "unit-tests,php-${{ matrix.php-version }}"
fail_ci_if_error: true

- name: Upload functional tests coverage to codecov
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: codecov/codecov-action@v3
with:
files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover"
name: "functional-tests-${{ matrix.php-version }}"
flags: "functional-tests,php-${{ matrix.php-version }}"
fail_ci_if_error: true

- name: Upload coverages to Codacy
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial

static-checks:
name: Static checks
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- uses: actions/checkout@v2

- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: 8.2 # Latest supported
tools: composer
coverage: none
env:
# Always use latest available patch for the version
update: true

- name: Setup cache
id: cache
uses: actions/cache@v2
with:
path: |
~/.composer
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}

- name: Build
run: make build

- name: ComposerRequireChecker
uses: docker://webfactory/composer-require-checker:3.2.0

- name: Dependencies check
if: ${{ github.event_name == 'pull_request' }}
uses: actions/dependency-review-action@v1

finalize-codacy-coverage-report:
runs-on: ubuntu-latest
name: Finalize Codacy coverage report
needs: [ tests ]
steps:
- name: Setup cache
id: cache
uses: actions/cache@v2
with:
path: |
${{ env.CODACY_CACHE_PATH }}
key: ${{ env.CACHE_VERSION }}-codacy-final

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
&& chmod +x ${{ env.CODACY_BIN }} \
&& ${{ env.CODACY_BIN }} download

- name: Finalize reporting
run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }}
39 changes: 0 additions & 39 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
Expand Up @@ -3,7 +3,7 @@

[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/php-jsonrpc-server-sdk.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/php-jsonrpc-server-sdk/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/php-jsonrpc-server-sdk/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk/?branch=master)

[![Travis Build Status](https://img.shields.io/travis/yoanm/php-jsonrpc-server-sdk/master.svg?label=Travis&logo=travis)](https://travis-ci.org/yoanm/php-jsonrpc-server-sdk) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/php-jsonrpc-server-sdk.svg?logo=travis)](https://travis-ci.org/yoanm/php-jsonrpc-server-sdk)
[![CI](https://github.com/yoanm/php-jsonrpc-server-sdk/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/sphp-jsonrpc-server-sdk/actions/workflows/CI.yml)

[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/jsonrpc-server-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-server-sdk) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/jsonrpc-server-sdk.svg)](https://packagist.org/packages/yoanm/jsonrpc-server-sdk)

Expand Down