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
38 changes: 38 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PHPUnit Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Build the Docker image
run: make build

- name: Install dependencies
run: make install

- name: Run test suite
run: make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.php_cs.cache
.*.cache
/.idea/
/vendor/
composer.lock
25 changes: 25 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return new PhpCsFixer\Config()
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'string_implicit_backslashes' => true,
'list_syntax' => ['syntax' => 'short'],
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
'ordered_imports' => true,
'phpdoc_to_comment' => false,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'parameters']],
'visibility_required' => ['elements' => ['property', 'method', 'const']],
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
)
;
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM php:8.4-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libssl-dev \
libcurl4-openssl-dev \
pkg-config \
openjdk-17-jre-headless \
&& rm -rf /var/lib/apt/lists/*

# Install MongoDB extension
RUN pecl install mongodb \
&& docker-php-ext-enable mongodb \
&& docker-php-ext-install pcntl

# Copy Composer from official image
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /app

# Copy composer files
COPY composer.json composer.lock* ./

# Install dependencies including dev dependencies for testing
RUN composer install --optimize-autoloader

# Copy application code
COPY . .

# Set environment variable for Composer
ENV COMPOSER_ALLOW_SUPERUSER=1

CMD ["tail", "-f", "/dev/null"]
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.PHONY: build up down test phpstan fix-cs install update shell logs clean

# Build the Docker image
build:
docker compose build

# Start the services
up:
docker compose up -d

# Stop the services
down:
docker compose down

# Install dependencies
install:
docker compose run --rm php composer install

# Update dependencies
update:
docker compose run --rm php composer update

# Run all tests
test: up
docker compose exec php vendor/bin/phpunit

phpstan: up
docker compose exec php vendor/bin/phpstan

fix-cs: up
docker compose exec php vendor/bin/php-cs-fixer fix -v

# Open a shell in the PHP container
shell:
docker compose exec php bash

# View logs
logs:
docker compose logs -f php

# Clean up containers and volumes
clean:
docker compose down -v
docker compose rm -f
8 changes: 8 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
php:
build: .
working_dir: /app
volumes:
- .:/app
environment:
- COMPOSER_ALLOW_SUPERUSER=1
32 changes: 21 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{
"name": "recruiterphp/geezer",
"description": "PHP tools to build robust long-running processes",
"license": "MIT",
"type": "library",
"license": "proprietary",
"authors": [
{
"name": "Easy Welfare Development Team",
"email": "dev@easywelfare.com"
},
{
"name": "Contributors",
"homepage": "https://github.com/recruiterphp/geezer/graphs/contributors"
}
],
"require": {
"php": "^7.2",
"php": "^8.4",
"ext-pcntl": "*",
"symfony/console": "~4.0",
"recruiterphp/concurrency": "^3.0.0"
"recruiterphp/concurrency": "^4.0",
"symfony/console": "^7.3"
},
"require-dev": {
"phpunit/phpunit": "^7",
"friendsofphp/php-cs-fixer": "^2.13",
"phpstan/phpstan": "^0.10.5",
"phpstan/phpstan-phpunit": "^0.10.0"
"ergebnis/composer-normalize": "^2.47",
"friendsofphp/php-cs-fixer": "^3.85",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12.3",
"rector/rector": "^2.1"
},
"provide": {
"easywelfare/geezer-implementation": "2.0.0"
"easywelfare/geezer-implementation": "self.version"
},
"minimum-stability": "dev",
"prefer-stable": true,
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Recruiter\\Geezer\\": "src",
Expand All @@ -36,5 +40,11 @@
"psr-4": {
"Recruiter\\Geezer\\": "tests"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"sort-packages": true
}
}
}
11 changes: 4 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
includes:
- ./vendor/phpstan/phpstan-phpunit/extension.neon
- ./vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: 7
excludes_analyse:
- %currentWorkingDirectory%/vendor/
level: 10
paths:
- src
- tests
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.3/phpunit.xsd"
backupGlobals="false"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true"
bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
16 changes: 16 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
// ->withPhpSets()
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
2 changes: 2 additions & 0 deletions src/Command/LeadershipEventsHandler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Recruiter\Geezer\Command;

interface LeadershipEventsHandler
Expand Down
5 changes: 3 additions & 2 deletions src/Command/RobustCommand.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

declare(strict_types=1);

namespace Recruiter\Geezer\Command;

use Recruiter\Geezer\Leadership\LeadershipStrategy;
use Recruiter\Geezer\Timing\WaitStrategy;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Throwable;

interface RobustCommand
{
Expand Down Expand Up @@ -35,5 +36,5 @@ public function execute(): bool;
/**
* @return bool true on successful shutdown, false otherwhise
*/
public function shutdown(?Throwable $e = null): bool;
public function shutdown(?\Throwable $e = null): bool;
}
Loading