diff --git a/.docker/Dockerfile b/.docker/Dockerfile index ab0f992..14cda03 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,8 +1,44 @@ -FROM splitbrain/phpfarm:jessie +FROM debian:trixie-slim -RUN apt-get update && apt-get install -y git zip +# Prevent interactive prompts +ENV DEBIAN_FRONTEND=noninteractive +# Install dependencies +RUN apt-get update && apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + git \ + lsb-release \ + unzip \ + zip \ + && curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \ + && apt-get update + +# Supported PHP Versions +ENV PHP_VERSIONS="7.4 8.0 8.1 8.2 8.3 8.4 8.5" + +# Install all PHP versions using a loop +RUN for ver in $PHP_VERSIONS; do \ + apt-get install -y \ + php${ver}-cli php${ver}-xml php${ver}-mbstring php${ver}-soap; \ + done \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Create symlinks (php-X.Y) using the same list +RUN for ver in $PHP_VERSIONS; do \ + ln -s /usr/bin/php${ver} /usr/bin/php-${ver}; \ + done + +# Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Set working directory +WORKDIR /var/www + +# Copy project files COPY . /var/www/ -WORKDIR /var/www/ +# Default command +CMD ["bash"] diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonars.yml similarity index 55% rename from .github/workflows/sonarcloud.yml rename to .github/workflows/sonars.yml index 4bec647..0621cba 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonars.yml @@ -1,18 +1,25 @@ -name: SonarCloud +name: Sonars on: push: branches: - develop - feature/* - feat/* + - release/* pull_request: types: [ opened, synchronize, reopened ] +concurrency: sonars jobs: sonarcloud: - name: SonarCloud + name: Sonars runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + statuses: write steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -25,13 +32,22 @@ jobs: - name: Install dependencies with composer run: composer update --no-ansi --no-interaction --no-progress - - name: Generate coverage report with phpunit/phpunit + - name: Generate coverage report with phpunit run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit report.xml + - name: Monitor coverage + uses: slavcodev/coverage-monitor-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + coverage_path: coverage.xml + threshold_alert: 95 + threshold_warning: 90 + - name: Fix phpunit files paths run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master + uses: SonarSource/sonarqube-scan-action@v7 env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a4044cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".docker"] + path = .docker + url = git@github.com:WsdlToPhp/DockerCommonImage.git diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 56564b1..686ff64 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -8,5 +8,9 @@ ->setUsingCache(false) ->setRules(array( '@PhpCsFixer' => true, + 'phpdoc_separation' => false, + 'single_line_empty_body' => false, + 'phpdoc_align' => false, + 'php_unit_test_class_requires_covers' => false, )) ->setFinder($finder); diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f44be3b --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +PHP_VERSION ?= php-7.4 +CONTAINER_NAME ?= dom_handler +COMPOSER ?= /usr/bin/composer +DOCKER_COMPOSE ?= docker compose +DOCKER_EXEC_CONTAINER ?= docker exec -t $(CONTAINER_NAME) + +.PHONY: bash build cs-fixer down install phpstan phpunit rector up update + +bash: + $(DOCKER_EXEC_CONTAINER) bash + +build: + $(DOCKER_COMPOSE) build + +cs-fixer: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/php-cs-fixer fix --ansi --diff --verbose + +down: + $(DOCKER_COMPOSE) down + +install: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) $(COMPOSER) install + +phpstan: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpstan analyze src --level=2 + +phpunit: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpunit --stop-on-failure --stop-on-error $(ARGS) + +rector: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/rector process + +up: + $(DOCKER_COMPOSE) up -d + +update: + $(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) $(COMPOSER) update diff --git a/README.md b/README.md index 2e9a9cf..6553abe 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. Developers who helped on this project are listed in the [composer.json](composer.json#L8) file as `Contributor` and are: - [phordijk](https://github.com/phordijk) +- [AndreasA](https://github.com/AndreasA) ## FAQ diff --git a/composer.json b/composer.json index 0e876d5..d50f999 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,10 @@ { "name": "phordijk", "role": "Contributor" + }, + { + "name": "Andreas Allacher", + "role": "Contributor" } ], "require": { diff --git a/docker-compose.yml b/docker-compose.yml index 832062f..fb108ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.4' - services: php: build: @@ -8,3 +6,4 @@ services: volumes: - .:/var/www:rw container_name: dom_handler + tty: true diff --git a/tests/AttributeHandlerTest.php b/tests/AttributeHandlerTest.php index 7048f46..3093f3f 100644 --- a/tests/AttributeHandlerTest.php +++ b/tests/AttributeHandlerTest.php @@ -8,8 +8,6 @@ /** * @internal - * - * @coversDefaultClass \WsdlToPhp\DomHandler\AttributeHandler */ final class AttributeHandlerTest extends TestCase { diff --git a/tests/DomDocumentHandlerTest.php b/tests/DomDocumentHandlerTest.php index 2999bff..b087ced 100644 --- a/tests/DomDocumentHandlerTest.php +++ b/tests/DomDocumentHandlerTest.php @@ -10,8 +10,6 @@ /** * @internal - * - * @coversDefaultClass \WsdlToPhp\DomHandler\DomDocumentHandler */ final class DomDocumentHandlerTest extends TestCase { diff --git a/tests/ElementHandlerTest.php b/tests/ElementHandlerTest.php index dd4f1fa..e4d4113 100644 --- a/tests/ElementHandlerTest.php +++ b/tests/ElementHandlerTest.php @@ -11,8 +11,6 @@ /** * @internal - * - * @coversDefaultClass \WsdlToPhp\DomHandler\ElementHandler */ final class ElementHandlerTest extends TestCase { diff --git a/tests/NameSpaceHandlerTest.php b/tests/NameSpaceHandlerTest.php index 88aee09..73276ba 100755 --- a/tests/NameSpaceHandlerTest.php +++ b/tests/NameSpaceHandlerTest.php @@ -6,8 +6,6 @@ /** * @internal - * - * @coversDefaultClass \WsdlToPhp\DomHandler\NameSpaceHandler */ final class NameSpaceHandlerTest extends TestCase { diff --git a/tests/NodeHandlerTest.php b/tests/NodeHandlerTest.php index c80deb3..57ea008 100644 --- a/tests/NodeHandlerTest.php +++ b/tests/NodeHandlerTest.php @@ -9,8 +9,6 @@ /** * @internal - * - * @coversDefaultClass \WsdlToPhp\DomHandler\NodeHandler */ final class NodeHandlerTest extends TestCase {