Skip to content

Commit

Permalink
[TASK] Introduce GitHub action workflow as CI check
Browse files Browse the repository at this point in the history
This change introduces GitHub action workflows to
integrate automatic CI checks for pushes and pull
requests.

This change adds a general php-linting for supported
php-versions and executes unit- and integration tests
against laravel 9.x and 10.x.

This helps contributors a lot, and also helps the
maintainer(s) for pull-requests, that tests are
green. Maybe this helps to minimze manual work
for pull-request reviews and increases merging
working pull-requests.

Resolves krlove#110
  • Loading branch information
sbuerk committed Mar 11, 2023
1 parent db55263 commit 3c25822
Show file tree
Hide file tree
Showing 2 changed files with 218 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/ci_laravel10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI against Laravel 10.x

on:
push:
pull_request:
schedule:
- cron: '56 4 * * *'

jobs:
lint:
name: "Lint PHP"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 10.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^10.0" \
"illuminate/support":"^10.0" \
"illuminate/config":"^10.0" \
"illuminate/console":"^10.0" ; \
git restore composer.json
- name: "Lint PHP files"
run: |
find src tests -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l
unit-tests:
name: "Unit tests"
runs-on: ubuntu-22.04
needs: lint
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 10.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^10.0" \
"illuminate/support":"^10.0" \
"illuminate/config":"^10.0" \
"illuminate/console":"^10.0" ; \
git restore composer.json
- name: "Run tests"
run: |
[[ ! -f vendor/bin/phpunit ]] && echo "PHPUnit binary missing" && exit 1
php vendor/bin/phpunit -c phpunit.xml.dist tests/unit/
integration-tests:
name: "Integration tests"
runs-on: ubuntu-22.04
needs: unit-tests
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 10.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^10.0" \
"illuminate/support":"^10.0" \
"illuminate/config":"^10.0" \
"illuminate/console":"^10.0" ; \
git restore composer.json
- name: "Run tests"
run: |
[[ ! -f vendor/bin/phpunit ]] && echo "PHPUnit binary missing" && exit 1
php vendor/bin/phpunit -c phpunit.xml.dist tests/integration/
109 changes: 109 additions & 0 deletions .github/workflows/ci_laravel9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI against Laravel 9.x

on:
push:
pull_request:
schedule:
- cron: '56 4 * * *'

jobs:
lint:
name: "Lint PHP"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 9.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^9.0" \
"illuminate/support":"^9.0" \
"illuminate/config":"^9.0" \
"illuminate/console":"^9.0" ; \
git restore composer.json
- name: "Lint PHP files"
run: |
find src tests -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l
unit-tests:
name: "Unit tests"
runs-on: ubuntu-22.04
needs: lint
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 9.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^9.0" \
"illuminate/support":"^9.0" \
"illuminate/config":"^9.0" \
"illuminate/console":"^9.0" ; \
git restore composer.json
- name: "Run tests"
run: |
[[ ! -f vendor/bin/phpunit ]] && echo "PHPUnit binary missing" && exit 1
php vendor/bin/phpunit -c phpunit.xml.dist tests/unit/
integration-tests:
name: "Integration tests"
runs-on: ubuntu-22.04
needs: unit-tests
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2.4
- name: "Install with Laravel 9.x"
run: |
rm -rf composer.lock vendor/ ; \
composer require \
"illuminate/database":"^9.0" \
"illuminate/support":"^9.0" \
"illuminate/config":"^9.0" \
"illuminate/console":"^9.0" ; \
git restore composer.json
- name: "Run tests"
run: |
[[ ! -f vendor/bin/phpunit ]] && echo "PHPUnit binary missing" && exit 1
php vendor/bin/phpunit -c phpunit.xml.dist tests/integration/

0 comments on commit 3c25822

Please sign in to comment.