Skip to content

Commit

Permalink
Merge pull request #28 from yajra/L11
Browse files Browse the repository at this point in the history
feat: Laravel 11
  • Loading branch information
yajra committed Mar 17, 2024
2 parents 15b2cd1 + d9edb42 commit 5191062
Show file tree
Hide file tree
Showing 27 changed files with 485 additions and 159 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Continuous Integration"

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
phpunit:

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.2, 8.3]
stability: [prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, memcached
tools: composer:v2
coverage: none

- name: Setup Memcached
uses: niden/actions-memcached@v7

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/pest
2 changes: 1 addition & 1 deletion .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
#issue-comment: |
# This issue has been locked since it has been closed for more than 14 days.
issue-lock-reason: ""
process-only: "issues"
process-only: "issues"
20 changes: 20 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PHP Linting
on:
pull_request:
push:
branches:
- master
jobs:
phplint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "laravel-pint"
uses: aglipanci/laravel-pint-action@2.0.0
with:
preset: laravel
verboseMode: true
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "fix: pint"

9 changes: 5 additions & 4 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * *"
- cron: "0 0 * * *"

jobs:
close-issues:
Expand All @@ -12,11 +12,12 @@ jobs:
steps:
- uses: actions/stale@v5
with:
exempt-issue-labels: "bug,security,enhancement,pinned"
days-before-issue-stale: 30
days-before-issue-close: 14
days-before-issue-close: 7
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days."
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Static Analysis"

on:
push:
paths:
- .github/workflows/static-analysis.yml
- composer.*
- phpstan.neon.dist
- src/**
- tests/**

pull_request:
paths:
- .github/workflows/static-analysis.yml
- composer.*
- phpstan.neon.dist
- src/**
- tests/**

schedule:
- cron: '0 0 * * *'

jobs:
static-analysis-phpstan:

name: "Static Analysis with PHPStan"
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.2, 8.3]
stability: [prefer-stable]

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

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

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan --error-format=table"
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build
build/
composer.lock
docs
vendor
.idea
docs/
vendor/
.idea/
.phpunit.cache/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All Notable changes to `laravel-auditable` will be documented in this file.

## [Unreleased]

- Laravel 11 Support
- Implement static analysis tools
- Add GitHub Actions for CI/CD
- Add Pint and Rector
- Upgrade code to PHP 8.2 coding standards
- Add tests using PestPHP

## v4.6.0 - 2023-04-11

- feat: Add withDefault on deleter #26
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]

[![Continuous Integration](https://github.com/yajra/laravel-auditable/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/yajra/laravel-auditable/actions/workflows/continuous-integration.yml)
[![Static Analysis](https://github.com/yajra/laravel-auditable/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/yajra/laravel-auditable/actions/workflows/static-analysis.yml)
[![Total Downloads][ico-downloads]][link-downloads]

Laravel Auditable is a simple Laravel auditing package for your Eloquent Model.
This package automatically inserts/updates an audit log on your table on who created and last updated the record.

## Laravel Version Compatibility

| Laravel | Package |
|:---------|:--------|
| 5.x-10.x | 4.x |
| 11.x | 11.x |

## Install via Composer

```bash
composer require yajra/laravel-auditable
composer require yajra/laravel-auditable:^11
```

## Publish config file
Expand Down
45 changes: 35 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@
}
],
"require": {
"php": ">=7.2",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^6.0|^7.0|^8.0|^9.0|^10.0"
"php": "^8.2",
"illuminate/support": "^11.0",
"illuminate/database": "^11.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5|^8.4|^9.0|^10.0"
"larastan/larastan": "^2.9.1",
"laravel/pint": "^1.14",
"rector/rector": "^1.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.3"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"autoload": {
"psr-4": {
Expand All @@ -31,20 +41,35 @@
},
"autoload-dev": {
"psr-4": {
"Yajra\\Auditable\\Test\\": "tests"
"Yajra\\Auditable\\Tests\\": "tests"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "11.x-dev"
},
"laravel": {
"providers": [
"Yajra\\Auditable\\AuditableServiceProvider"
]
}
}
},
"scripts": {
"test": "./vendor/bin/pest",
"pint": "./vendor/bin/pint",
"rector": "./vendor/bin/rector",
"stan": "./vendor/bin/phpstan analyse --memory-limit=2G --ansi --no-progress --no-interaction --configuration=phpstan.neon.dist",
"pr": [
"@rector",
"@pint",
"@stan",
"@test"
]
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/yajra"
}
]
}
15 changes: 15 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
includes:
- ./vendor/larastan/larastan/extension.neon

parameters:

paths:
- src

level: max

ignoreErrors:

excludePaths:

checkMissingIterableValueType: true
17 changes: 0 additions & 17 deletions phpunit.xml

This file was deleted.

20 changes: 20 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="DB_CONNECTION" value="testing"/>
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "laravel"
}
22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,
]);
};
Loading

0 comments on commit 5191062

Please sign in to comment.