Skip to content

Commit

Permalink
Automatically run tests and code style checks via Github actions
Browse files Browse the repository at this point in the history
Resolves: #221
Resolves: #227
  • Loading branch information
SvenRtbg authored and cweiske committed Feb 27, 2024
1 parent 132c75c commit dddcdc0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Code Style test
on:
push:
workflow_dispatch:
pull_request:

jobs:

codestyle:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions:
- '8.3'

name: with PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php-versions }}-

- name: Install dependencies
run: composer install --no-interaction --prefer-dist

- name: Check codestyle
run: ./vendor/bin/phpcs --standard=PEAR src/
24 changes: 14 additions & 10 deletions .github/workflows/test.yml → .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: JsonMapper tests
on: [push, workflow_dispatch]
name: PHPUnit tests
on:
push:
workflow_dispatch:
pull_request:

jobs:
test:

phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -13,12 +18,14 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
name: PHP ${{ matrix.php-versions }}
- '8.3'

name: using PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

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

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

- name: Run unit tests
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text

- name: Check codestyle
run: ./vendor/bin/phpcs --standard=PEAR src/

0 comments on commit dddcdc0

Please sign in to comment.