Skip to content

Commit 8b429eb

Browse files
committed
Improvements v2
1 parent 963a518 commit 8b429eb

5 files changed

Lines changed: 50 additions & 45 deletions

File tree

.github/actions/container-user/action.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/check.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
on:
22
workflow_dispatch: ~
33
push:
4-
branches: ['main', '*.*.x']
4+
branches: [main, '*.*.x']
55
pull_request: ~
66

77
jobs:
8-
lint:
8+
code-style:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v6
12-
- uses: ./.github/actions/container-user
13-
- run: make lint
12+
- run: make fixer-check rector-check
1413

1514
composer:
1615
runs-on: ubuntu-latest
1716
steps:
18-
- uses: actions/checkout@v6
19-
- uses: ./.github/actions/container-user
20-
- run: make composer-validate deps-analyze
17+
- uses: actions/checkout@v6
18+
- run: make composer-validate composer-normalize-check deps-analyze
2119

2220
phpstan:
2321
runs-on: ubuntu-latest
@@ -28,13 +26,17 @@ jobs:
2826
deps: [ lowest, highest ]
2927
steps:
3028
- uses: actions/checkout@v6
31-
- uses: ./.github/actions/container-user
3229
- run: PHP_VERSION=${{ matrix.php }} make install-${{ matrix.deps }} phpstan
3330

3431
test:
3532
runs-on: ubuntu-latest
3633
strategy: *strategy
3734
steps:
3835
- uses: actions/checkout@v6
39-
- uses: ./.github/actions/container-user
4036
- run: PHP_VERSION=${{ matrix.php }} make install-${{ matrix.deps }} test
37+
38+
# infect:
39+
# runs-on: ubuntu-latest
40+
# steps:
41+
# - uses: actions/checkout@v6
42+
# - run: make infect

Makefile

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include .env
44
SHELL ?= /bin/bash
55
DOCKER ?= docker
66
DOCKER_COMPOSE ?= $(DOCKER) compose
7+
export CONTAINER_USER ?= $(shell id -u):$(shell id -g)
78
INSIDE_CONTAINER ?= $(shell test -f /.dockerenv && echo 1)
89

910
RUN ?= $(if $(INSIDE_CONTAINER),,$(DOCKER_COMPOSE) run --rm php)
@@ -34,51 +35,65 @@ run: ## Run a command inside the Docker container, e.g. `make run CMD=pwd`
3435
$(RUN) $(CMD)
3536
.PHONY: run
3637

38+
t: terminal
3739
terminal: var ## Start a terminal inside the Docker container
3840
@$(if $(INSIDE_CONTAINER),echo 'Already inside docker container.'; exit 1,)
3941
$(DOCKER_COMPOSE) run --rm php bash
40-
.PHONY: terminal
42+
.PHONY: t terminal
4143

4244
##
4345
## Tools
4446
## -----
4547

46-
lint: var ## Check code style
47-
$(RUN) php-cs-fixer fix --diff --verbose --dry-run
48-
$(RUN) rector process --dry-run
49-
.PHONY: lint
48+
fixer: var ## Fix code style using PHP-CS-Fixer
49+
$(RUN) php-cs-fixer fix --diff --verbose $(ARGS)
50+
.PHONY: fixer
5051

51-
fixcs: var ## Fix code style
52-
$(RUN) php-cs-fixer fix --diff --verbose
53-
$(RUN) rector process
54-
.PHONY: fixcs
52+
fixer-check: var ## Check code style using PHP-CS-Fixer
53+
$(RUN) php-cs-fixer fix --diff --verbose --dry-run $(ARGS)
54+
.PHONY: fixer-check
5555

56-
phpstan: var vendor ## Analyze with PHPStan
57-
$(RUN) phpstan analyze
56+
rector: var ## Fix code style using Rector
57+
$(RUN) rector process $(ARGS)
58+
.PHONY: rector
59+
60+
rector-check: var ## Check code style using Rector
61+
$(RUN) rector process --dry-run $(ARGS)
62+
.PHONY: rector-check
63+
64+
phpstan: var vendor ## Analyze code using PHPStan
65+
$(RUN) phpstan analyze $(ARGS)
5866
.PHONY: phpstan
5967

60-
test: var vendor ## Run tests
61-
$(RUN) vendor/bin/phpunit
68+
test: var vendor ## Run tests using PHPUnit
69+
$(RUN) vendor/bin/phpunit $(ARGS)
6270
.PHONY: test
6371

64-
infect: var vendor ## Run mutation tests
65-
$(RUN) infection --show-mutations
72+
infect: var vendor ## Run mutation tests using Infection
73+
$(RUN) infection --show-mutations $(ARGS)
6674
.PHONY: infect
6775

76+
deps-analyze: vendor ## Analyze project dependencies using Composer dependency analyser
77+
$(RUN) composer-dependency-analyser $(ARGS)
78+
.PHONY: deps-analyze
79+
6880
composer-validate: ## Validate composer.json
69-
$(COMPOSER) validate
70-
$(COMPOSER) normalize --diff --dry-run
81+
$(COMPOSER) validate $(ARGS)
7182
.PHONY: composer-validate
7283

7384
composer-normalize: ## Normalize composer.json
74-
$(COMPOSER) normalize --diff
85+
$(COMPOSER) normalize --diff $(ARGS)
7586
.PHONY: composer-normalize
7687

77-
deps-analyze: vendor ## Analyze project dependencies
78-
$(RUN) composer-dependency-analyser
79-
.PHONY: deps-analyze
88+
composer-normalize-check: ## Check that composer.json is normalized
89+
$(COMPOSER) normalize --diff --dry-run $(ARGS)
90+
.PHONY: composer-normalize-check
91+
92+
fix: fixer rector composer-normalize ## Run all fixing recipes
93+
.PHONY: fix
8094

81-
check: lint phpstan test composer-validate deps-analyze ## Run all project checks
95+
check: fixer-check rector-check composer-validate composer-normalize-check phpstan test deps-analyze ## Run all project checks
96+
.PHONY: check
8297

8398
# -----------------------
8499

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
user: ${CONTAINER_USER:-}
55
environment:
66
HISTFILE: /app/var/.docker_history
7+
COMPOSER_CACHE_DIR: /app/var/.composer_cache
78
tty: true
89
volumes:
910
- .:/app:cached

src/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
declare(strict_types=1);
44

5-
echo 'Hello world!';
5+
echo 'Hello world!', PHP_EOL;

0 commit comments

Comments
 (0)