first commit

This commit is contained in:
Anatoliy Poloz
2023-12-11 12:19:51 +03:00
commit 476cd707ab
4 changed files with 164 additions and 0 deletions

46
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: 'Action Test'
on:
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
name: Test Default
steps:
- uses: actions/checkout@v4
- name: Install laravel/laravel
run: |
docker run --rm \
--pull=always \
-v "$(pwd)":/laravel \
-w /laravel \
composer:latest \
bash -c "composer create-project laravel/laravel laravel"
- run: |
sudo chown -R runner:docker laravel
cp -a laravel/. .
rm -rf laravel
- uses: ./
test-custom-setup:
runs-on: ubuntu-latest
name: Test Custom Setup
steps:
- uses: actions/checkout@v4
- name: Install laravel/laravel
run: |
docker run --rm \
--pull=always \
-v "$(pwd)":/laravel \
-w /laravel \
composer:latest \
bash -c "composer create-project laravel/laravel laravel"
- run: |
sudo chown -R runner:docker laravel
cp -a laravel/. .
rm -rf laravel
- uses: ./
with:
setup: false

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Halas Labs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

49
README.md Normal file
View File

@@ -0,0 +1,49 @@
# GitHub Action to run your Laravel application's test suite.
This GitHub Action will run your [Laravel](https://laravel.com) application's test suite with `php artisan test`.
For more information about testing your Laravel application see the [official documentation](https://laravel.com/docs/testing).
## Usage
To use this action, call it as a step in one of your workflows.
See [action.yml](action.yml)
<!-- start usage -->
```yaml
name: 'Test'
on:
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v3
- uses: halaslabs/laravel-test-runner@v1
with:
php-version: 8.2
```
<!-- end usage -->
A demo of the action can be seen here: https://github.com/halaslabs/laravel-test-runner/actions/workflows/test.yml
### Inputs
```yaml
- uses: halaslabs/laravel-test-runner@v1
with:
# Version of php to install for running the test suite.
# For supported versions, see: https://github.com/shivammathur/setup-php#tada-php-support
# default: 8.2
php-version: '8.2'
# If true, we run https://github.com/shivammathur/setup-php prior to running your laravel tests
# If false, you are in charge of setting php as needed for your application.
# default: true
setup: 'true'
```

48
action.yml Normal file
View File

@@ -0,0 +1,48 @@
name: Laravel Test Runner
author: halaslabs
description: "This action will run your Laravel application's test suite."
branding:
color: 'purple'
icon: 'crosshair'
inputs:
php-version:
description: 'PHP version to install'
required: false
default: '8.2'
setup:
description: 'If false, setup-php will not be run'
required: false
default: 'true'
runs:
using: composite
steps:
- if: inputs.setup == 'true'
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
- name: Install Dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
shell: bash
- name: Prepare
run: |
echo "::group::PHP Modules"
php -m
echo "::endgroup::"
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
shell: bash
- name: Test Run
run: |
php artisan test --without-tty | tee test_results
echo '```' >> $GITHUB_STEP_SUMMARY
cat test_results >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
shell: bash