Skip to content

Commit bb8691b

Browse files
committed
Merge unit and functional tests
1 parent f1f6435 commit bb8691b

File tree

2 files changed

+32
-78
lines changed

2 files changed

+32
-78
lines changed

.github/workflows/CI.yml

+23-73
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
- name: ComposerRequireChecker
4040
uses: docker://webfactory/composer-require-checker:3.2.0
4141

42-
unit-tests:
43-
name: Unit / PHP ${{ matrix.php-version }}
42+
tests:
43+
name: Tests / PHP ${{ matrix.php-version }}
4444
runs-on: ubuntu-latest
4545
strategy:
4646
fail-fast: true
@@ -90,97 +90,39 @@ jobs:
9090
&& make build
9191
9292
- name: Test
93-
run: make test-unit
93+
run: make test-unit && make test-functional
9494

95-
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
96-
- name: Upload coverage to codecov
95+
# See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server
96+
- name: Upload unit tests coverage to codecov
9797
uses: codecov/codecov-action@v2
9898
with:
99+
file: "build/coverage/clover-unit.xml"
99100
name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
100101
flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}"
101102
fail_ci_if_error: true
102-
103-
functional-tests:
104-
name: Functional / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }}
105-
needs: [ unit-tests ]
106-
runs-on: ubuntu-latest
107-
strategy:
108-
fail-fast: true
109-
max-parallel: 4
110-
matrix:
111-
php-version:
112-
- '7.2'
113-
- '7.4'
114-
- '8.0'
115-
- '8.1'
116-
symfony-version:
117-
- '4.4'
118-
- '5.4'
119-
steps:
120-
- name: Check out code
121-
uses: actions/checkout@v2
122-
123-
- name: Setup PHP
124-
uses: shivammathur/setup-php@v2
125-
with:
126-
php-version: '${{ matrix.php-version }}'
127-
tools: composer
128-
coverage: xdebug
129-
env:
130-
# Always use latest available patch for the version
131-
update: true
132-
133-
- name: Setup cache
134-
id: cache
135-
uses: actions/cache@v2
136-
with:
137-
path: |
138-
~/.composer
139-
./vendor
140-
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
141-
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
142-
143-
- name: Build
144-
run: |
145-
composer require \
146-
symfony/http-foundation:^${{ matrix.symfony-version }} \
147-
symfony/http-kernel:^${{ matrix.symfony-version }} \
148-
symfony/config:^${{ matrix.symfony-version }} \
149-
symfony/dependency-injection:^${{ matrix.symfony-version }} \
150-
symfony/event-dispatcher:^${{ matrix.symfony-version }} \
151-
symfony/routing:^${{ matrix.symfony-version }} \
152-
&& make build
153-
154-
- name: Test
155-
run: make test-functional
156-
157-
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
158-
- name: Upload coverage to codecov
103+
- name: Upload unit tests coverage to codecov
159104
uses: codecov/codecov-action@v2
160105
with:
106+
file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml"
161107
name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
162108
flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}"
163109
fail_ci_if_error: true
164110

165111
nightly-tests:
166112
name: Nightly / PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }}
167-
needs: [ functional-tests ]
113+
needs: [ tests ]
168114
runs-on: ubuntu-latest
169115
env:
170116
COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' # Ignore upper PHP bound requirement
171117
strategy:
172118
fail-fast: false
173119
max-parallel: 2
174120
matrix:
175-
exclude:
176-
- php-version: '8.1' # Already done above
177-
symfony-version: '5.4'
178121
php-version:
179-
- '8.1'
180122
- '8.2'
181123
symfony-version:
124+
- '4.4'
182125
- '5.4'
183-
- '6.2'
184126
steps:
185127
- name: Check out code
186128
uses: actions/checkout@v2
@@ -217,12 +159,20 @@ jobs:
217159
&& make build
218160
219161
- name: Test
220-
run: make test-functional
162+
run: make test-unit && make test-functional
221163

222-
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
223-
- name: Upload coverage to codecov
164+
# See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server
165+
- name: Upload unit tests coverage to codecov
224166
uses: codecov/codecov-action@v2
225167
with:
226-
name: "nightly-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
227-
flags: "nightly-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}"
168+
file: "build/coverage/clover-unit.xml"
169+
name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
170+
flags: "unit-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}"
171+
fail_ci_if_error: false
172+
- name: Upload unit tests coverage to codecov
173+
uses: codecov/codecov-action@v2
174+
with:
175+
file: "build/coverage/clover-functional.xml,build/behat-coverage/clover.xml"
176+
name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
177+
flags: "functional-tests,php-${{ matrix.php-version }},sf-^${{ matrix.symfony-version }}"
228178
fail_ci_if_error: false

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ BUILD_DIRECTORY ?= build
66
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
77
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
88
BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage-behat
9-
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
9+
PHPUNIT_UNIT_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-unit.xml
10+
PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover-functional.xml
1011

1112
## Commands options
1213
### Composer
@@ -42,12 +43,15 @@ ifdef COVERAGE_OUTPUT_STYLE
4243
export XDEBUG_MODE=coverage
4344
ifeq ("${COVERAGE_OUTPUT_STYLE}","html")
4445
PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
46+
PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
4547
BEHAT_COVERAGE_OPTION ?= --profile coverage-html
4648
else ifeq ("${COVERAGE_OUTPUT_STYLE}","clover")
47-
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH}
48-
BEHAT_COVERAGE_OPTION ?= --profile coverage-clover
49+
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${PHPUNIT_UNIT_COVERAGE_FILE_PATH}
50+
PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-clover ${PHPUNIT_FUNCTIONAL_COVERAGE_FILE_PATH}
51+
BEHAT_COVERAGE_OPTION ?= --profile coverage-clover
4952
else
5053
PHPUNIT_COVERAGE_OPTION ?= --coverage-text
54+
PHPUNIT_FUNCTIONAL_COVERAGE_OPTION ?= --coverage-text
5155
BEHAT_COVERAGE_OPTION ?= --profile coverage
5256
endif
5357
endif
@@ -84,11 +88,11 @@ test-unit:
8488

8589
ifdef BEHAT_COVERAGE_OPTION
8690
test-functional: create-build-directories
87-
else ifdef PHPUNIT_COVERAGE_OPTION
91+
else ifdef PHPUNIT_FUNCTIONAL_COVERAGE_OPTION
8892
test-functional: create-build-directories
8993
endif
9094
test-functional:
91-
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} --testsuite functional
95+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_FUNCTIONAL_COVERAGE_OPTION} --testsuite functional
9296
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} ${BEHAT_COVERAGE_OPTION} --no-snippets
9397

9498
codestyle: create-build-directories

0 commit comments

Comments
 (0)