Skip to content

Commit 37ee0ee

Browse files
authored
chore: add Structarmed to QA (#10180)
* chore: Add Structarmed to QA * chore: use latest structarmed 0.3.1 * chore: bump structarmed to 0.3.2 * bump structarmed to 0.3.3 to properly fix cache on CI * chore: bump to structarmed 0.3.4 to fix very long list progressbar * chore: bump to structarmed 0.3.5 * chore: bump structarmed to 0.4.0 * chore: remove ignore platform php 8.5 on test-structarmed workflow * chore: use php 8.5 in php-versions * use tools: composer under Setup PHP
1 parent 83d509c commit 37ee0ee

3 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
- '8.5'
51+
52+
steps:
53+
- name: Checkout base branch for PR
54+
if: github.event_name == 'pull_request'
55+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
56+
with:
57+
ref: ${{ github.base_ref }}
58+
59+
- name: Checkout
60+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
61+
62+
- name: Setup PHP
63+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
64+
with:
65+
php-version: ${{ matrix.php-version }}
66+
extensions: intl
67+
tools: composer
68+
69+
- name: Validate composer.json
70+
run: composer validate --strict
71+
72+
- name: Get composer cache directory
73+
id: composer-cache
74+
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
75+
76+
- name: Cache dependencies
77+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
78+
with:
79+
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
80+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
81+
restore-keys: ${{ runner.os }}-composer-
82+
83+
- name: Install dependencies
84+
run: composer update --ansi --no-interaction ${{ matrix.composer-option }}
85+
86+
- name: Structarmed Cache
87+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
88+
with:
89+
path: /tmp/structarmed
90+
key: ${{ runner.os }}-structarmed-${{ github.run_id }}
91+
restore-keys: ${{ runner.os }}-structarmed-
92+
93+
- run: mkdir -p /tmp/structarmed
94+
95+
- name: Run static analysis
96+
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.4.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)