From 19ad9f9852d21b656207faa44ed875e7b1e37638 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Tue, 14 Oct 2025 02:03:12 +0200 Subject: [PATCH 1/8] docs: documentation for Docker --- Makefile | 29 +++++++++++++++++++++++++++++ README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ doc/flat-square.svg | 20 ++++++++++++++++++++ doc/flat.svg | 20 ++++++++++++++++++++ doc/for-the-badge.svg | 11 +++++++++++ doc/plastic.svg | 18 ++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 Makefile create mode 100644 doc/flat-square.svg create mode 100644 doc/flat.svg create mode 100644 doc/for-the-badge.svg create mode 100644 doc/plastic.svg diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..acd87ad --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +CONTAINER ?= php83 +DOCKER_RUN=docker compose run --rm $(CONTAINER) + +setup: + docker compose build $(CONTAINER) + $(DOCKER_RUN) composer update + +tests: + docker compose run --rm $(CONTAINER) bin/php-cs-fixer fix --verbose --diff --dry-run + docker compose run --rm $(CONTAINER) bin/phpspec run --format=pretty + docker compose run --rm $(CONTAINER) bin/behat --snippets-for + +matrix-tests: + CONTAINER=php81 $(MAKE) setup + CONTAINER=php81 $(MAKE) tests + + CONTAINER=php82 $(MAKE) setup + CONTAINER=php82 $(MAKE) tests + + CONTAINER=php83 $(MAKE) setup + CONTAINER=php83 $(MAKE) tests + +doc-images: + docker compose run --rm php83 rm -f doc/flat.svg doc/flat-square.svg doc/plastic.svg doc/for-the-badge.svg + + docker compose run --rm php83 bin/poser poser FLAT blue -s "flat" -p "doc/flat.svg" + docker compose run --rm php83 bin/poser poser "FLAT SQUARE" blue -s "flat-square" -p "doc/flat-square.svg" + docker compose run --rm php83 bin/poser poser PLASTIC blue -s "plastic" -p "doc/plastic.svg" + docker compose run --rm php83 bin/poser poser "FOR THE BADGE" blue -s "for-the-badge" -p "doc/for-the-badge.svg" diff --git a/README.md b/README.md index 6f25e8a..02e7483 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ Choose a different style poser license MIT blue -s "for-the-badge" ``` +You can also use the provided Docker Compose services: + +```bash +docker compose run --rm php82 bin/poser license MIT blue +docker compose run --rm php83 bin/poser license MIT blue -p "license.svg" +docker compose run --rm php83 bin/poser license MIT blue -s "plastic" -p "license-plastic.svg" +``` + + ## Usage as library #### 1. Add to composer dependencies @@ -72,6 +81,16 @@ echo $image->getStyle(); The allowed styles are: `plastic`, `flat`, `flat-square`, and `for-the-badge`. +### Examples (generated with `make doc-images`) + +![Flat style](doc/flat.svg) + +![Flat square style](doc/flat-square.svg) + +![Plastic style](doc/plastic.svg) + +![For the badge style](doc/for-the-badge.svg) + ## Encoding @@ -99,6 +118,30 @@ Active contribution and patches are very welcome. Please refer to [CONTRIBUTING](CONTRIBUTING.md) +## Docker development + +You can use the env var CONTAINER to run the tests in a specific PHP version. +The default version if CONTAINER is omitted is php83. + +#### 1. Setup your Docker environment + +```bash +CONTAINER=php83 make setup +``` + +#### 2. Run the tests + +```bash +CONTAINER=php83 make tests +``` + +#### 3. Run the tests for all PHP versions + +```bash +make matrix-tests +``` + + ## License [![License](https://poser.pugx.org/badges/poser/license.svg)](./LICENSE) diff --git a/doc/flat-square.svg b/doc/flat-square.svg new file mode 100644 index 0000000..42cc661 --- /dev/null +++ b/doc/flat-square.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + poser + poser + FLAT SQUARE + FLAT SQUARE + + diff --git a/doc/flat.svg b/doc/flat.svg new file mode 100644 index 0000000..855333e --- /dev/null +++ b/doc/flat.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + poser + poser + FLAT + FLAT + + diff --git a/doc/for-the-badge.svg b/doc/for-the-badge.svg new file mode 100644 index 0000000..93babfb --- /dev/null +++ b/doc/for-the-badge.svg @@ -0,0 +1,11 @@ + + POSER: FOR THE BADGE + + + + + + POSER + FOR THE BADGE + + diff --git a/doc/plastic.svg b/doc/plastic.svg new file mode 100644 index 0000000..6611794 --- /dev/null +++ b/doc/plastic.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + poser + poser + PLASTIC + PLASTIC + + From e4db206f384c4016c05c4a8cd42e8c0073506b7d Mon Sep 17 00:00:00 2001 From: jmleroux Date: Tue, 14 Oct 2025 02:03:44 +0200 Subject: [PATCH 2/8] chore: common docker config --- compose.yml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/compose.yml b/compose.yml index fab418d..fd4166e 100644 --- a/compose.yml +++ b/compose.yml @@ -1,32 +1,28 @@ +x-php-service: &php-service + working_dir: /application + stdin_open: true + volumes: + - .:/application:cached + environment: + - COMPOSER_HOME=/tmp/.composer + services: php81: + <<: *php-service build: context: .docker/php81 - working_dir: /application - stdin_open: true - volumes: - - .:/application:cached php82: + <<: *php-service build: context: .docker/php82 - working_dir: /application - stdin_open: true - volumes: - - .:/application:cached php83: + <<: *php-service build: context: .docker/php83 - working_dir: /application - stdin_open: true - volumes: - - .:/application:cached php84: + <<: *php-service build: context: .docker/php84 - working_dir: /application - stdin_open: true - volumes: - - .:/application:cached From 1cdcfc02450bb9ef58b82f5444f84cc2d6dc736c Mon Sep 17 00:00:00 2001 From: jmleroux Date: Tue, 14 Oct 2025 02:04:01 +0200 Subject: [PATCH 3/8] chore: remove unused scripts --- composer.json | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/composer.json b/composer.json index 93ffbcd..3fa5a39 100644 --- a/composer.json +++ b/composer.json @@ -47,17 +47,6 @@ } }, "bin": ["bin/poser"], - "scripts": { - "php-cs-fixer-dry-run": "bin/php-cs-fixer fix --verbose --diff --dry-run --ansi", - "php-cs-fixer": "bin/php-cs-fixer fix -v --ansi", - "behat": "bin/behat --snippets-for", - "docker:build:php81": "docker build -t pugx/poser:php81 -f .docker/base/php81/Dockerfile .", - "docker:push:php81": "docker push pugx/poser:php81", - "docker:build:php82": "docker build -t pugx/poser:php82 -f .docker/base/php82/Dockerfile .", - "docker:push:php82": "docker push pugx/poser:php82", - "docker:build:php83": "docker build -t pugx/poser:php83 -f .docker/base/php83/Dockerfile .", - "docker:push:php83": "docker push pugx/poser:php83" - }, "extra": { "branch-alias": { "dev-master": "2.x-dev" From 88319303ccb0967d90493acf79113542d58d6756 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Mon, 27 Oct 2025 21:55:32 +0100 Subject: [PATCH 4/8] chore: PHP 8.4 as default container for make targets and PHP 8.4 tests in CI --- .github/workflows/php.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c0a0472..96ed520 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - container: [ "php81", "php82", "php83" ] + container: [ "php81", "php82", "php83", "php84" ] runs-on: ubuntu-24.04 steps: diff --git a/Makefile b/Makefile index acd87ad..8ccdf7e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CONTAINER ?= php83 +CONTAINER ?= php84 DOCKER_RUN=docker compose run --rm $(CONTAINER) setup: From f4c17565a54984cee673b636e9157e980b659ca4 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Mon, 27 Oct 2025 22:05:41 +0100 Subject: [PATCH 5/8] fix: fix tests make target by making it a phony target. Fix phpunit instead of phpspec --- .github/workflows/php.yml | 10 ++-------- Makefile | 5 ++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 96ed520..decd06e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -55,11 +55,5 @@ jobs: - name: Install dependencies run: docker compose run -u $(id -u):$(id -g) --rm ${{ matrix.container }} composer install --prefer-dist --no-progress - - name: Coding Standard Checks - run: docker compose run --rm ${{ matrix.container }} bin/php-cs-fixer fix --verbose --diff --dry-run - - - name: Unit tests - run: docker compose run --rm ${{ matrix.container }} ./bin/phpunit - - - name: Run behat tests - run: docker compose run --rm ${{ matrix.container }} ./bin/behat --snippets-for + - name: Run tests + run: CONTAINER=${{ matrix.container }} make tests diff --git a/Makefile b/Makefile index 8ccdf7e..24991b0 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ CONTAINER ?= php84 DOCKER_RUN=docker compose run --rm $(CONTAINER) +.PHONY: setup tests matrix-tests doc-images + setup: docker compose build $(CONTAINER) $(DOCKER_RUN) composer update + tests: docker compose run --rm $(CONTAINER) bin/php-cs-fixer fix --verbose --diff --dry-run - docker compose run --rm $(CONTAINER) bin/phpspec run --format=pretty + docker compose run --rm $(CONTAINER) bin/phpunit docker compose run --rm $(CONTAINER) bin/behat --snippets-for matrix-tests: From 809327187cf7531541f301ee5cfed22ac8d99c93 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Mon, 27 Oct 2025 22:33:26 +0100 Subject: [PATCH 6/8] ci: dedicated job for PHP 8.4 --- .github/workflows/php.yml | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index decd06e..93b4e62 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -18,11 +18,10 @@ jobs: with: args: --diff --dry-run - build: - + tests: strategy: matrix: - container: [ "php81", "php82", "php83", "php84" ] + container: [ "php81", "php82", "php83" ] runs-on: ubuntu-24.04 steps: @@ -57,3 +56,29 @@ jobs: - name: Run tests run: CONTAINER=${{ matrix.container }} make tests + + tests-php84: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Build Docker image + run: docker compose build php84 + + - name: Validate composer.json + run: docker compose run -u $(id -u):$(id -g) --rm php84 composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php84-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php84 + + - name: Install dependencies + run: docker compose run -u $(id -u):$(id -g) --rm php84 composer install --prefer-dist --no-progress + + - name: Run tests + run: make tests From c9dfc66af59acf5e21ccfd7a2e1b86c3cec78a9f Mon Sep 17 00:00:00 2001 From: jmleroux Date: Fri, 7 Nov 2025 09:11:34 +0100 Subject: [PATCH 7/8] ci: ignore deprecation errors for PHP 8.4 --- .github/workflows/php.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 93b4e62..7f88a14 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -81,4 +81,8 @@ jobs: run: docker compose run -u $(id -u):$(id -g) --rm php84 composer install --prefer-dist --no-progress - name: Run tests - run: make tests + run: | + docker compose run --rm php84 bin/php-cs-fixer fix --verbose --diff --dry-run + docker compose run --rm php84 bin/phpunit + docker compose run --rm php84 php -d error_reporting='E_ALL & ~E_DEPRECATED' bin/behat --snippets-for + From b768dbef07edd53a214c1ae60283df9673b0f614 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Fri, 7 Nov 2025 09:17:11 +0100 Subject: [PATCH 8/8] ci: ignore deprecation errors for behat tests --- .github/workflows/php.yml | 6 +----- Makefile | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7f88a14..93b4e62 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -81,8 +81,4 @@ jobs: run: docker compose run -u $(id -u):$(id -g) --rm php84 composer install --prefer-dist --no-progress - name: Run tests - run: | - docker compose run --rm php84 bin/php-cs-fixer fix --verbose --diff --dry-run - docker compose run --rm php84 bin/phpunit - docker compose run --rm php84 php -d error_reporting='E_ALL & ~E_DEPRECATED' bin/behat --snippets-for - + run: make tests diff --git a/Makefile b/Makefile index 24991b0..8094565 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ setup: tests: docker compose run --rm $(CONTAINER) bin/php-cs-fixer fix --verbose --diff --dry-run docker compose run --rm $(CONTAINER) bin/phpunit - docker compose run --rm $(CONTAINER) bin/behat --snippets-for + docker compose run --rm $(CONTAINER) php -d error_reporting='E_ALL & ~E_DEPRECATED' bin/behat --snippets-for matrix-tests: CONTAINER=php81 $(MAKE) setup