Skip to content

Commit 7d08382

Browse files
authored
Merge pull request #1336 from samsonasik/migrate-deptrac-to-structarmed
chore: migrate from deptrac to structarmed
2 parents 9d6e1e5 + 39c14f6 commit 7d08382

7 files changed

Lines changed: 109 additions & 184 deletions

File tree

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/.gitignore export-ignore
88
/.php-cs-fixer.dist.php export-ignore
99
/composer-unused.php export-ignore
10-
/deptrac.yml export-ignore
10+
/structarmed.php export-ignore
1111
/infection.json.dist export-ignore
1212
/mkdocs.yml export-ignore
1313
/phpstan-baseline.php export-ignore

‎.github/workflows/deptrac.yml‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎.github/workflows/structarmed.yml‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: StructArmed
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
paths:
8+
- '**.php'
9+
- 'composer.*'
10+
- 'structarmed.php'
11+
- '.github/workflows/structarmed.yml'
12+
push:
13+
branches:
14+
- develop
15+
paths:
16+
- '**.php'
17+
- 'composer.*'
18+
- 'structarmed.php'
19+
- '.github/workflows/structarmed.yml'
20+
workflow_call:
21+
inputs:
22+
php-version:
23+
required: false
24+
type: string
25+
default: '8.2'
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
build:
32+
name: Dependency Tracing
33+
runs-on: ubuntu-latest
34+
if: (! contains(github.event.head_commit.message, '[ci skip]'))
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
39+
40+
- name: Set up PHP
41+
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2.37.1
42+
with:
43+
php-version: ${{ inputs['php-version'] }}
44+
tools: composer
45+
extensions: intl, json, mbstring, xml
46+
coverage: none
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Get composer cache directory
51+
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
52+
53+
- name: Cache composer dependencies
54+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae #v5.0.5
55+
with:
56+
path: ${{ env.COMPOSER_CACHE_FILES_DIR }}
57+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
58+
restore-keys: ${{ runner.os }}-composer-
59+
60+
- name: Install dependencies
61+
run: |
62+
if [ -f composer.lock ]; then
63+
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
64+
else
65+
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
66+
fi
67+
68+
- name: Structarmed Cache
69+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
70+
with:
71+
path: /tmp/structarmed
72+
key: ${{ runner.os }}-structarmed-${{ github.run_id }}
73+
restore-keys: ${{ runner.os }}-structarmed-
74+
75+
- run: mkdir -p /tmp/structarmed
76+
77+
- name: Run static analysis
78+
run: vendor/bin/structarmed analyze

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PHP-CS-Fixer](https://github.com/codeigniter4/shield/actions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/codeigniter4/shield/actions/workflows/phpcsfixer.yml)
66
[![Rector](https://github.com/codeigniter4/shield/actions/workflows/rector.yml/badge.svg)](https://github.com/codeigniter4/shield/actions/workflows/rector.yml)
77
[![Psalm](https://github.com/codeigniter4/shield/actions/workflows/psalm.yml/badge.svg)](https://github.com/codeigniter4/shield/actions/workflows/psalm.yml)
8-
[![Architecture](https://github.com/codeigniter4/shield/workflows/Deptrac/badge.svg)](https://github.com/codeigniter4/shield/actions/workflows/deptrac.yml)
8+
[![Architecture](https://github.com/codeigniter4/shield/workflows/StructArmed/badge.svg)](https://github.com/codeigniter4/shield/actions/workflows/structarmed.yml)
99
[![Coverage Status](https://coveralls.io/repos/github/codeigniter4/shield/badge.svg?branch=develop)](https://coveralls.io/github/codeigniter4/shield?branch=develop)
1010

1111
Shield is the official authentication and authorization framework for CodeIgniter 4.

‎composer.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"codeigniter4/settings": "^2.1"
3030
},
3131
"require-dev": {
32+
"boundwize/structarmed": "^0.11.0",
3233
"codeigniter/phpstan-codeigniter": "^1.3",
3334
"codeigniter4/devkit": "^1.3",
3435
"codeigniter4/framework": ">=4.3.5 <4.5.0 || ^4.5.1",
@@ -86,7 +87,7 @@
8687
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff",
8788
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff",
8889
"deduplicate": "phpcpd app/ src/ --exclude src/Database/Migrations/2020-12-28-223112_create_auth_tables.php --exclude src/Authentication/Authenticators/HmacSha256.php",
89-
"inspect": "deptrac analyze --cache-file=build/deptrac.cache",
90+
"inspect": "vendor/bin/structarmed analyze",
9091
"mutate": "infection --threads=2 --skip-initial-tests --coverage=build/phpunit",
9192
"sa": "@analyze",
9293
"style": "@cs-fix",

‎deptrac.yaml‎

Lines changed: 0 additions & 158 deletions
This file was deleted.

‎structarmed.php‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Boundwize\StructArmed\Architecture;
6+
use Boundwize\StructArmed\Preset\Preset;
7+
use Boundwize\StructArmed\Preset\Presets\Psr4Preset;
8+
9+
return Architecture::define()
10+
->skip([
11+
Psr4Preset::CLASSES_MUST_MATCH_COMPOSER => [
12+
__DIR__ . '/src/Database/Migrations',
13+
],
14+
])
15+
->cacheDirectory(is_dir('/tmp') ? '/tmp/structarmed' : null)
16+
->withPreset(Preset::PSR4())
17+
->layerPattern('Model', '/^CodeIgniter\\\\Shield\\\\.*Model$/')
18+
->layerPattern('Controller', '/^CodeIgniter\\\\Shield\\\\Controllers\\\\.*$/')
19+
->layerPattern('Config', '/^CodeIgniter\\\\Shield\\\\Config\\\\.*$/', '/^.*Services$/')
20+
->layerPattern('Entity', '/^CodeIgniter\\\\Shield\\\\Entities\\\\.*$/')
21+
->layerPattern('Service', '/^.*Services$/')
22+
->ruleset([
23+
'Entity' => ['Config', 'Model', 'Service'],
24+
'Config' => ['Model', 'Service'],
25+
'Model' => ['Config', 'Entity', 'Service'],
26+
'Service' => ['Config'],
27+
]);

0 commit comments

Comments
 (0)