Skip to content

refactor BaseCommand.php #57

refactor BaseCommand.php

refactor BaseCommand.php #57

Workflow file for this run

name: Test Package with Laravel 12
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
laravel-12-tests:
runs-on: ubuntu-latest
timeout-minutes: 5 # Add timeout to prevent indefinite runs
strategy:
matrix:
php: ["8.2", "8.3", "8.4"]
name: Laravel 12 (PHP ${{ matrix.php }})
steps:
- name: Checkout package repository
uses: actions/checkout@v4
with:
path: laravel-microscope
- name: Checkout Laravel test application
uses: actions/checkout@v4
with:
repository: imanghafoori1/laravel-microscope-tester
path: laravel-app
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_sqlite, sqlite3, gd, zip, curl, dom, fileinfo, libxml, bcmath, openssl, tokenizer, json, xdebug
coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-laravel12-php-${{ matrix.php }}-${{ hashFiles('laravel-app/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-laravel12-php-${{ matrix.php }}-
${{ runner.os }}-composer-
- name: Configure Laravel 12 and local package
timeout-minutes: 2
run: |
cd laravel-app
# First, just install existing dependencies without updating
composer install --no-interaction --no-progress
# Remove any existing version of the package
composer remove imanghafoori/laravel-microscope --no-interaction 2>/dev/null || true
# Add local package repository
composer config repositories.local-microscope '{"type": "path", "url": "../laravel-microscope", "options": {"symlink": true}}'
# Require local package
composer require "imanghafoori/laravel-microscope:@dev" --no-interaction
# Update PHPUnit based on PHP version
# if [[ "${{ matrix.php }}" == "8.5" ]] || [[ "${{ matrix.php }}" == "8.4" ]]; then
# # PHP 8.4+ requires PHPUnit 11+
# composer update "phpunit/phpunit:^11.0" -W --no-interaction
# else
# # PHP 8.2-8.3 work with PHPUnit 10+
# composer update "phpunit/phpunit:^10.0" -W --no-interaction
# fi
- name: Verify installations
run: |
cd laravel-app
echo "=== Installed Versions ==="
composer show laravel/framework 2>/dev/null || echo "laravel/framework not installed"
composer show phpunit/phpunit 2>/dev/null || echo "phpunit/phpunit not installed"
composer show imanghafoori/laravel-microscope 2>/dev/null || echo "Package not found"
echo "=========================="
- name: Prepare Laravel environment
run: |
cd laravel-app
# Create .env if not exists
if [ ! -f ".env" ]; then
cp .env.example .env 2>/dev/null || echo "APP_NAME=Test\nAPP_ENV=testing\nAPP_KEY=" > .env
fi
# Generate app key
php artisan key:generate --force 2>/dev/null || true
# Clear caches
php artisan config:clear 2>/dev/null || true
php artisan cache:clear 2>/dev/null || true
- name: Run tests with Laravel 12
if: always()
run: |
cd laravel-app
# Check if there are test files mentioning microscope
echo "running tests..."
php artisan test --coverage-clover ./../laravel-microscope/clover.xml --colors=always 2>/dev/null || false
env:
XDEBUG_MODE: coverage
- name: Check for dependency issues
if: always()
run: |
cd laravel-app
echo "=== Dependency Status ==="
composer outdated --direct --format=json 2>/dev/null | jq -r '.installed[] | "\(.name): \(.version) -> \(.latest)"' 2>/dev/null || echo "Could not check dependencies"
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd laravel-microscope
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=clover.xml --json_path=coverall.xml -v
laravel-11-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
php: ["8.2", "8.3"] # Note: Laravel 11 supports PHP 8.2-8.3
name: Laravel 11 (PHP ${{ matrix.php }})
steps:
- name: Checkout package repository
uses: actions/checkout@v4
with:
path: laravel-microscope
- name: Checkout Laravel test application
uses: actions/checkout@v4
with:
repository: imanghafoori1/laravel-microscope-tester
path: laravel-app
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml, ctype, iconv, intl, libxml, bcmath, tokenizer, json
# coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies for Laravel 11
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-laravel11-php-${{ matrix.php }}-${{ hashFiles('laravel-app/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-laravel11-php-${{ matrix.php }}-
${{ runner.os }}-composer-
- name: Configure Laravel 11 and local package
timeout-minutes: 2
run: |
cd laravel-app
# First, install without updating
composer install --no-interaction --no-progress
# Remove Laravel 12 and install Laravel 11
composer remove laravel/framework --no-interaction 2>/dev/null || true
composer require "laravel/framework:^11.0" --no-interaction --no-update
# Update composer to use Laravel 11 dependencies
composer update --no-interaction --with-all-dependencies
# Remove any existing version of the package
composer remove imanghafoori/laravel-microscope --no-interaction 2>/dev/null || true
# Add local package repository
composer config repositories.local-microscope '{"type": "path", "url": "../laravel-microscope", "options": {"symlink": true}}'
# Require local package
composer require "imanghafoori/laravel-microscope:@dev" --no-interaction
- name: Verify installations
run: |
cd laravel-app
echo "=== Installed Versions ==="
composer show laravel/framework 2>/dev/null || echo "laravel/framework not installed"
composer show phpunit/phpunit 2>/dev/null || echo "phpunit/phpunit not installed"
composer show imanghafoori/laravel-microscope 2>/dev/null || echo "Package not found"
echo "=========================="
- name: Prepare Laravel environment
run: |
cd laravel-app
# Create .env if not exists
if [ ! -f ".env" ]; then
cp .env.example .env 2>/dev/null || echo "APP_NAME=Test\nAPP_ENV=testing\nAPP_KEY=" > .env
fi
# Generate app key
php artisan key:generate --force 2>/dev/null || true
# Clear caches
php artisan config:clear 2>/dev/null || true
php artisan cache:clear 2>/dev/null || true
- name: Run tests with Laravel 11
if: always()
run: |
cd laravel-app
# Check if there are test files mentioning microscope
echo "running tests..."
php artisan test --colors=always 2>/dev/null || false