Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/test-structarmed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# When a PR is opened or a push is made, perform
# a static analysis check on the code using Structarmed.
name: Structarmed

on:
pull_request:
branches:
- 'develop'
- '4.*'
paths:
- 'app/**.php'
- 'system/**.php'
- 'tests/**.php'
- 'utils/**.php'
- '.github/workflows/test-structarmed.yml'
- composer.json
- structarmed.php
- '**.neon.dist'

push:
branches:
- 'develop'
- '4.*'
paths:
- 'app/**.php'
- 'system/**.php'
- 'tests/**.php'
- 'utils/**.php'
- '.github/workflows/test-structarmed.yml'
- composer.json
- structarmed.php
- '**.neon.dist'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
name: PHP ${{ matrix.php-version }} Analyze code (Structarmed)
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php-version:
- '8.2'
include:
- php-version: '8.5'
composer-option: '--ignore-platform-req=php'

steps:
- name: Checkout base branch for PR
if: github.event_name == 'pull_request'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.base_ref }}

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: ${{ matrix.php-version }}
extensions: intl

- name: Use latest Composer
run: composer self-update

- name: Validate composer.json
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer update --ansi --no-interaction ${{ matrix.composer-option }}

- name: Structarmed Cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /tmp/structarmed
key: ${{ runner.os }}-structarmed-${{ github.run_id }}
restore-keys: ${{ runner.os }}-structarmed-

- run: mkdir -p /tmp/structarmed

- name: Run static analysis
run: vendor/bin/structarmed analyze
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"psr/log": "^3.0"
},
"require-dev": {
"boundwize/structarmed": "0.3.4",
"codeigniter/phpstan-codeigniter": "^1.5",
"fakerphp/faker": "^1.24",
"kint-php/kint": "^6.1",
Expand Down
25 changes: 25 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
use Boundwize\StructArmed\Preset\Presets\Psr4Preset;

return Architecture::define()
->skip([
Psr4Preset::CLASSES_MUST_MATCH_COMPOSER => [
__DIR__ . '/tests/system/Config/fixtures',
],
])
->cacheDirectory(is_dir('/tmp') ? '/tmp/structarmed' : null)
->withPreset(Preset::PSR4());
Loading