Skip to content

Commit 74bdb22

Browse files
authored
Align the tooling with the ecosystem standard. (#34)
1 parent 1606503 commit 74bdb22

7 files changed

Lines changed: 33 additions & 48 deletions

File tree

‎.gitattributes‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
*.php text diff=php
44

5-
# Keep Claude tooling scripts out of GitHub's language statistics
6-
75
# Dev-only, excluded from the Packagist tarball
86
/.github export-ignore
97
/tests export-ignore

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Closes #...
1212

1313
- [ ] Tests added or updated.
1414
- [ ] Documentation updated when applicable.
15-
- [ ] `composer review` passes.
16-
- [ ] `composer tests` passes.
15+
- [ ] `make review` passes.
16+
- [ ] `make tests` passes.

‎.github/copilot-instructions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PHP library in the tiny-blocks ecosystem.
66

77
## Mandatory pre-task step
88

9-
Before starting any task, read and strictly follow `CLAUDE.md` and every rule file in
9+
Before starting any task, read and strictly follow `.claude/CLAUDE.md` and every rule file in
1010
`.claude/rules/`. These files are the absolute source of truth for code generation. Apply every
1111
rule strictly. Do not deviate from the patterns, folder structure, or naming conventions defined
1212
in them.

‎.github/workflows/ci.yml‎

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,39 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
resolve-php-version:
15-
name: Resolve PHP version
14+
resolve-tooling-image:
15+
name: Resolve tooling image
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 5
1818
outputs:
19-
php-version: ${{ steps.config.outputs.php-version }}
19+
php-image: ${{ steps.config.outputs.php-image }}
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v7
2323

24-
- name: Resolve PHP version from composer.json
24+
- name: Resolve tooling image from the Makefile
2525
id: config
26-
run: |
27-
version=$(jq -r '.require.php' composer.json | grep -oP '\d+\.\d+' | head -1)
28-
echo "php-version=$version" >> "$GITHUB_OUTPUT"
26+
run: echo "php-image=$(make show-image)" >> "$GITHUB_OUTPUT"
2927

3028
build:
3129
name: Build
32-
needs: resolve-php-version
30+
needs: resolve-tooling-image
3331
runs-on: ubuntu-latest
3432
timeout-minutes: 15
33+
env:
34+
image: ${{ needs.resolve-tooling-image.outputs.php-image }}
35+
workspace: /var/www/html
3536
steps:
3637
- name: Checkout
3738
uses: actions/checkout@v7
3839

39-
- name: Setup PHP
40-
uses: shivammathur/setup-php@v2
41-
with:
42-
tools: composer:2
43-
php-version: ${{ needs.resolve-php-version.outputs.php-version }}
44-
4540
- name: Validate composer.json
46-
run: composer validate --no-interaction
41+
run: docker run --rm -v "${PWD}":${{ env.workspace }} ${{ env.image }} composer validate --no-interaction
4742

4843
- name: Install dependencies
49-
run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction
44+
run: >
45+
docker run --rm -v "${PWD}":${{ env.workspace }} ${{ env.image }}
46+
composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction
5047
5148
- name: Upload vendor and composer.lock as artifact
5249
uses: actions/upload-artifact@v7
@@ -58,48 +55,36 @@ jobs:
5855
5956
auto-review:
6057
name: Auto review
61-
needs: [resolve-php-version, build]
58+
needs: [resolve-tooling-image, build]
6259
runs-on: ubuntu-latest
6360
timeout-minutes: 15
6461
steps:
6562
- name: Checkout
6663
uses: actions/checkout@v7
6764

68-
- name: Setup PHP
69-
uses: shivammathur/setup-php@v2
70-
with:
71-
tools: composer:2
72-
php-version: ${{ needs.resolve-php-version.outputs.php-version }}
73-
7465
- name: Download vendor artifact from build
7566
uses: actions/download-artifact@v8
7667
with:
7768
name: vendor-artifact
7869
path: .
7970

8071
- name: Run review
81-
run: composer review
72+
run: make review
8273

8374
tests:
8475
name: Tests
85-
needs: [resolve-php-version, auto-review]
76+
needs: [resolve-tooling-image, auto-review]
8677
runs-on: ubuntu-latest
8778
timeout-minutes: 15
8879
steps:
8980
- name: Checkout
9081
uses: actions/checkout@v7
9182

92-
- name: Setup PHP
93-
uses: shivammathur/setup-php@v2
94-
with:
95-
tools: composer:2
96-
php-version: ${{ needs.resolve-php-version.outputs.php-version }}
97-
9883
- name: Download vendor artifact from build
9984
uses: actions/download-artifact@v8
10085
with:
10186
name: vendor-artifact
10287
path: .
10388

10489
- name: Run tests
105-
run: composer tests
90+
run: make tests

‎Makefile‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ endif
88

99
TTY := $(shell [ -t 0 ] && echo -it)
1010

11-
DOCKER_RUN = docker run ${PLATFORM} --rm ${TTY} --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.5-alpine
11+
PHP_VERSION := $(shell sed -n 's/.*"php": *"^\([0-9]*\.[0-9]*\)".*/\1/p' composer.json)
12+
IMAGE_VERSION := 1.0.0
13+
PHP_IMAGE := gustavofreze/php:${PHP_VERSION}-cli-${IMAGE_VERSION}
14+
WORKSPACE := /var/www/html
15+
16+
DOCKER_RUN = docker run ${PLATFORM} --rm ${TTY} --net=host -v ${PWD}:${WORKSPACE} ${PHP_IMAGE}
1217

1318
RESET := \033[0m
1419
GREEN := \033[0;32m
@@ -44,6 +49,10 @@ show-reports: ## Open coverage and mutation reports in the browser
4449
show-outdated: ## Show outdated direct dependencies
4550
@${DOCKER_RUN} composer outdated --direct
4651

52+
.PHONY: show-image
53+
show-image: ## Show the pinned PHP tooling image
54+
@echo ${PHP_IMAGE}
55+
4756
.PHONY: clean
4857
clean: ## Remove dependencies and generated artifacts
4958
@sudo chown -R ${USER}:${USER} ${PWD}
@@ -66,7 +75,7 @@ help: ## Display this help message
6675
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
6776
@echo ""
6877
@echo "$$(printf '$(GREEN)')Reports$$(printf '$(RESET)')"
69-
@grep -E '^(show-reports|show-outdated):.*?## .*$$' $(MAKEFILE_LIST) \
78+
@grep -E '^(show-reports|show-outdated|show-image):.*?## .*$$' $(MAKEFILE_LIST) \
7079
| awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}'
7180
@echo ""
7281
@echo "$$(printf '$(GREEN)')Cleanup$$(printf '$(RESET)')"

‎composer.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"ergebnis/composer-normalize": true,
6161
"infection/extension-installer": true
6262
},
63+
"process-timeout": 0,
6364
"sort-packages": true
6465
},
6566
"scripts": {

‎phpstan.neon.dist‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ parameters:
33
paths:
44
- src
55
- tests
6+
tmpDir: reports/phpstan
67
ignoreErrors:
78
# PHPDoc cannot express iterable value types inside src/Internal/ and tests/, nor on the public
89
# constructor parameters Mapper::$mappings and Configuration::$omittedFields (PHPDoc on
@@ -15,54 +16,45 @@ parameters:
1516
path: src/Mapper.php
1617
- identifier: missingType.iterableValue
1718
path: src/Configuration.php
18-
1919
# PHPDoc cannot express generic class types inside src/Internal/ and tests/.
2020
- identifier: missingType.generics
2121
path: src/Internal/
2222
- identifier: missingType.generics
2323
path: tests/
24-
2524
# Reflection-driven mapping reads mixed values from untyped sources inside src/Internal/ and tests/.
2625
- identifier: argument.type
2726
path: src/Internal/
2827
- identifier: argument.type
2928
path: tests/
30-
3129
# Reflection-driven mapping returns concrete types PHPStan cannot infer from mixed input, both
3230
# inside src/Internal/ and on the public facade that forwards engine results (Mapper).
3331
- identifier: return.type
3432
path: src/Internal/
3533
- identifier: return.type
3634
path: src/Mapper.php
37-
3835
# Subtype and Layout mappings forward a class name resolved at runtime (from an untyped source
3936
# or the target type string) into the generic reflectionRead, so PHPStan cannot bind the
4037
# template type T. The forwarded value is always a valid class-string.
4138
- identifier: argument.templateType
4239
path: src/Internal/
43-
4440
# Reflection-driven hydration casts values typed as mixed into the property's declared scalar type.
4541
- identifier: cast.string
4642
path: src/Internal/
47-
4843
# Reflection-driven mapping accesses offsets of sources whose runtime shape is mixed.
4944
- identifier: offsetAccess.invalidOffset
5045
path: src/Internal/
51-
5246
# Reflection-driven mapping invokes methods on values resolved at runtime from mixed.
5347
- identifier: method.nonObject
5448
path: src/Internal/
5549
- identifier: instanceof.invalidExprType
5650
path: src/Internal/
57-
5851
# The scalar-codec list on the class descriptor cannot carry its value type (PHPDoc on the
5952
# src/Internal/ concrete descriptor is prohibited), so reading the decode and encode method
6053
# names off each ScalarCodec is seen as property access on mixed.
6154
- identifier: property.nonObject
6255
path: src/Internal/Deserialization/Resolvers/ScalarCodecResolver.php
6356
- identifier: property.nonObject
6457
path: src/Internal/Serialization/Encoders/ScalarCodecEncoder.php
65-
6658
# Late static binding in the Refunds test fixture mirrors tiny-blocks/collection's extension-point shape.
6759
- identifier: new.static
6860
path: tests/Models/Refunds.php

0 commit comments

Comments
 (0)