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
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')
)
;
22 changes: 0 additions & 22 deletions .php_cs

This file was deleted.

39 changes: 30 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
FROM php:7.4-alpine
FROM php:8.4-cli

RUN apk add git autoconf build-base gcc
# 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/*

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

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&\
php composer-setup.php &&\
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer
# 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"]
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.PHONY: build up down test 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

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

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
26 changes: 0 additions & 26 deletions Rakefile

This file was deleted.

21 changes: 21 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
php:
build: .
working_dir: /app
volumes:
- .:/app
environment:
- COMPOSER_ALLOW_SUPERUSER=1
- MONGODB_URI=mongodb://mongodb:27017/concurrency
depends_on:
- mongodb

mongodb:
image: mongo:7
container_name: zeiss_mongodb
restart: unless-stopped
volumes:
- mongodb_data:/data/db

volumes:
mongodb_data:
30 changes: 21 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
{
"name": "Easy Welfare - Development Team",
"email": "dev@easywelfare.com"
}
},

{
"name": "Contributors",
"homepage": "https://github.com/recruiterphp/zeiss/graphs/contributors"
}
],
"autoload": {
"psr-4": {
Expand All @@ -20,16 +25,23 @@
}
},
"require": {
"php": "^7.4",
"php": "^8.4",
"ext-mongodb": "*",
"mongodb/mongodb": "^1.5",
"recruiterphp/geezer": "^5.0",
"psr/log": "^1.1"
"mongodb/mongodb": "^2.1",
"recruiterphp/geezer": "^6.0",
"psr/log": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.4",
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.11.19",
"phpstan/phpstan-phpunit": "^0.11.2"
"ergebnis/composer-normalize": "^2.47",
"friendsofphp/php-cs-fixer": "^3.85",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12.3",
"rector/rector": "^2.1"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"sort-packages": true
}
}
}
Loading