Skip to content

Instantly share code, notes, and snippets.

@JohnnyWalkerDigital
Last active February 20, 2026 10:57
Show Gist options
  • Select an option

  • Save JohnnyWalkerDigital/1b80922a06fb441fb3b44d97ed65b21f to your computer and use it in GitHub Desktop.

Select an option

Save JohnnyWalkerDigital/1b80922a06fb441fb3b44d97ed65b21f to your computer and use it in GitHub Desktop.
GitHub Action: Laravel CI Pipeline
# Laravel CI Pipeline
# Description: Github Action to run code linting, static analysis, and Laravel tests
# Author: Johnny Walker
# Version: 1.1
# Date: 21 February 2026
# Requirements:
# PHP_CodeSniffer - https://github.com/PHPCSStandards/PHP_CodeSniffer/
# Larastan - https://github.com/larastan/larastan
# Recommended:
# Slavomat Coding Standard - https://github.com/slevomat/coding-standard
# Suggested Codesniffer Config - https://gist.github.com/JohnnyWalkerDigital/aca5ee0d21c12d31440327079ae40c23
# Latest version at: https://gist.github.com/JohnnyWalkerDigital/1b80922a06fb441fb3b44d97ed65b21f
# Usage: Place in .github/workflows folder
name: Laravel CI Pipeline
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- 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: Install npm
run: npm ci
- name: Create npm manifest
run: npm run build
- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs -n --runtime-set ignore_warnings_on_exit 1 || ./vendor/bin/phpcbf --runtime-set ignore_warnings_on_exit 1
- name: Run PHP Larastan
run: php vendor/bin/phpstan analyse --memory-limit=2G
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan test --stop-on-failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment