Skip to content

Commit 7d0d264

Browse files
authored
[CI] Moved Unit tests and CS to GitHub Actions
For more details see ezsystems/ezplatform-rest#89
1 parent 408774d commit 7d0d264

File tree

3 files changed

+73
-12
lines changed

3 files changed

+73
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '[0-9]+.[0-9]+'
8+
pull_request: ~
9+
10+
jobs:
11+
cs-fix:
12+
name: Run code style check
13+
runs-on: "ubuntu-20.04"
14+
strategy:
15+
matrix:
16+
php:
17+
- '7.4'
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup PHP Action
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: none
26+
extensions: 'pdo_sqlite, gd'
27+
tools: cs2pr
28+
29+
- uses: "ramsey/composer-install@v1"
30+
with:
31+
dependency-versions: "highest"
32+
33+
- name: Run code style check
34+
run: composer run-script check-cs -- --format=checkstyle | cs2pr
35+
36+
tests:
37+
name: Unit tests
38+
runs-on: "ubuntu-20.04"
39+
timeout-minutes: 15
40+
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
php:
45+
- '7.3'
46+
- '7.4'
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Setup PHP Action
52+
uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: ${{ matrix.php }}
55+
coverage: none
56+
extensions: pdo_sqlite, gd
57+
tools: cs2pr
58+
59+
- uses: "ramsey/composer-install@v1"
60+
with:
61+
dependency-versions: "highest"
62+
63+
- name: Setup problem matchers for PHPUnit
64+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
65+
66+
- name: Run unit test suite
67+
run: composer test

.travis.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ matrix:
2929
fast_finish: true
3030
include:
3131
# 7.3
32-
- name: "PHP 7.3 Unit tests"
33-
php: 7.3
34-
env: TEST_CONFIG="phpunit.xml"
3532
- name: "PHP 7.3 REST Integration Tests"
3633
php: 7.3
3734
env:
@@ -40,9 +37,6 @@ matrix:
4037
- APP_DEBUG=1
4138
- SF_CMD="ez:behat:create-language 'pol-PL' 'Polish (polski)'"
4239
- WEB_HOST=web
43-
- name: "Code Style Check"
44-
php: 7.3
45-
env: CHECK_CS=1
4640

4741
# test only master, stable branches and pull requests
4842
branches:
@@ -56,18 +50,16 @@ install:
5650
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
5751
# Prepare system
5852
- travis_retry composer install --prefer-dist --no-interaction --no-suggest
59-
- if [ "$REST_TEST_CONFIG" != "" ] ; then ./vendor/bin/prepare_project_edition.sh oss ${PROJECT_VERSION} ${COMPOSE_FILE} ; fi
53+
- ./vendor/bin/prepare_project_edition.sh oss ${PROJECT_VERSION} ${COMPOSE_FILE}
6054
# Execute Symfony command if specified
61-
- if [ "$SF_CMD" != "" ] ; then cd "$HOME/build/project"; docker-compose exec --user www-data app sh -c "APP_ENV=behat php bin/console $SF_CMD" ; fi
55+
- cd "$HOME/build/project"; docker-compose exec --user www-data app sh -c "APP_ENV=behat php bin/console $SF_CMD"
6256
# Detecting timezone issues by testing on random timezone
6357
- TEST_TIMEZONES=("America/New_York" "Asia/Calcutta" "UTC")
6458
- TEST_TIMEZONE=${TEST_TIMEZONES["`shuf -i 0-2 -n 1`"]}
6559

6660
# execute phpunit or behat as the script command
6761
script:
68-
- if [ "$TEST_CONFIG" != "" ] ; then php -d date.timezone=$TEST_TIMEZONE -d memory_limit=-1 vendor/bin/phpunit -c $TEST_CONFIG ; fi
69-
- if [ "$REST_TEST_CONFIG" != "" ] ; then cd "$HOME/build/project"; docker-compose exec app sh -c "cd ezsystems/ezplatform-rest && composer update && php ./vendor/bin/phpunit -c phpunit-integration-rest.xml" ; fi
70-
- if [ "$CHECK_CS" == "1" ] ; then ./vendor/bin/check_cs.sh ; fi
62+
- cd "$HOME/build/project"; docker-compose exec app sh -c "cd ezsystems/ezplatform-rest && composer update && php ./vendor/bin/phpunit -c phpunit-integration-rest.xml"
7163

7264
notifications:
7365
slack:

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
"symfony/browser-kit": "^5.3"
5454
},
5555
"scripts": {
56-
"fix-cs": "@php ./vendor/bin/php-cs-fixer fix -v --show-progress=estimating"
56+
"fix-cs": "php-cs-fixer fix -v --show-progress=estimating",
57+
"check-cs": "@fix-cs --dry-run",
58+
"test": "phpunit -c phpunit.xml"
5759
},
5860
"extra": {
5961
"branch-alias": {

0 commit comments

Comments
 (0)