Skip to content

Commit 83b0e4f

Browse files
SvenRtbgcweiske
authored andcommitted
Automatically run tests and code style checks via Github actions
Resolves: #221 Resolves: #227
1 parent fa23e59 commit 83b0e4f

File tree

2 files changed

+59
-10
lines changed

2 files changed

+59
-10
lines changed

.github/workflows/phpcs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Code Style test
2+
on:
3+
push:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
9+
codestyle:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php-versions:
14+
- '8.3'
15+
16+
name: with PHP ${{ matrix.php-versions }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Install PHP ${{ matrix.php-versions }}
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-versions }}
25+
tools: composer
26+
27+
- name: Validate composer.json and composer.lock
28+
run: composer validate --strict
29+
30+
- name: Get composer cache directory
31+
id: composer-cache
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
34+
- name: Cache dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: ${{ steps.composer-cache.outputs.dir }}
38+
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
39+
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-versions }}-
40+
41+
- name: Install dependencies
42+
run: composer install --no-interaction --prefer-dist
43+
44+
- name: Check codestyle
45+
run: ./vendor/bin/phpcs --standard=PEAR src/

.github/workflows/test.yml renamed to .github/workflows/phpunit.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: JsonMapper tests
2-
on: [push, workflow_dispatch]
1+
name: PHPUnit tests
2+
on:
3+
push:
4+
workflow_dispatch:
5+
pull_request:
6+
37
jobs:
4-
test:
8+
9+
phpunit:
510
runs-on: ubuntu-latest
611
strategy:
712
matrix:
@@ -13,12 +18,14 @@ jobs:
1318
- '8.0'
1419
- '8.1'
1520
- '8.2'
16-
name: PHP ${{ matrix.php-versions }}
21+
- '8.3'
22+
23+
name: using PHP ${{ matrix.php-versions }}
1724
steps:
1825
- name: Checkout
19-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2027

21-
- name: Install PHP
28+
- name: Install PHP ${{ matrix.php-versions }}
2229
uses: shivammathur/setup-php@v2
2330
with:
2431
php-version: ${{ matrix.php-versions }}
@@ -30,7 +37,7 @@ jobs:
3037
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3138

3239
- name: Cache dependencies
33-
uses: actions/cache@v3
40+
uses: actions/cache@v4
3441
with:
3542
path: ${{ steps.composer-cache.outputs.dir }}
3643
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
@@ -41,6 +48,3 @@ jobs:
4148

4249
- name: Run unit tests
4350
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text
44-
45-
- name: Check codestyle
46-
run: ./vendor/bin/phpcs --standard=PEAR src/

0 commit comments

Comments
 (0)