Skip to content

Commit c3f0be4

Browse files
committed
chore: Add Structarmed to QA
1 parent 7446d0b commit c3f0be4

3 files changed

Lines changed: 126 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# When a PR is opened or a push is made, perform
2+
# a static analysis check on the code using Structarmed.
3+
name: Structarmed
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'develop'
9+
- '4.*'
10+
paths:
11+
- 'app/**.php'
12+
- 'system/**.php'
13+
- 'tests/**.php'
14+
- 'utils/**.php'
15+
- '.github/workflows/test-structarmed.yml'
16+
- composer.json
17+
- structarmed.php
18+
- '**.neon.dist'
19+
20+
push:
21+
branches:
22+
- 'develop'
23+
- '4.*'
24+
paths:
25+
- 'app/**.php'
26+
- 'system/**.php'
27+
- 'tests/**.php'
28+
- 'utils/**.php'
29+
- '.github/workflows/test-structarmed.yml'
30+
- composer.json
31+
- structarmed.php
32+
- '**.neon.dist'
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
36+
cancel-in-progress: true
37+
38+
permissions:
39+
contents: read
40+
41+
jobs:
42+
build:
43+
name: PHP ${{ matrix.php-version }} Analyze code (Structarmed)
44+
runs-on: ubuntu-24.04
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
php-version:
49+
- '8.2'
50+
include:
51+
- php-version: '8.5'
52+
composer-option: '--ignore-platform-req=php'
53+
54+
steps:
55+
- name: Checkout base branch for PR
56+
if: github.event_name == 'pull_request'
57+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
58+
with:
59+
ref: ${{ github.base_ref }}
60+
61+
- name: Checkout
62+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
63+
64+
- name: Setup PHP
65+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
66+
with:
67+
php-version: ${{ matrix.php-version }}
68+
extensions: intl
69+
70+
- name: Use latest Composer
71+
run: composer self-update
72+
73+
- name: Validate composer.json
74+
run: composer validate --strict
75+
76+
- name: Get composer cache directory
77+
id: composer-cache
78+
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
79+
80+
- name: Cache dependencies
81+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
82+
with:
83+
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
84+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
85+
restore-keys: ${{ runner.os }}-composer-
86+
87+
- name: Install dependencies
88+
run: composer update --ansi --no-interaction ${{ matrix.composer-option }}
89+
90+
- name: Structarmed Cache
91+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
92+
with:
93+
path: /tmp/structarmed
94+
key: ${{ runner.os }}-structarmed-${{ github.run_id }}
95+
restore-keys: ${{ runner.os }}-structarmed-
96+
97+
- run: mkdir -p /tmp/structarmed
98+
99+
- name: Run static analysis
100+
run: vendor/bin/structarmed analyze

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20+
"boundwize/structarmed": "0.3.0",
2021
"codeigniter/phpstan-codeigniter": "^1.5",
2122
"fakerphp/faker": "^1.24",
2223
"kint-php/kint": "^6.1",

structarmed.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of CodeIgniter 4 framework.
7+
*
8+
* (c) CodeIgniter Foundation <admin@codeigniter.com>
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
use Boundwize\StructArmed\Architecture;
15+
use Boundwize\StructArmed\Preset\Preset;
16+
use Boundwize\StructArmed\Preset\Presets\Psr4Preset;
17+
18+
return Architecture::define()
19+
->skip([
20+
Psr4Preset::CLASSES_MUST_MATCH_COMPOSER => [
21+
__DIR__ . '/tests/system/Config/fixtures',
22+
],
23+
])
24+
->cacheDirectory(is_dir('/tmp') ? '/tmp/structarmed' : null)
25+
->withPreset(Preset::PSR4());

0 commit comments

Comments
 (0)