diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c0a0472..93b4e62 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -18,8 +18,7 @@ jobs: with: args: --diff --dry-run - build: - + tests: strategy: matrix: container: [ "php81", "php82", "php83" ] @@ -55,11 +54,31 @@ 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: 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: Unit tests - run: docker compose run --rm ${{ matrix.container }} ./bin/phpunit + - 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 behat tests - run: docker compose run --rm ${{ matrix.container }} ./bin/behat --snippets-for + - name: Run tests + run: make tests diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8094565 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +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/phpunit + docker compose run --rm $(CONTAINER) php -d error_reporting='E_ALL & ~E_DEPRECATED' 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/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 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" 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 + +