Skip to content

Instantly share code, notes, and snippets.

@davidpeach
Created September 13, 2022 10:45
Show Gist options
  • Save davidpeach/76e0f24126e8d6359a586f95e05bd0ed to your computer and use it in GitHub Desktop.
Save davidpeach/76e0f24126e8d6359a586f95e05bd0ed to your computer and use it in GitHub Desktop.
Github Actions CI file to run Pint, Larastan and Tests in parallel
name: Laravel
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
@Neodark7
Copy link

Hi ! This workflow doesn't re use what shivammathur/setup-php installs on the system.

I set up shivammathur action to install php 8.2

but the subsequent steps are using the default installed php (which is php 8.1.2-1ubuntu2.14 at the moment i write this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment