From 476cd707ab6ba32a44ead4405b2f6df41929ed4a Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Mon, 11 Dec 2023 12:19:51 +0300 Subject: [PATCH] first commit --- .github/workflows/test.yml | 46 +++++++++++++++++++++++++++++++++++ LICENSE | 21 ++++++++++++++++ README.md | 49 ++++++++++++++++++++++++++++++++++++++ action.yml | 48 +++++++++++++++++++++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f6671a8 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2fcaea6 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e132dbf --- /dev/null +++ b/README.md @@ -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) + + +```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 +``` + + +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' +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..9c73fb3 --- /dev/null +++ b/action.yml @@ -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