Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
35 changes: 27 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
with:
args: --diff --dry-run

build:

tests:
strategy:
matrix:
container: [ "php81", "php82", "php83" ]
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running tests with make will also validate the target works as expected


tests-php84:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted from the matrix while it is not stable

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
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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) 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"
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
28 changes: 12 additions & 16 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 0 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions doc/flat-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions doc/flat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions doc/for-the-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions doc/plastic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading