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
34 changes: 34 additions & 0 deletions .github/workflows/lint-sniffs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint & Sniffs

on:
pull_request:
branches:
- main
- dev
jobs:
php-lint-sniffs:
name: PHP (Sniffs)
runs-on: ubuntu-latest
# timeout-minutes: 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment the timeout or remove it if not needed. It's better to have a reasonable timeout (e.g., 10 minutes) to prevent hung actions from consuming billing minutes.

Suggested change
# timeout-minutes: 20
timeout-minutes: 10

steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction

- name: PHP Code Standards
run: composer phpcs:test

- name: PHP Static Analysis
run: composer phpstan

- name: PHP Mess Detector
run: composer phpmd

- name: Laravel Pint
run: composer pint:test
35 changes: 29 additions & 6 deletions .github/workflows/checks.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Code checks
name: Tests

on:
pull_request:
push:
branches:
- main
- dev

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '8.3', '8.4', '8.5' ]
services:
mysql-service:
image: mysql:5.7
Expand Down Expand Up @@ -42,16 +46,35 @@ jobs:
echo "DB_USERNAME=root" >> workbench/.env
echo "DB_PASSWORD=password" >> workbench/.env
echo "APP_ENV=testing" >> workbench/.env
- name: Testing on PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer
extensions: pcov
coverage: pcov
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Publish roles migrations
run: vendor/bin/testbench vendor:publish --tag roles-migrations
- name: Run migrations
run: vendor/bin/testbench migrate
- name: Run tests
run: vendor/bin/testbench package:test
- name: Run linter test
run: composer pint:test
run: vendor/bin/testbench package:test --coverage --coverage-clover=reports/coverage/coverage.xml
- name: Check code coverage
run: |
COVERAGE=$(php -r "
\$xml = simplexml_load_file('reports/coverage/coverage.xml');
\$metrics = \$xml->project->metrics;
\$coverage = ((int)\$metrics['coveredstatements'] / (int)\$metrics['statements']) * 100;
echo round(\$coverage, 2);
")
echo "Code coverage: $COVERAGE%"
MIN_COVERAGE=59.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimum coverage threshold is set to a very specific value (59.1). It is recommended to round this to an integer or use a more standard threshold (e.g., 60 or 80) to avoid failures on minor, non-logical line shifts.

Suggested change
MIN_COVERAGE=59.1
MIN_COVERAGE=60

if (( $(echo "$COVERAGE < $MIN_COVERAGE" | bc -l) )); then
echo "❌ Code coverage ($COVERAGE%) is below the minimum threshold of $MIN_COVERAGE%"
exit 1
else
echo "✅ Code coverage ($COVERAGE%) meets the minimum threshold of $MIN_COVERAGE%"
fi
- name: Clean up SSH key
if: always()
run: rm -f ~/.ssh/id_rsa
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ vendor/
.idea/
.phpunit.result.cache
workbench/storage
.vscode
.vscode
reports/
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": "^8.2",
"php": "^8.3",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"whilesmart/eloquent-roles": "*",
Expand All @@ -22,7 +22,11 @@
"zircote/swagger-php": "^5.1",
"nunomaduro/collision": "^8.8",
"laravel/pint": "^1.22",
"fakerphp/faker": "^1.24"
"fakerphp/faker": "^1.24",
"phpmd/phpmd": "@stable",
"phpstan/phpstan": "^2.1",
"larastan/larastan": "^3.0",
"squizlabs/php_codesniffer": "^4.0"
},
"suggest": {
"whilesmart/organizations": "For organization/customer management within workspaces",
Expand All @@ -47,16 +51,22 @@
}
},
"scripts": {
"test": "vendor/bin/testbench package:test",
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"pint": [
"./vendor/bin/pint"
"./vendor/bin/pint --preset psr12"
],
"pint:test": [
"./vendor/bin/pint --test"
]
"./vendor/bin/pint --preset psr12 --test"
],
"phpmd": [
"vendor/bin/phpmd src text phpmd.xml"
],
"phpstan": "phpstan analyse src --memory-limit=2048M --level=5",
"phpcs": "phpcbf src",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phpcs script is configured to use phpcbf, which is a fixer, not a checker. This is confusing as the script name implies checking. Usually, phpcs should be for checking and phpcbf for fixing.

Suggested change
"phpcs": "phpcbf src",
"phpcs:fix": "phpcbf src",

"phpcs:test": "phpcs src",
"test": "vendor/bin/testbench package:test --coverage"
}
}

Loading
Loading