Skip to content

Commit db066f4

Browse files
author
farhadzand
committed
remove mongodb driver
1 parent 56bbe3b commit db066f4

File tree

4 files changed

+212
-56
lines changed

4 files changed

+212
-56
lines changed

.github/workflows/coding-standards.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313

1414
jobs:
1515
lint:
16-
name: PHP CS & Static Analysis
16+
name: PHP CS Check
1717
runs-on: ubuntu-latest
1818

1919
steps:
@@ -23,33 +23,29 @@ jobs:
2323
- name: Setup PHP
2424
uses: shivammathur/setup-php@v2
2525
with:
26-
php-version: 8.2
26+
php-version: 8.4
2727
extensions: dom, curl, libxml, mbstring, zip, pcntl, bcmath, intl
2828
coverage: none
2929
tools: composer:v2
3030

3131
- name: Setup problem matchers
3232
run: |
3333
echo "::add-matcher::/opt/hostedtoolcache/php.json"
34-
shell: /usr/bin/bash -e {0}
3534
3635
- name: Get composer cache directory
3736
id: composer-cache
3837
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3938

4039
- name: Cache dependencies
41-
uses: actions/cache@v3
40+
uses: actions/cache@v4
4241
with:
4342
path: ${{ steps.composer-cache.outputs.dir }}
44-
key: ${{ runner.os }}-composer-8.2-${{ hashFiles('**/composer.json') }}
43+
key: ${{ runner.os }}-composer-8.4-${{ hashFiles('**/composer.json') }}
4544
restore-keys: |
46-
${{ runner.os }}-composer-8.2-
45+
${{ runner.os }}-composer-8.4-
4746
4847
- name: Install dependencies
4948
run: composer update --prefer-dist --no-interaction --no-progress
5049

5150
- name: Check code style with Laravel Pint
52-
run: vendor/bin/pint --test
53-
54-
- name: Run PHPStan
55-
run: vendor/bin/phpstan analyse
51+
run: vendor/bin/pint --test
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Laravel Integration Test
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
schedule:
9+
- cron: '0 0 * * 0' # Run weekly on Sundays
10+
11+
env:
12+
COMPOSER_PROCESS_TIMEOUT: 0
13+
COMPOSER_NO_INTERACTION: 1
14+
COMPOSER_NO_AUDIT: 1
15+
16+
jobs:
17+
integration-test:
18+
name: Laravel Integration - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
php: [8.3, 8.4]
25+
laravel: [11.*, 12.*]
26+
exclude:
27+
- php: 8.3
28+
laravel: 12.*
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl
39+
coverage: none
40+
tools: composer:v2
41+
42+
- name: Create Laravel app
43+
run: |
44+
composer create-project laravel/laravel:${{ matrix.laravel }} laravel-app --prefer-dist --no-interaction
45+
cd laravel-app
46+
composer require laravel/pint --dev
47+
48+
- name: Install package from path
49+
run: |
50+
cd laravel-app
51+
composer config repositories.local path "../"
52+
composer require iamfarhad/laravel-audit-log:@dev --no-interaction
53+
54+
- name: Publish config
55+
run: |
56+
cd laravel-app
57+
php artisan vendor:publish --provider="iamfarhad\\LaravelAuditLog\\AuditLoggerServiceProvider"
58+
59+
- name: Create sample migration and model
60+
run: |
61+
cd laravel-app
62+
php artisan make:model TestModel -m
63+
64+
- name: Add Auditable trait to model
65+
run: |
66+
cd laravel-app
67+
cat > app/Models/TestModel.php << 'EOL'
68+
<?php
69+
70+
declare(strict_types=1);
71+
72+
namespace App\Models;
73+
74+
use Illuminate\Database\Eloquent\Factories\HasFactory;
75+
use Illuminate\Database\Eloquent\Model;
76+
use iamfarhad\LaravelAuditLog\Traits\Auditable;
77+
78+
final class TestModel extends Model
79+
{
80+
use HasFactory;
81+
use Auditable;
82+
83+
protected $fillable = ['name'];
84+
}
85+
EOL
86+
87+
- name: Update migration
88+
run: |
89+
cd laravel-app
90+
find database/migrations -name "*_create_test_models_table.php" -exec sed -i 's/Schema::create/\$table->string("name")->nullable();\n Schema::create/g' {} \;
91+
92+
- name: Run migrations
93+
run: |
94+
cd laravel-app
95+
php artisan migrate
96+
97+
- name: Create basic test
98+
run: |
99+
cd laravel-app
100+
cat > tests/Feature/AuditLogTest.php << 'EOL'
101+
<?php
102+
103+
declare(strict_types=1);
104+
105+
namespace Tests\Feature;
106+
107+
use App\Models\TestModel;
108+
use iamfarhad\LaravelAuditLog\Models\AuditLog;
109+
use Tests\TestCase;
110+
111+
final class AuditLogTest extends TestCase
112+
{
113+
public function test_it_can_create_audit_log_when_model_is_created(): void
114+
{
115+
$model = TestModel::create(['name' => 'Test']);
116+
117+
$this->assertDatabaseHas('audit_logs', [
118+
'auditable_type' => TestModel::class,
119+
'auditable_id' => $model->id,
120+
'event' => 'created',
121+
]);
122+
}
123+
124+
public function test_it_can_create_audit_log_when_model_is_updated(): void
125+
{
126+
$model = TestModel::create(['name' => 'Test']);
127+
$model->update(['name' => 'Updated']);
128+
129+
$this->assertDatabaseHas('audit_logs', [
130+
'auditable_type' => TestModel::class,
131+
'auditable_id' => $model->id,
132+
'event' => 'updated',
133+
]);
134+
135+
$log = AuditLog::where('auditable_id', $model->id)
136+
->where('event', 'updated')
137+
->first();
138+
139+
$this->assertNotNull($log);
140+
$this->assertIsArray($log->old_values);
141+
$this->assertIsArray($log->new_values);
142+
$this->assertEquals('Test', $log->old_values['name']);
143+
$this->assertEquals('Updated', $log->new_values['name']);
144+
}
145+
}
146+
EOL
147+
148+
- name: Run tests
149+
run: |
150+
cd laravel-app
151+
php artisan test

.github/workflows/phpstan.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: PHPStan Static Analysis
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
COMPOSER_PROCESS_TIMEOUT: 0
11+
COMPOSER_NO_INTERACTION: 1
12+
COMPOSER_NO_AUDIT: 1
13+
14+
jobs:
15+
phpstan:
16+
name: Static Analysis
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: 8.4
27+
extensions: dom, curl, libxml, mbstring, zip, pcntl, bcmath, intl
28+
coverage: none
29+
ini-values: memory_limit=512M
30+
tools: composer:v2
31+
32+
- name: Get composer cache directory
33+
id: composer-cache
34+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ steps.composer-cache.outputs.dir }}
40+
key: ${{ runner.os }}-composer-8.4-${{ hashFiles('**/composer.json') }}
41+
restore-keys: |
42+
${{ runner.os }}-composer-8.4-
43+
44+
- name: Install dependencies
45+
run: composer update --prefer-dist --no-interaction --no-progress
46+
47+
- name: Run PHPStan
48+
run: vendor/bin/phpstan analyse

.github/workflows/tests.yml

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
strategy:
21-
fail-fast: false # Changed to false to see all failures
21+
fail-fast: false
2222
matrix:
2323
php: [8.2, 8.3, 8.4]
2424
laravel: [11.*, 12.*]
@@ -40,29 +40,22 @@ jobs:
4040
uses: shivammathur/setup-php@v2
4141
with:
4242
php-version: ${{ matrix.php }}
43-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, exif, iconv
43+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl
4444
coverage: xdebug
45-
ini-values: error_reporting=E_ALL
45+
ini-values: memory_limit=256M
4646
tools: composer:v2
4747

48-
- name: Verify PHP and extensions
49-
run: |
50-
php -v
51-
php -m
52-
php --ini
53-
5448
- name: Setup problem matchers
5549
run: |
5650
echo "::add-matcher::/opt/hostedtoolcache/php.json"
5751
echo "::add-matcher::/opt/hostedtoolcache/phpunit.json"
58-
shell: /usr/bin/bash -e {0}
5952
6053
- name: Get composer cache directory
6154
id: composer-cache
6255
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
6356

6457
- name: Cache dependencies
65-
uses: actions/cache@v3
58+
uses: actions/cache@v4
6659
with:
6760
path: ${{ steps.composer-cache.outputs.dir }}
6861
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}-${{ matrix.stability }}
@@ -87,41 +80,9 @@ jobs:
8780
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
8881
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
8982
90-
- name: List installed packages
91-
run: composer show
92-
93-
- name: Check for PHPUnit
94-
run: |
95-
if [ -f vendor/bin/phpunit ]; then
96-
echo "PHPUnit exists at vendor/bin/phpunit"
97-
ls -la vendor/bin/phpunit
98-
else
99-
echo "PHPUnit not found!"
100-
ls -la vendor/bin/
101-
fi
102-
103-
- name: Check for tests directory
104-
run: |
105-
if [ -d tests ]; then
106-
echo "Tests directory exists"
107-
ls -la tests
108-
else
109-
echo "Tests directory not found!"
110-
fi
111-
11283
- name: Run PHPUnit tests
113-
run: |
114-
if [ -f vendor/bin/phpunit ]; then
115-
vendor/bin/phpunit --coverage-text --verbose
116-
else
117-
echo "PHPUnit not found, skipping tests"
118-
exit 1
119-
fi
84+
run: vendor/bin/phpunit --coverage-text --verbose
12085

12186
- name: Run PHP Static Analysis
122-
run: |
123-
if [ -f vendor/bin/phpstan ]; then
124-
vendor/bin/phpstan analyse
125-
else
126-
echo "PHPStan not found, skipping static analysis"
127-
fi
87+
if: ${{ matrix.stability == 'prefer-stable' }}
88+
run: vendor/bin/phpstan analyse

0 commit comments

Comments
 (0)