Skip to content

Commit 444d55e

Browse files
committed
create workflow
1 parent ef79b22 commit 444d55e

File tree

6 files changed

+90
-10
lines changed

6 files changed

+90
-10
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
ci:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Cache Composer packages
21+
id: composer-cache
22+
uses: actions/cache@v3
23+
with:
24+
path: vendor
25+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-php-
28+
29+
- name: Install dependencies
30+
run: composer install --prefer-dist --no-progress
31+
32+
- name: Run ci checks
33+
run: composer ci

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@
1616
}
1717
},
1818
"scripts": {
19+
"lint": "XDEBUG_MODE=off pint --test",
20+
"lint.fix": "XDEBUG_MODE=off pint",
21+
"stan": "XDEBUG_MODE=off phpstan analyse --ansi --memory-limit=-1",
22+
"test.arch": "XDEBUG_MODE=off pest --testsuite=Architecture",
23+
"test.unit": "XDEBUG_MODE=off pest --testsuite=Unit",
24+
"test.feature": "XDEBUG_MODE=coverage pest --testsuite=Feature --coverage --min=90",
25+
"rector": "XDEBUG_MODE=off rector process --dry-run",
26+
"rector.fix": "XDEBUG_MODE=off rector process",
27+
"ci": [
28+
"@lint",
29+
"@stan",
30+
"@rector"
31+
],
32+
"ci.fix": [
33+
"@rector.fix",
34+
"@lint.fix"
35+
]
1936
},
2037
"extra": {
2138
"laravel": {

phpstan.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
- vendor/nesbot/carbon/extension.neon
4+
5+
parameters:
6+
7+
paths:
8+
- src/
9+
10+
level: max

rector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/config',
10+
__DIR__.'/src',
11+
])
12+
// uncomment to reach your current PHP version
13+
// ->withPhpSets()
14+
->withTypeCoverageLevel(0)
15+
->withDeadCodeLevel(0)
16+
->withCodeQualityLevel(0);

src/CodebuddyServiceProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function register()
1212
// Register bindings if any
1313
}
1414

15-
public function boot()
15+
public function boot(): void
1616
{
1717
if ($this->app->runningInConsole()) {
1818
$this->commands([
@@ -25,10 +25,13 @@ public function boot()
2525
}
2626
}
2727

28-
public function provides()
28+
/**
29+
* @return array<string>
30+
*/
31+
public function provides(): array
2932
{
3033
return [
3134
Configure::class,
3235
];
3336
}
34-
}
37+
}

src/Commands/Configure.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
7-
use function Termwind\render;
87

98
class Configure extends Command
109
{
@@ -14,7 +13,7 @@ class Configure extends Command
1413

1514
public function handle(): void
1615
{
17-
$filesystem = new Filesystem();
16+
$filesystem = new Filesystem;
1817

1918
$configs = [
2019
'rector.php',
@@ -23,18 +22,20 @@ public function handle(): void
2322
];
2423

2524
foreach ($configs as $file) {
26-
$sourceFile = __DIR__ . "/../../config/laravel/{$file}";
25+
$sourceFile = __DIR__."/../../config/laravel/{$file}";
2726
$destinationFile = base_path($file);
2827

29-
if (!$filesystem->exists($sourceFile)) {
28+
if (! $filesystem->exists($sourceFile)) {
3029
$this->error("Source file not found: {$sourceFile}");
30+
3131
continue;
3232
}
3333

3434
if ($filesystem->exists($destinationFile)) {
3535
$overwrite = $this->confirmOverwrite($destinationFile);
36-
if (!$overwrite) {
36+
if (! $overwrite) {
3737
$this->warn("Skipped: {$destinationFile} already exists");
38+
3839
continue;
3940
}
4041
}
@@ -45,12 +46,12 @@ public function handle(): void
4546
}
4647
}
4748

48-
private function confirmOverwrite(string $file): bool
49+
private function confirmOverwrite(string $file): mixed
4950
{
5051
$this->info(
5152
sprintf('%s already exists. Do you want to overwrite it?', $file)
5253
);
5354

54-
return $this->ask('Overwrite?', false);
55+
return $this->ask('Overwrite?');
5556
}
5657
}

0 commit comments

Comments
 (0)