Skip to content

Commit cc2d11d

Browse files
authored
Various updates (#232)
1 parent 88ba515 commit cc2d11d

131 files changed

Lines changed: 574 additions & 3077 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
env:
6060
XDEBUG_MODE: off
6161
PSALM: tools/psalm/vendor/bin/psalm
62-
CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
62+
CHANGED_FILES: ${{ steps.changed-php-files.outputs.all_changed_files }}
6363
- name: Psalm on mainline for all files
6464
if: github.ref == 'refs/heads/main'
6565
run: php -dxdebug.mode=off $(PSALM) --ignore-baseline --long-progress --monochrome --output-format=github --report=results.sarif

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
$finder = Finder::create()
1010
->in(__DIR__)
11+
->exclude('build')
1112
->exclude('docs')
1213
->exclude('tools')
1314
->exclude('vendor')

Makefile

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ BARD_COMPILE = src/SonsOfPHP/Bard/bin/compile
99
CHURN = tools/churn/vendor/bin/churn
1010
INFECTION = tools/infection/vendor/bin/infection
1111
PHP_CS_FIXER = tools/php-cs-fixer/vendor/bin/php-cs-fixer
12+
PHPACTOR = tools/phpactor/vendor/bin/phpactor
1213
PHPUNIT = tools/phpunit/vendor/bin/phpunit
1314
PSALM = tools/psalm/vendor/bin/psalm
1415
RECTOR = tools/rector/vendor/bin/rector
1516
# end: Tools
1617

1718
# start: Config Files
18-
PHP_CS_FIXER_CONFIG=.php-cs-fixer.dist.php
19-
RECTOR_CONFIG=rector.php
19+
CHURN_CONFIG = churn.yml
20+
INFECTION_CONFIG = infection.json5
21+
PHP_CS_FIXER_CONFIG = .php-cs-fixer.dist.php
22+
PHPUNIT_CONFIG = phpunit.xml.dist
23+
PSALM_CONFIG = psalm.xml
24+
RECTOR_CONFIG = rector.php
2025
# end: Config Files
2126

2227
# start: Config Options
@@ -49,21 +54,23 @@ help:
4954
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
5055

5156
.PHONY: install
52-
install: vendor $(BARD) $(CHURN) $(INFECTION) $(PHP_CS_FIXER) $(PHPUNIT) $(PSALM) $(RECTOR) ## Install Dependencies
53-
mkdir -p build/{cache,logs}
54-
$(COMPOSER) githooks
57+
install: composer.lock $(BARD) $(CHURN) $(INFECTION) $(PHP_CS_FIXER) $(PHPACTOR) $(PHPUNIT) $(PSALM) $(RECTOR) ## Install Dependencies
58+
@mkdir -p build/{cache,logs,config}
59+
@$(COMPOSER) githooks
5560

5661
.PHONY: update
5762
update: ## Update all the dependencies (root, tools, and packages)
63+
$(info COMPOSER_UPDATE_OPTIONS : $(COMPOSER_UPDATE_OPTIONS))
5864
XDEBUG_MODE=off $(COMPOSER) update $(COMPOSER_UPDATE_OPTIONS)
5965
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/churn $(COMPOSER_UPDATE_OPTIONS)
6066
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/infection $(COMPOSER_UPDATE_OPTIONS)
6167
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/php-cs-fixer $(COMPOSER_UPDATE_OPTIONS)
68+
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/phpactor $(COMPOSER_UPDATE_OPTIONS)
6269
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/phpunit $(COMPOSER_UPDATE_OPTIONS)
6370
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/psalm $(COMPOSER_UPDATE_OPTIONS)
6471
XDEBUG_MODE=off $(COMPOSER) update --working-dir=tools/rector $(COMPOSER_UPDATE_OPTIONS)
6572
@$(MAKE) pkg-update
66-
$(COMPOSER) githooks
73+
@$(COMPOSER) githooks
6774

6875
.PHONY: clean
6976
clean: ## Remove all vendor folders, composer.lock files, and removes build artifacts
@@ -87,8 +94,9 @@ upgrade-code: $(RECTOR) $(PHP_CS_FIXER)
8794

8895
# NOTE: This may make changes to the source code
8996
.PHONY: fix-code
90-
fix-code: upgrade-code
91-
XDEBUG_MODE=off $(PHP) $(PSALM) --alter --issues=all --dry-run
97+
fix-code: PSALM_ISSUES=all
98+
fix-code: upgrade-code $(PSALM)
99+
XDEBUG_MODE=off $(PHP) $(PSALM) --alter --issues=$(PSALM_ISSUES) --dry-run
92100

93101
##---- Testing ------------------------------------------------------------------------
94102
.PHONY: test
@@ -118,7 +126,7 @@ php-cs-fixer: $(PHP_CS_FIXER) ## Run php-cs-fixer (dry-run)
118126

119127
.PHONY: psalm
120128
psalm: $(PSALM) ## Run Psalm
121-
XDEBUG_MODE=off $(PHP) $(PSALM)
129+
XDEBUG_MODE=off $(PHP) $(PSALM) --show-info=true --config=$(PSALM_CONFIG)
122130

123131
.PHONY: psalm-baseline
124132
psalm-baseline: $(PSALM) # Updates the baseline file
@@ -151,6 +159,7 @@ pkg-install: $(BARD) ## Runs `composer install` on each package
151159

152160
.PHONY: pkg-update
153161
pkg-update: $(BARD) ## Runs `composer update` on each package
162+
$(info Bard: composer update)
154163
$(BARD) update -n -vvv
155164

156165
.PHONY: pkg-merge
@@ -167,26 +176,40 @@ $(BARD): src/SonsOfPHP/Bard/composer.lock
167176
src/SonsOfPHP/Bard/composer.lock:
168177
XDEBUG_MODE=off $(COMPOSER) install --working-dir=src/SonsOfPHP/Bard $(COMPOSER_INSTALL_OPTIONS)
169178

170-
$(CHURN):
179+
$(CHURN): tools/churn/composer.lock
180+
181+
tools/churn/composer.lock:
171182
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/churn $(COMPOSER_INSTALL_OPTIONS)
172183

173-
$(INFECTION):
184+
$(INFECTION): tools/infection/composer.lock
185+
186+
tools/infection/composer.lock:
174187
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/infection $(COMPOSER_INSTALL_OPTIONS)
175188

176-
$(PHP_CS_FIXER):
189+
$(PHP_CS_FIXER): tools/php-cs-fixer/composer.lock
190+
191+
tools/php-cs-fixer/composer.lock:
177192
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/php-cs-fixer $(COMPOSER_INSTALL_OPTIONS)
178193

179-
$(PHPUNIT):
194+
$(PHPACTOR): tools/phpactor/composer.lock
195+
196+
tools/phpactor/composer.lock:
197+
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/phpactor $(COMPOSER_INSTALL_OPTIONS)
198+
199+
$(PHPUNIT): tools/phpunit/composer.lock
200+
201+
tools/phpunit/composer.lock:
180202
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/phpunit $(COMPOSER_INSTALL_OPTIONS)
181203

182-
$(PSALM):
204+
$(PSALM): tools/psalm/composer.lock
205+
206+
tools/psalm/composer.lock:
183207
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/psalm $(COMPOSER_INSTALL_OPTIONS)
184208

185-
$(RECTOR):
209+
$(RECTOR): tools/rector/composer.lock
210+
211+
tools/rector/composer.lock:
186212
XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/rector $(COMPOSER_INSTALL_OPTIONS)
187213

188214
composer.lock:
189215
XDEBUG_MODE=off $(COMPOSER) install $(COMPOSER_INSTALL_OPTIONS)
190-
191-
vendor: composer.json composer.lock
192-
XDEBUG_MODE=off $(COMPOSER) install $(COMPOSER_INSTALL_OPTIONS)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
3+
</files>

build/hooks/pre-commit

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ function __info() {
3030
printf "${color_bold_black}${color_background_blue} ℹ️ $1 ${color_reset}\n" >&2
3131
}
3232

33+
function __add_modified_files() {
34+
FILES_TO_ADD=$(git diff --name-only --diff-filter=dM)
35+
FILES_TO_ADD_COUNT=$(wc -w <<< $FILES_TO_ADD | xargs)
36+
if [[ FILES_TO_ADD_COUNT -gt 0 ]]; then
37+
__info "Adding ${FILES_TO_ADD_COUNT} modified files"
38+
git add --verbose $FILES_TO_ADD
39+
fi
40+
}
41+
3342
ROOT=$(git rev-parse --show-toplevel)
3443

3544
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=d -- '*.php')
@@ -44,11 +53,8 @@ __info "Changed File Count: ${CHANGED_FILE_COUNT}"
4453
PHP_CS_FIXER="tools/php-cs-fixer/vendor/bin/php-cs-fixer"
4554
if [[ -x $PHP_CS_FIXER && $CHANGED_FILE_COUNT -gt 0 ]]; then
4655
__info "Running php-cs-fixer"
47-
php -dxdebug.mode=off $PHP_CS_FIXER fix --config=$ROOT/.php-cs-fixer.dist.php --allow-risky=yes -vvv --using-cache=no $CHANGED_FILES
48-
49-
__info "Adding any updated files"
50-
git add $(git diff --cached --name-only)
51-
56+
php -dxdebug.mode=off $PHP_CS_FIXER fix --diff --config=$ROOT/.php-cs-fixer.dist.php --allow-risky=yes -vvv --using-cache=no $CHANGED_FILES
57+
__add_modified_files
5258
__success "php-cs-fixer completed"
5359
else
5460
__info "Skipping php-cs-fixer"
@@ -60,10 +66,7 @@ RECTOR="tools/rector/vendor/bin/rector"
6066
if [[ -x $RECTOR && $CHANGED_FILE_COUNT -gt 0 ]]; then
6167
__info "Running rector"
6268
XDEBUG_MODE=off php -dxdebug.mode=off $RECTOR process $CHANGED_FILES
63-
64-
__info "Adding any updated files"
65-
git add $(git diff --cached --name-only)
66-
69+
__add_modified_files
6770
__success "rector completed"
6871
else
6972
__info "Skipping rector"

0 commit comments

Comments
 (0)