Skip to content

Commit 4dff068

Browse files
authored
PHP 8 / CodeCov / GitHub CI (#27)
1 parent 473faef commit 4dff068

File tree

15 files changed

+254
-126
lines changed

15 files changed

+254
-126
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
10+
[Makefile]
11+
indent_style = tab
12+
indent_size = 8
13+
14+
[{*.yml,*.yaml}]
15+
indent_style = space
16+
indent_size = 2

.github/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.yml]
2+
indent_style = space
3+
indent_size = 2

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @yoanm

.github/workflows/CI.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: 'CI'
2+
on: # rebuild any PRs and main branch changes
3+
pull_request:
4+
types:
5+
- opened
6+
- synchronize
7+
push:
8+
branches: [ master ]
9+
10+
concurrency:
11+
group: "CI-${{ github.head_ref }}"
12+
cancel-in-progress: true
13+
14+
env:
15+
# Cache params
16+
CACHE_VERSION: 2022031803 # To be able to create a new cache (YYYYMMDDXX)
17+
CI: 'true'
18+
COVERAGE_OUTPUT_STYLE: clover
19+
TEST_OUTPUT_STYLE: 'pretty'
20+
PHPCS_REPORT_STYLE: 'full'
21+
COMPOSER_OPTIONS: '--optimize-autoloader'
22+
23+
jobs:
24+
unit-tests:
25+
name: Unit / PHP ${{ matrix.php-version }}
26+
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: true
29+
matrix:
30+
php-version:
31+
- '7.4'
32+
- '8.0'
33+
- '8.1'
34+
steps:
35+
- name: Check out code
36+
uses: actions/checkout@v2
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: '${{ matrix.php-version }}'
42+
tools: composer
43+
coverage: xdebug
44+
env:
45+
# Always use latest available patch for the version
46+
update: true
47+
48+
- name: Setup cache
49+
id: cache
50+
uses: actions/cache@v2
51+
with:
52+
path: |
53+
~/.composer
54+
./vendor
55+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
56+
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
57+
58+
- name: Build
59+
run: make build
60+
61+
- name: Test
62+
run: make test-unit
63+
64+
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
65+
- name: Upload coverage to codecov
66+
uses: codecov/codecov-action@v2
67+
with:
68+
name: "unit-tests-${{ matrix.php-version }}"
69+
flags: "unit-tests,php-${{ matrix.php-version }}"
70+
fail_ci_if_error: true
71+
72+
functional-tests:
73+
name: Functional / PHP ${{ matrix.php-version }}
74+
needs: [unit-tests]
75+
runs-on: ubuntu-latest
76+
strategy:
77+
fail-fast: true
78+
matrix:
79+
php-version:
80+
- '7.4'
81+
- '8.0'
82+
- '8.1'
83+
steps:
84+
- name: Check out code
85+
uses: actions/checkout@v2
86+
87+
- name: Setup PHP
88+
uses: shivammathur/setup-php@v2
89+
with:
90+
php-version: '${{ matrix.php-version }}'
91+
tools: composer
92+
coverage: xdebug
93+
env:
94+
# Always use latest available patch for the version
95+
update: true
96+
97+
- name: Setup cache
98+
id: cache
99+
uses: actions/cache@v2
100+
with:
101+
path: |
102+
~/.composer
103+
./vendor
104+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
105+
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
106+
107+
- name: Build
108+
run: make build
109+
110+
- name: Test
111+
run: make test-functional
112+
113+
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
114+
- name: Upload coverage to codecov
115+
uses: codecov/codecov-action@v2
116+
with:
117+
name: "functional-tests-${{ matrix.php-version }}"
118+
flags: "functional-tests,php-${{ matrix.php-version }}"
119+
fail_ci_if_error: true

.scrutinizer.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ build_failure_conditions:
88
- 'patches.label("Spacing").exists' # No spacing patches allowed
99
- 'patches.label("Bug").exists' # No bug patches allowed
1010
- 'issues.label("coding-style").exists' # No coding style issues allowed
11+
1112
build:
1213
dependencies:
1314
override:
1415
- make build
1516
tests:
1617
stop_on_failure: true
1718
override:
18-
-
19-
command: make coverage
20-
idle_timeout: 1200
21-
coverage:
22-
file: 'build/coverage/clover.xml'
23-
format: 'php-clover'
24-
- php-scrutinizer-run --enable-security-analysis
2519
- make codestyle
20+
- command: make scrutinizer-phpunit
21+
idle_timeout: 1200
22+
coverage:
23+
file: 'build/coverage/clover.xml'
24+
format: 'php-clover'
25+
- command: make scrutinizer-behat
26+
idle_timeout: 1200
27+
coverage:
28+
file: 'build/coverage-behat/clover.xml'
29+
format: 'php-clover'
30+
- php-scrutinizer-run --enable-security-analysis
2631
cache:
2732
directories:
2833
- ~/.composer
@@ -37,7 +42,9 @@ build:
3742
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
3843
PHPCS_DISABLE_WARNING: "true"
3944
php:
40-
version: "7.1"
45+
version: "7.4.28"
46+
ini:
47+
memory_limit: "-1"
4148
timezone: UTC
4249
postgresql: false
4350
redis: false

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

Makefile

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
COLOR_ENABLED ?= true
22
TEST_OUTPUT_STYLE ?= dot
3-
COVERAGE_OUTPUT_STYLE ?= html
43

54
## DIRECTORY AND FILE
65
BUILD_DIRECTORY ?= build
76
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
87
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
9-
BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/behat-coverage
8+
BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat
109
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
1110

1211
## Commands options
@@ -39,14 +38,18 @@ else
3938
BEHAT_OUTPUT_STYLE_OPTION ?= --format progress
4039
endif
4140

42-
ifeq ("${COVERAGE_OUTPUT_STYLE}","clover")
43-
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH}
44-
else
41+
ifdef COVERAGE_OUTPUT_STYLE
42+
export XDEBUG_MODE=coverage
4543
ifeq ("${COVERAGE_OUTPUT_STYLE}","html")
46-
PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
47-
else
48-
PHPUNIT_COVERAGE_OPTION ?= --coverage-text
49-
endif
44+
PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
45+
BEHAT_COVERAGE_OPTION ?= --profile coverage-html
46+
else ifeq ("${COVERAGE_OUTPUT_STYLE}","clover")
47+
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH}
48+
BEHAT_COVERAGE_OPTION ?= --profile coverage-clover
49+
else
50+
PHPUNIT_COVERAGE_OPTION ?= --coverage-text
51+
BEHAT_COVERAGE_OPTION ?= --profile coverage
52+
endif
5053
endif
5154

5255
ifneq ("${PHPCS_REPORT_FILE}","")
@@ -71,39 +74,36 @@ install:
7174
configure:
7275

7376
# Project tests
74-
test:
75-
make test-functional
76-
make test-technical
77-
make codestyle
77+
test: test-functional test-unit codestyle
7878

79-
test-technical:
80-
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical
79+
ifdef PHPUNIT_COVERAGE_OPTION
80+
test-unit: create-build-directories
81+
endif
82+
test-unit:
83+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} --testsuite technical
8184

85+
ifdef BEHAT_COVERAGE_OPTION
86+
test-functional: create-build-directories
87+
else ifdef PHPUNIT_COVERAGE_OPTION
88+
test-functional: create-build-directories
89+
endif
8290
test-functional:
83-
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite functional
84-
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets
91+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} --testsuite functional
92+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --no-snippets
8593

86-
codestyle: create-reports-directory
94+
codestyle: create-build-directories
8795
./vendor/bin/phpcs ${PHPCS_DISABLE_WARNING_OPTION} --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE}
8896

89-
coverage: create-coverage-directory
97+
scrutinizer-phpunit:
9098
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION}
9199

92-
behat-coverage: create-behat-coverage-directory
93-
composer required leanphp/behat-code-coverage
94-
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets --profile coverage
100+
scrutinizer-behat:
101+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --no-snippets
95102

96103

97104
# Internal commands
98-
create-coverage-directory:
99-
mkdir -p ${COVERAGE_DIRECTORY}
100-
101-
create-behat-coverage-directory:
102-
mkdir -p ${BEHAT_COVERAGE_DIRECTORY}
103-
104-
create-reports-directory:
105-
mkdir -p ${REPORTS_DIRECTORY}
106-
105+
create-build-directories:
106+
mkdir -p ${COVERAGE_DIRECTORY} ${BEHAT_COVERAGE_DIRECTORY} ${REPORTS_DIRECTORY} ${REPORTS_DIRECTORY}
107107

108-
.PHONY: build install configure test test-technical test-functional codestyle coverage behat-coverage create-coverage-directory create-behat-coverage-directory create-reports-directory
108+
.PHONY: build install configure test test-unit test-functional codestyle create-build-directories scrutinizer-behat scrutinizer-phpunit
109109
.DEFAULT: build

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# JSON-RPC server documentation
2-
[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-server-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-server-doc-sdk) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-server-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-server-doc-sdk) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/php-jsonrpc-server-doc-sdk)](https://dependabot.com)
2+
[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-server-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-server-doc-sdk)
3+
[![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-server-doc-sdk.svg)](https://github.com/yoanm/php-jsonrpc-server-doc-sdk)
4+
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/php-jsonrpc-server-doc-sdk)](https://dependabot.com)
35

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

6-
[![Travis Build Status](https://img.shields.io/travis/yoanm/php-jsonrpc-server-doc-sdk/master.svg?label=Travis&logo=travis)](https://travis-ci.org/yoanm/php-jsonrpc-server-doc-sdk) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/php-jsonrpc-server-doc-sdk.svg?logo=travis)](https://travis-ci.org/yoanm/php-jsonrpc-server-doc-sdk)
10+
[![CI](https://github.com/yoanm/php-jsonrpc-server-doc-sdk/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/php-jsonrpc-server-doc-sdk/actions/workflows/CI.yml)
11+
[![codecov](https://codecov.io/gh/yoanm/php-jsonrpc-server-doc-sdk/branch/master/graph/badge.svg?token=NHdwEBUFK5)](https://codecov.io/gh/yoanm/php-jsonrpc-server-doc-sdk)
712

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

1016
Php SDK to generate (Http) JSON-RPC server documentation
1117

behat.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
default:
2+
extensions:
3+
DVDoug\Behat\CodeCoverage\Extension:
4+
filter:
5+
include:
6+
directories:
7+
'src': ~
8+
reports: [] # No reports
29
suites:
310
default:
411
contexts:
512
- Tests\Functional\BehatContext\DocNormalizerContext: ~
613
coverage:
714
extensions:
8-
LeanPHP\Behat\CodeCoverage\Extension:
9-
drivers:
10-
- local
11-
filter:
12-
whitelist:
13-
include:
14-
directories:
15-
'src': ~
16-
report:
17-
format: html
18-
options:
19-
target: build/behat-coverage
15+
DVDoug\Behat\CodeCoverage\Extension:
16+
reports:
17+
text:
18+
showColors: true
19+
coverage-html:
20+
extensions:
21+
DVDoug\Behat\CodeCoverage\Extension:
22+
reports:
23+
html:
24+
target: build/coverage-behat
25+
coverage-clover:
26+
extensions:
27+
DVDoug\Behat\CodeCoverage\Extension:
28+
reports:
29+
clover:
30+
target: build/coverage-behat/clover.xml # no default value, you must specify

0 commit comments

Comments
 (0)