Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
af8de7d
Update to PHP 8.4 and new dependencies, and break
dbellettini Aug 2, 2025
1379ee5
Fix types in BaseAcceptanceTestCase
dbellettini Aug 2, 2025
ae8a99a
Get MONGODB_URI from environment
dbellettini Aug 2, 2025
b9ac887
Try to fix phpstan
dbellettini Aug 2, 2025
a42cc06
Fix more types
dbellettini Aug 3, 2025
1283cca
Lower phpstan
dbellettini Aug 3, 2025
d23ce95
Add more types
dbellettini Aug 3, 2025
6c7f127
Fix Timeless signature
dbellettini Aug 3, 2025
5f1f477
Use array_any instead
dbellettini Aug 3, 2025
41dfc8a
Make setUp and tearDown protected
dbellettini Aug 3, 2025
c422d04
Fix more types
dbellettini Aug 3, 2025
9a603c4
Fix further type hints
dbellettini Aug 3, 2025
1dad2bd
Fix more type errors
dbellettini Aug 3, 2025
2608689
Normalize + extensions
dbellettini Aug 3, 2025
1a0348e
Scan directory for Eris
dbellettini Aug 3, 2025
791f2fb
Fix configuration of phpstan
dbellettini Aug 3, 2025
7787a5d
Increase PHPStan level to 1
dbellettini Aug 3, 2025
66456e3
Separate long tests
dbellettini Aug 3, 2025
a22871a
Fix constructor
dbellettini Aug 3, 2025
d5e83bc
Get MONGODB_URI from environment
dbellettini Aug 3, 2025
64de1b0
Fix mock call with spy
dbellettini Aug 3, 2025
f452a39
Add PHP-CS-Fixer
dbellettini Aug 3, 2025
26e2aec
Disable strict types for now
dbellettini Aug 3, 2025
0ba7278
Fix Coding Standards
dbellettini Aug 3, 2025
67bc5b4
Use a dist file instead
dbellettini Aug 3, 2025
db6d5fa
Remove setMethods
dbellettini Aug 3, 2025
333da69
Use ::class everywhere
dbellettini Aug 3, 2025
75e42ba
Fix Coding Standards
dbellettini Aug 3, 2025
6e64279
Fix most of the tests
dbellettini Aug 3, 2025
8129805
Update language level
dbellettini Aug 3, 2025
5e1405b
Introduce URI::fromEnvironment
dbellettini Aug 3, 2025
6ce9d2a
Fix outdated examples
dbellettini Aug 3, 2025
5bdf1ce
Ad explicit cast to string
dbellettini Aug 3, 2025
a77993c
Fix some type hints and errors
dbellettini Aug 3, 2025
7cdcd5d
Fix Coding Standards
dbellettini Aug 3, 2025
a47bfa9
Add some type hints
dbellettini Aug 3, 2025
98b908a
Move further steps with rector
dbellettini Aug 3, 2025
a43b46f
Increase rector level to 3
dbellettini Aug 3, 2025
6ed9157
Increase rector level to 4
dbellettini Aug 3, 2025
f19c94d
Fix type hint
dbellettini Aug 3, 2025
0f2727a
Increase PHPStan level to 2
dbellettini Aug 3, 2025
5f889bc
Try to fix more test issues
dbellettini Aug 3, 2025
ab26e18
Bump dependencies
dbellettini Aug 3, 2025
2726f1e
Implement minor improvements
dbellettini Aug 3, 2025
28a1b6d
Add var dumper
dbellettini Aug 3, 2025
ec0a470
Fixed the main Recruiter issue
dbellettini Aug 3, 2025
529ca76
Remove risky warning
dbellettini Aug 3, 2025
7911175
Fix the issue with the exit
dbellettini Aug 3, 2025
dc95a28
Improve assertions
dbellettini Aug 3, 2025
c4431e7
Increase waiting time
dbellettini Aug 3, 2025
2472cca
Increase timeout
dbellettini Aug 4, 2025
183833a
Further increase timeout for pipeline
dbellettini Aug 4, 2025
0e4fc2f
Enhance CI pipeline
dbellettini Aug 4, 2025
ba121eb
Make long tests optional
dbellettini Aug 4, 2025
914b265
Use multistage build
dbellettini Aug 4, 2025
e5818ec
Improve the build process
dbellettini Aug 4, 2025
45633c5
Dependencies are already in build
dbellettini Aug 4, 2025
4070baf
Move volumes to ovverride
dbellettini Aug 4, 2025
18b1d3e
Add env to GitHub Actions
dbellettini Aug 4, 2025
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_FILE=compose.yaml:compose.dev.yaml
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI Pipeline

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
inputs:
run_long_tests:
description: 'Run long tests'
required: false
default: false
type: boolean

permissions:
contents: read

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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 with cache
run: |
docker buildx create --use
docker buildx build \
--cache-from type=gha \
--cache-to type=gha,mode=max \
--load \
--tag recruiter-php \
.

test-fast:
needs: setup
runs-on: ubuntu-latest
env:
COMPOSE_FILE: compose.yaml
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Restore cache and build
run: |
docker buildx create --use
docker buildx build \
--cache-from type=gha \
--load \
--tag recruiter-php \
.
- name: Run fast tests
run: make test

test-long:
needs: setup
runs-on: ubuntu-latest
timeout-minutes: 90
if: github.event.inputs.run_long_tests == 'true'
env:
COMPOSE_FILE: compose.yaml
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Restore cache and build
run: |
docker buildx create --use
docker buildx build \
--cache-from type=gha \
--load \
--tag recruiter-php \
.
- name: Run long tests
run: make test-long
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.*
.*.cache
phpunit.xml
composer.phar
composer.lock
vendor/
Expand Down
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__ . '/spec')
)
;
41 changes: 32 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
FROM php:7.2-cli
FROM php:8.4-cli AS base

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

# Install MongoDB extension
RUN pecl install mongodb \
&& docker-php-ext-install bcmath pdo_mysql mbstring opcache pcntl \
&& docker-php-ext-enable mongodb
&& docker-php-ext-enable mongodb \
&& docker-php-ext-install -j$(nproc) \
bcmath \
pdo_mysql \
opcache \
pcntl

RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer && composer global require hirak/prestissimo --no-plugins --no-scripts
# Copy Composer from official image
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /app

COPY . /app
FROM base AS code

RUN composer install
# Set environment variable for Composer
ENV COMPOSER_ALLOW_SUPERUSER=1

ENTRYPOINT /etc/init.d/mongodb start && vendor/bin/phpunit
# Copy composer files
COPY composer.json composer.lock* ./

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

# Copy application code
COPY . .

CMD ["tail", "-f", "/dev/null"]
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.PHONY: build up down test test-long phpstan rector 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 except the long ones
test: up
docker compose exec php vendor/bin/phpunit --exclude-group=long

# Run long tests specifically
test-long: up
docker compose exec php vendor/bin/phpunit --group=long

phpstan: up
docker compose exec php vendor/bin/phpstan --memory-limit=2G

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

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
4 changes: 4 additions & 0 deletions compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
php:
volumes:
- .:/app
19 changes: 19 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
php:
build: .
working_dir: /app
environment:
- COMPOSER_ALLOW_SUPERUSER=1
- MONGODB_URI=mongodb://mongodb:27017/recruiter
depends_on:
- mongodb

mongodb:
image: mongo:8
container_name: recruiter_mongodb
restart: unless-stopped
volumes:
- mongodb_data:/data/db

volumes:
mongodb_data:
62 changes: 37 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "recruiterphp/recruiter",
"description": "Job Queue Manager: high performance, high volume, persistent, fault tolerant. 100% PHP/MongoDB, 100% Awesome",
"license": "MIT",
"type": "project",
"keywords": [
"job",
Expand All @@ -13,8 +14,6 @@
"manager",
"mongodb"
],
"homepage": "https://github.com/recruiterphp/recruiter",
"license": "MIT",
"authors": [
{
"name": "gabriele.lana",
Expand All @@ -25,44 +24,57 @@
"homepage": "https://github.com/recruiterphp/recruiter/graphs/contributors"
}
],
"homepage": "https://github.com/recruiterphp/recruiter",
"require": {
"php": "~7.2",
"php": "^8.4",
"ext-bcmath": "*",
"ext-mongodb": ">=1.1",
"alcaeus/mongo-php-adapter": "^1.1",
"recruiterphp/geezer": "^5",
"gabrielelana/byte-units": "~0.1",
"monolog/monolog": ">=1",
"recruiterphp/concurrency": "^3.0",
"psr/log": "^1.0",
"symfony/console": "^4.2",
"symfony/event-dispatcher": "^3.4|^4.0",
"ulrichsg/getopt-php": "~2.1",
"mongodb/mongodb": "^1.4",
"mtdowling/cron-expression": "^1.2"
},
"suggest": {
"symfony/console": "In order to use Recruiter\\Command\\RecruiterJobCommand."
"ext-posix": "*",
"dragonmantank/cron-expression": "^3.4",
"gabrielelana/byte-units": "^0.5",
"mongodb/mongodb": "^2.1",
"monolog/monolog": "^3.9",
"psr/log": "^3.0",
"recruiterphp/concurrency": "^5.0",
"recruiterphp/geezer": "^7.0",
"symfony/console": "^7.3",
"symfony/event-dispatcher": "^7.3",
"ulrichsg/getopt-php": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^8",
"ext-pcntl": "*",
"dms/phpunit-arraysubset-asserts": "^0.5",
"ergebnis/composer-normalize": "^2.47",
"friendsofphp/php-cs-fixer": "^3.85",
"giorgiosironi/eris": "^1.0",
"phpstan/phpstan": "*",
"giorgiosironi/eris": "dev-master",
"dms/phpunit-arraysubset-asserts": "^0.1.0"
"phpunit/phpunit": "^10.0",
"rector/rector": "^2.1",
"symfony/var-dumper": "^7.3"
},
"suggest": {
"symfony/console": "In order to use Recruiter\\Command\\RecruiterJobCommand."
},
"minimum-stability": "dev",
"prefer-stable": true,
"bin": [
"bin/recruiter"
],
"autoload": {
"psr-4": {
"Recruiter\\": "src/Recruiter",
"Timeless\\": "src/Timeless",
"Sink\\": "src/Sink"
"Sink\\": "src/Sink",
"Timeless\\": "src/Timeless"
},
"files": [
"src/Timeless/functions.php",
"src/Recruiter/functions.php"
]
},
"bin": [
"bin/recruiter"
],
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"sort-packages": true
}
}
10 changes: 8 additions & 2 deletions examples/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

use Recruiter\Recruiter;

echo 'BOOTSTRAP!!!' . PHP_EOL;
$recruiter->getEventDispatcher()->addListener('job.failure.last', function($event) {
error_log("Job definitively failed: " . var_export($event->export(), true));

assert(isset($recruiter));
assert($recruiter instanceof Recruiter);

$recruiter->getEventDispatcher()->addListener('job.failure.last', function ($event): void {
error_log('Job definitively failed: ' . var_export($event->export(), true));
});
Loading