Created
January 12, 2023 12:13
-
-
Save davidpeach/20f60fb7425b729ac5f18c45c568798f to your computer and use it in GitHub Desktop.
My default CI workflow yaml for Laravel projects
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
name: Tests | |
on: | |
push: | |
branches: [ "*" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
setup: | |
name: Setting up CI environment | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e | |
with: | |
php-version: '8.1' | |
- uses: actions/checkout@v3 | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | |
- name: Install Dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Generate key | |
run: php artisan key:generate | |
- name: Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Tar it up | |
run: tar -cvf setup.tar ./ | |
- name: Upload setup artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: setup-artifact | |
path: setup.tar | |
pint: | |
name: Pint Check | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Download Setup Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: setup-artifact | |
- name: Extraction | |
run: tar -xvf setup.tar | |
- name: Running Pint | |
run: ./vendor/bin/pint | |
larastan: | |
name: Larastan Check | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Download Setup Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: setup-artifact | |
- name: Extraction | |
run: tar -xvf setup.tar | |
- name: Running Phpstan | |
run: ./vendor/bin/phpstan analyse | |
test-suite: | |
name: Feature and Unit tests | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Download Setup Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: setup-artifact | |
- name: Extraction | |
run: tar -xvf setup.tar | |
- name: Create Database | |
run: | | |
mkdir -p database | |
touch database/database.sqlite | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
run: php artisan test | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment