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
119 changes: 119 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI Pipeline

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
name: Code Formatting

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

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

- name: Run Laravel Pint
run: ./vendor/bin/pint --test --verbose

phpstan:
runs-on: ubuntu-latest
name: Static Analysis

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

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

- name: Run PHPStan
run: ./vendor/bin/phpstan analyse

tests:
runs-on: ubuntu-latest
name: Unit Tests

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

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

- name: Run Unit Tests
run: ./vendor/bin/pest

coverage:
runs-on: ubuntu-latest
name: Test Coverage

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, xdebug
coverage: xdebug

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

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

- name: Run Test Coverage
run: ./vendor/bin/pest --coverage --coverage-clover ./coverage.xml --min=80

- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODE_COV_TOKEN }}
files: ./coverage.xml
50 changes: 0 additions & 50 deletions .github/workflows/pr.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,9 @@ on:
types: [published]

jobs:
code-quality:
runs-on: ubuntu-latest
name: Code Quality Check

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-composer-${{ hashFiles('composer.json') }}

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

- name: Run Laravel Pint
run: ./vendor/bin/pint --test

submit-to-packagist:
runs-on: ubuntu-latest
name: Submit to Packagist
needs: code-quality
if: success()

steps:
- name: Submit package to Packagist
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Homestead.yaml
/build
/dist
/coverage

# Miscellaneous
/.phpunit.cache
coverage.xml
35 changes: 29 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,46 @@
"array conversion"
],
"homepage": "https://github.com/lumosolutions/actionable",
"autoload": {
"psr-4": {
"LumoSolutions\\Actionable\\": "src/"
}
},
"authors": [
{
"name": "Richard Anderson",
"email": "richard@lumosolutions.org",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"LumoSolutions\\Actionable\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"LumoSolutions\\Actionable\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"require": {
"php": ">=8.2"
},
"require-dev": {
"laravel/pint": "^1.22"
"larastan/larastan": "^2.9||^3.0",
"laravel/pint": "^1.22",
"orchestra/testbench": "^10.0.0||^9.0.0||^8.22.0",
"pestphp/pest": "^3.0"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 5
paths:
- src
- tests
excludePaths:
- tests/*/*Test.php
tmpDir: build/phpstan
31 changes: 31 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="LumoSolutions Actionable Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
28 changes: 3 additions & 25 deletions src/Analysis/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace LumoSolutions\Actionable\Analysis;

class ClassMetadata
readonly class ClassMetadata
{
/** @var FieldMetadata[] */
public readonly array $constructorFields;
public array $constructorFields;

/** @var FieldMetadata[] */
public readonly array $properties;
public array $properties;

/**
* @param FieldMetadata[] $constructorFields
Expand All @@ -20,28 +20,6 @@ public function __construct(array $constructorFields, array $properties)
$this->properties = $properties;
}

public function getConstructorField(string $propertyName): ?FieldMetadata
{
foreach ($this->constructorFields as $field) {
if ($field->propertyName === $propertyName) {
return $field;
}
}

return null;
}

public function getProperty(string $propertyName): ?FieldMetadata
{
foreach ($this->properties as $property) {
if ($property->propertyName === $propertyName) {
return $property;
}
}

return null;
}

public function getVisibleProperties(): array
{
return array_filter($this->properties, fn (FieldMetadata $field) => ! $field->shouldIgnore());
Expand Down
20 changes: 10 additions & 10 deletions src/Analysis/FieldMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace LumoSolutions\Actionable\Analysis;

class FieldMetadata
readonly class FieldMetadata
{
public function __construct(
public readonly string $propertyName,
public readonly string $fieldName,
public readonly ?string $type = null,
public readonly bool $ignore = false,
public readonly ?string $dateFormat = null,
public readonly ?string $arrayOf = null,
public readonly bool $hasDefault = false,
public readonly mixed $defaultValue = null,
public readonly bool $allowsNull = false
public string $propertyName,
public string $fieldName,
public ?string $type = null,
public bool $ignore = false,
public ?string $dateFormat = null,
public ?string $arrayOf = null,
public bool $hasDefault = false,
public mixed $defaultValue = null,
public bool $allowsNull = false
) {}

public function isDateTime(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Attributes/ArrayOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Attribute;

#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)]
class ArrayOf
readonly class ArrayOf
{
public function __construct(
public string $class
Expand Down
Loading