Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ include $(_MAKEFILE_DIR)makefiles/PHPUnit.mk
include $(_MAKEFILE_DIR)makefiles/Psalm.mk
include $(_MAKEFILE_DIR)makefiles/Rector.mk
include $(_MAKEFILE_DIR)makefiles/Infection.mk
include $(_MAKEFILE_DIR)makefiles/StructArmed.mk
include $(_MAKEFILE_DIR)makefiles/Utilities.mk

# Include the Tools fragment after all other tooling so that bump and update of stand-alone tools collects all necessary targets
Expand Down
56 changes: 49 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ Other host machine dependencies include:

### Out-of-the-box `Makefile`

Create a Makefile in the project root with the following contents, after installing this dependency via composer:

```makefile
# ./Makefile
include vendor/laminas/internal-tooling/Makefile
```
After copying the shipped `Makefile` template, it will need a few minor adjustments.
These are documented in the template.

Now, running `make` should list a number of useful targets for general QA work on Laminas and Mezzio libraries.

Expand Down Expand Up @@ -96,6 +92,33 @@ When rector is installed to `./tools/rector`
- `make rector` (Run rector with --dry-run)
- `make rector-fix`

### Infection Targets

When infection is installed to `./tools/infection`

- `make infection`

### StructArmed Targets

When [StructArmed](https://boundwize.github.io/structarmed/) is installed to `./tools/structarmed`

- `make structarmed` Runs the analysis
- `make structarmed-fix` Runs auto fixers
- `make structarmed-clear` Clears the cache

### Dependency Management Targets

- `make install` - Often not required because this lib is distributed via composer itself
- `make update` - Runs composer update with the project docker image
- `make bump-dev` - Bumps _development_ dependencies
- `make outdated` - Run `composer outdated`

For tools that are installed in subdirectories, it's a pain to cd to each one and run composer for each tool, therefore these targets operate on all installed tools:

- `make install-tools`
- `make update-tools`
- `make bump-tools`

## Migrations

Migrations represent small units of automation for common or one-off maintenance tasks for Laminas Repos.
Expand Down Expand Up @@ -127,7 +150,26 @@ Install rector into `./tools/rector`
make install-rector
```

For more information about this migration [see the README](migrations/InstallStandaloneRector/README.md).
### Infection Installation

Install [infection](https://infection.github.io/) into `./tools/infection`

```bash
make install-infection
```

By default, the Min MSI is not configured, so tweaking the configuration file may be necessary.
Additionally, depending on what version of PHPUnit is installed, some settings may need adjusting for PHPUnit such as `executionOrder`

### StructArmed Installation

Install [StructArmed](https://boundwize.github.io/structarmed/) into `./tools/structarmed`

```bash
make install-structarmed
```

Once installed, further [configuration](https://boundwize.github.io/structarmed/quick-start/) will be required.

### Psalm Removal

Expand Down
1 change: 1 addition & 0 deletions mago.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ workspace = "."
paths = ["migrations/"]
excludes = [
"migrations/*/templates/rector.php",
"migrations/*/structarmed.php",
]
[analyzer]

Expand Down
57 changes: 57 additions & 0 deletions makefiles/StructArmed.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
STRUCT_ARMED_DIRECTORY ?= $(PROJECT_DIR)tools/structarmed
HAS_STRUCT_ARMED := $(strip $(shell if [ -d $(STRUCT_ARMED_DIRECTORY) ]; then echo TRUE; fi))

ifeq ("$(HAS_STRUCT_ARMED)", "TRUE")

BUMP_TOOLS_TARGETS += structarmed-bump
UPDATE_TOOLS_TARGETS += structarmed-update
INSTALL_TOOLS_TARGETS += structarmed-install

HELP += $(call MK_HELP,'structarmed','Check the codebase with StructArmed')
QA_TARGETS += structarmed
CLEAN_TARGETS += structarmed-clear

structarmed:
@$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) \
$(STRUCT_ARMED_DIRECTORY)/vendor/bin/structarmed \
--config $(STRUCT_ARMED_DIRECTORY)/structarmed.php \
analyze
.PHONY: structarmed

HELP += $(call MK_HELP,'structarmed-fix','Run automatic fixes provided by StructArmed')
structarmed-fix:
@$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) \
$(STRUCT_ARMED_DIRECTORY)/vendor/bin/structarmed \
--config $(STRUCT_ARMED_DIRECTORY)/structarmed.php \
analyze --fix
.PHONY: structarmed-fix

structarmed-clear:
@$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) \
$(STRUCT_ARMED_DIRECTORY)/vendor/bin/structarmed \
--config $(STRUCT_ARMED_DIRECTORY)/structarmed.php \
--clear-cache
.PHONY: structarmed-clear

structarmed-update:
$(DOCKER_RUN) ${DOCKER_IMAGE_NAME} composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
update
.PHONY: structarmed-update

structarmed-install:
$(DOCKER_RUN) ${DOCKER_IMAGE_NAME} composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
install
.PHONY: structarmed-install

structarmed-bump: structarmed-update _do-structarmed-bump structarmed-update
.PHONY: structarmed-bump

_do-structarmed-bump:
$(DOCKER_RUN) ${DOCKER_IMAGE_NAME} composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
bump -D
.PHONY: _do-structarmed-bump

endif
36 changes: 36 additions & 0 deletions migrations/InstallStructArmed/Install.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
_STRUCT_ARMED_MIGRATION_DIRECTORY := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
STRUCT_ARMED_DIRECTORY := $(PROJECT_DIR)tools/structarmed
HAS_STRUCT_ARMED_DIR := $(strip $(shell if [ -d $(STRUCT_ARMED_DIRECTORY) ]; then echo TRUE; fi))

ifneq ("$(HAS_STRUCT_ARMED_DIR)","TRUE")

PROJECT_COMPOSER_PLATFORM := $(shell $(DOCKER_RUN) ${DOCKER_IMAGE_NAME} composer config platform.php)
HELP += $(call MK_HELP,'install-structarmed','Install a standalone copy of structarmed into tools/structarmed')

install-structarmed: $(STRUCT_ARMED_DIRECTORY) _do-install-structarmed
@echo 'Now StructArmed is installed, you should edit its configuration file to define appropriate layers:'
@echo 'https://boundwize.github.io/structarmed/configuration/'
.PHONY: install-structarmed

_do-install-structarmed:
@$(DOCKER_RUN) --env PHP_EXTENSIONS="$(PHP_EXTENSIONS)" ${DOCKER_IMAGE_NAME} php $(_STRUCT_ARMED_MIGRATION_DIRECTORY)migrate $(PROJECT_DIR)
.PHONY: _do-install-structarmed

# Installation routine for rector:
$(STRUCT_ARMED_DIRECTORY):
mkdir -p $(STRUCT_ARMED_DIRECTORY)
echo '{}' > $(STRUCT_ARMED_DIRECTORY)/composer.json
$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
config platform.php $(PROJECT_COMPOSER_PLATFORM)
$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
require --dev boundwize/structarmed
cp $(_STRUCT_ARMED_MIGRATION_DIRECTORY)structarmed.php $(STRUCT_ARMED_DIRECTORY)/
echo vendor > $(STRUCT_ARMED_DIRECTORY)/.gitignore
$(DOCKER_RUN) $(DOCKER_IMAGE_NAME) composer \
--working-dir=$(STRUCT_ARMED_DIRECTORY) \
install
# end

endif
25 changes: 25 additions & 0 deletions migrations/InstallStructArmed/migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use Laminas\Internal\Migrations\GitAttributes;
use Laminas\Internal\Migrations\ProjectInformation;

require __DIR__ . '/../autoloader.php';

/** @var mixed $rootDirectory */
$rootDirectory = $argv[1] ?? null;
if (
! is_string($rootDirectory)
|| $rootDirectory === ''
|| ! is_dir($rootDirectory)
) {
throw new RuntimeException('Pass a single argument representing the root directory of the target library');
}

$project = ProjectInformation::fromDirectory($rootDirectory);

// Ensure that the 'tools' directory is export-ignored
$attributes = new GitAttributes($project->gitAttributes);
$attributes->ignore('tools');
9 changes: 9 additions & 0 deletions migrations/InstallStructArmed/structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;

return Architecture::define()
->withPresets(Preset::PER(), Preset::CODEQUALITY());
1 change: 1 addition & 0 deletions migrations/Migrations.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ include $(_MAKEFILE_DIR)migrations/InstallStandaloneRector/InstallStandaloneRect
include $(_MAKEFILE_DIR)migrations/InstallMago/InstallMago.mk
include $(_MAKEFILE_DIR)migrations/UninstallPsalm/UninstallPsalm.mk
include $(_MAKEFILE_DIR)migrations/InstallInfectionWithMago/Install.mk
include $(_MAKEFILE_DIR)migrations/InstallStructArmed/Install.mk
Loading