-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: callable github action for testing laravel applications with ph…
…punit
- Loading branch information
1 parent
9437045
commit d834148
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
updates: | ||
# Fetch and update latest `github-actions` pkgs | ||
- package-ecosystem: github-actions | ||
directory: '/' | ||
schedule: | ||
interval: daily | ||
time: '00:00' | ||
open-pull-requests-limit: 10 | ||
reviewers: | ||
- 99linesofcode | ||
assignees: | ||
- 99linesofcode | ||
commit-message: | ||
prefix: fix | ||
prefix-development: chore | ||
include: scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Laravel Tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
tests: | ||
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} | ||
defaults: | ||
run: | ||
working-directory: api | ||
runs-on: ubuntu-latest | ||
# Docs: https://docs.github.com/en/actions/using-containerized-services | ||
services: | ||
mysql: | ||
image: mysql:latest | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: 1 | ||
MYSQL_DATABASE: maya | ||
ports: | ||
- 3306/tcp | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
redis: | ||
image: redis:latest | ||
ports: | ||
- 6379/tcp | ||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: [8.0] | ||
stability: [prefer-stable] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Docs: https://github.com/shivammathur/setup-php | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: mbstring, dom, fileinfo, mysql | ||
coverage: none | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install composer dependencies | ||
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader | ||
|
||
- name: Prepare the application | ||
run: | | ||
php -r "copy('.env.testing', '.env');" | ||
php artisan key:generate | ||
- name: Clear config | ||
run: php artisan config:clear | ||
|
||
- name: Migrations | ||
run: php artisan migrate -v | ||
env: | ||
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | ||
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} | ||
|
||
- name: PHPUnit | ||
run: vendor/bin/phpunit --coverage-text | ||
env: | ||
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | ||
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} |