Skip to content

Commit

Permalink
feat: make package compatible with Laravel 11 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkaitzgarro committed Apr 16, 2024
1 parent 55ecf60 commit fd81143
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 96 deletions.
78 changes: 40 additions & 38 deletions .github/workflows/run-lint.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
name: Lint

on: [push, pull_request]
on:
- push
- pull_request

jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.0, 8.1, 8.2]

name: PHP${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-php${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Execute linters
run: php vendor/bin/php-cs-fixer fix --dry-run --diff
lint:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.0, 8.1, 8.2]

name: PHP${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-php${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Execute linters
run: php vendor/bin/php-cs-fixer fix --dry-run --diff
112 changes: 60 additions & 52 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
name: Unit tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
unit-tests:
runs-on: ubuntu-latest
unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 10.*
php: 8.0
strategy:
matrix:
php: [8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*, 11.*]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

name: PHP${{ matrix.php }} - L${{ matrix.laravel }}
name: PHP${{ matrix.php }} - L${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v1
steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}-php${{ matrix.php }}-L${{ matrix.laravel }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}-php${{ matrix.php }}
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}-php${{ matrix.php }}-L${{ matrix.laravel }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}-php${{ matrix.php }}
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.php }}
${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
- name: Execute tests
uses: paambaati/codeclimate-action@v2.7.4
env:
CC_TEST_REPORTER_ID: 23639f09f4ef515ddb5fea9baf90f9f5cd9bb5e0801cf1dc062d993a3d70d3eb
with:
coverageCommand: vendor/bin/codecept run --xml test_report.xml --coverage --coverage-html --coverage-xml
coverageLocations: |
${{github.workspace}}/tests/_output/coverage.xml:clover
- name: Execute tests
uses: paambaati/codeclimate-action@v2.7.4
env:
CC_TEST_REPORTER_ID: 23639f09f4ef515ddb5fea9baf90f9f5cd9bb5e0801cf1dc062d993a3d70d3eb
with:
coverageCommand: vendor/bin/codecept run --xml test_report.xml --coverage --coverage-html --coverage-xml
coverageLocations: |
${{github.workspace}}/tests/_output/coverage.xml:clover
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
"require": {
"php": "^8.0.2",
"http-interop/http-factory-guzzle": "^1.0",
"illuminate/database": "^8|^9|^10.0",
"illuminate/http": "^8|^9|^10.0",
"illuminate/routing": "^8|^9|^10.0",
"illuminate/support": "^8|^9|^10.0",
"illuminate/contracts": "^8|^9|^10.0",
"illuminate/database": "^8|^9|^10.0|^11.0",
"illuminate/http": "^8|^9|^10.0|^11.0",
"illuminate/routing": "^8|^9|^10.0|^11.0",
"illuminate/support": "^8|^9|^10.0|^11.0",
"illuminate/contracts": "^8|^9|^10.0|^11.0",
"jasny/persist-sql-query": "^2.0",
"nipwaayoni/elastic-apm-php-agent": "^8.0"
},
"require-dev": {
"codeception/codeception": "^5",
"codeception/mockery-module": "^0.5",
"friendsofphp/php-cs-fixer": "^3.0",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"php-http/guzzle7-adapter": "^1.0.0",
"symfony/service-contracts": "^2.0|^3.0"
},
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/Collectors/JobCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public function testJobProcessingListenerIgnored()
$this->agentMock->shouldNotReceive('startTransaction');
$this->agentMock->shouldNotReceive('getTransaction');

// For Laravel 11+
if (class_exists('\Illuminate\Support\Facades\Context')) {
Illuminate\Support\Facades\Context::shouldReceive('hydrate');
$this->jobMock->shouldReceive('payload');
}

$this->dispatcher->dispatch(new JobProcessing('test', $this->jobMock));
}

Expand Down

0 comments on commit fd81143

Please sign in to comment.