Skip to content
Merged
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
87 changes: 87 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: PHPCS

on:
pull_request:
branches: [ "main", "develop" ]
# Manual runs from the Actions tab
workflow_dispatch:

jobs:
tests:
name: "PHP ${{ matrix.php }} (deps: ${{ matrix.deps }})"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [ "8.2" ]
deps: [ "stable" ]

env:
# Typical CI4 testing env values
APP_ENV: testing
CI_ENVIRONMENT: testing

steps:
# --- 1. Checkout code ---------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4

# --- 2. Setup PHP -------------------------------------------------------
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, json, pdo_mysql, sqlite3
ini-values: |
memory_limit=512M
coverage: none
tools: composer

# --- 3. Cache Composer dependencies ------------------------------------
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer-

# --- 4. Install dependencies -------------------------------------------
- name: Install Composer dependencies
run: |
if [ "${{ matrix.deps }}" = "lowest" ]; then
composer update --prefer-lowest --no-interaction --no-progress
else
composer install --no-interaction --no-progress --prefer-dist
fi

# --- 5. Prepare .env for CodeIgniter 4----------------------
# name it `.env.github-ci`
- name: Prepare .env
run: |
if [ -f .env.github-ci ]; then
cp .env.github-ci .env
elif [ -f env ]; then
cp env .env
fi

# --- 6. Coding standards (PHPCS) - optional ----------------------------
- name: Run PHPCS (if configured)
if: ${{ hashFiles('phpcs.xml*') != '' }}
run: |
if [ -f vendor/bin/phpcs ]; then
vendor/bin/phpcs
fi

# --- 7. PHP-CBF (dry-run) - optional -----------------------------
- name: Run PHP-CBF (dry-run, if configured)
if: ${{ hashFiles('.php-cs-fixer.dist.php', '.php-cs-fixer.php') != '' }}
run: |
if [ -f vendor/bin/phpcbf ]; then
vendor/bin/phpcbf
fi
79 changes: 79 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: PHPStan

on:
pull_request:
branches: [ "main", "develop" ]
# Manual runs from the Actions tab
workflow_dispatch:

jobs:
tests:
name: "PHP ${{ matrix.php }} (deps: ${{ matrix.deps }})"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [ "8.2" ]
deps: [ "stable" ]

env:
# Typical CI4 testing env values
APP_ENV: testing
CI_ENVIRONMENT: testing

steps:
# --- 1. Checkout code ---------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4

# --- 2. Setup PHP -------------------------------------------------------
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, json, pdo_mysql, sqlite3
ini-values: |
memory_limit=512M
coverage: none
tools: composer

# --- 3. Cache Composer dependencies ------------------------------------
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer-

# --- 4. Install dependencies -------------------------------------------
- name: Install Composer dependencies
run: |
if [ "${{ matrix.deps }}" = "lowest" ]; then
composer update --prefer-lowest --no-interaction --no-progress
else
composer install --no-interaction --no-progress --prefer-dist
fi

# --- 5. Prepare .env for CodeIgniter 4----------------------
# name it `.env.github-ci`
- name: Prepare .env
run: |
if [ -f .env.github-ci ]; then
cp .env.github-ci .env
elif [ -f env ]; then
cp env .env
fi

# --- 6. Static analysis (PHPStan) - ---------------------------
- name: Run PHPStan (if configured)
if: ${{ hashFiles('phpstan.neon*') != '' }}
run: |
if [ -f vendor/bin/phpstan ]; then
vendor/bin/phpstan analyse src tests --no-progress
fi
24 changes: 1 addition & 23 deletions .github/workflows/action.yml → .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,4 @@ jobs:
exit 1
fi

# --- 8. Static analysis (PHPStan) - optional ---------------------------
- name: Run PHPStan (if configured)
if: ${{ hashFiles('phpstan.neon*') != '' }}
run: |
if [ -f vendor/bin/phpstan ]; then
vendor/bin/phpstan analyse src tests --no-progress
fi

# --- 9. Coding standards (PHPCS) - optional ----------------------------
- name: Run PHPCS (if configured)
if: ${{ hashFiles('phpcs.xml*') != '' }}
run: |
if [ -f vendor/bin/phpcs ]; then
vendor/bin/phpcs
fi

# --- 10. PHP-CBF (dry-run) - optional -----------------------------
- name: Run PHP-CBF (dry-run, if configured)
if: ${{ hashFiles('.php-cs-fixer.dist.php', '.php-cs-fixer.php') != '' }}
run: |
if [ -f vendor/bin/phpcbf ]; then
vendor/bin/phpcbf
fi

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/olajideolamide/ci4-settings.svg)](https://packagist.org/packages/olajideolamide/ci4-settings)
![GitHub License](https://img.shields.io/github/license/olajideolamide/ci4-settings)
![PHP CI](https://github.com/olajideolamide/ci4-settings/actions/workflows/action.yml/badge.svg)
![PHP UNIT](https://github.com/olajideolamide/ci4-settings/actions/workflows/phpunit.yml/badge.svg)
![PHP STAN](https://github.com/olajideolamide/ci4-settings/actions/workflows/phpstan.yml/badge.svg)
![PHP CS](https://github.com/olajideolamide/ci4-settings/actions/workflows/phpcs.yml/badge.svg)



Expand Down