Skip to content

Commit bb77426

Browse files
committed
ci: add support for phive
ci: update Makefile with latest commands ci(docker-compose): add healthcheck for pgsql database ci(composer-require-checker): lint project files
1 parent 767de29 commit bb77426

File tree

7 files changed

+199
-643
lines changed

7 files changed

+199
-643
lines changed

Makefile

Lines changed: 105 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
# https://docs.docker.com/compose/environment-variables/envvars/
66
export DOCKER_BUILDKIT ?= 1
77

8+
# Docker binary to use, when executing docker tasks
9+
DOCKER ?= docker
10+
811
# Binary to use, when executing docker-compose tasks
9-
DOCKER_COMPOSE ?= docker compose
12+
DOCKER_COMPOSE ?= $(DOCKER) compose
1013

1114
# Support image with all needed binaries, like envsubst, mkcert, wait4x
1215
SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest
1316

1417
APP_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app
15-
APP_EXEC ?= $(DOCKER_COMPOSE) exec app
1618
APP_COMPOSER ?= $(APP_RUNNER) composer
19+
APP_EXEC ?= $(DOCKER_COMPOSE) exec app
1720

1821
BUILDER_PARAMS ?= docker run --rm -i \
1922
--env-file ./.env \
@@ -32,14 +35,34 @@ WAITER ?= $(BUILDER_WIRED) wait4x
3235
# Shorthand envsubst command, executed through build-deps
3336
ENVSUBST ?= $(BUILDER) envsubst
3437

38+
# Yamllint docker image
39+
YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
40+
-v $(PWD):/data \
41+
cytopia/yamllint:latest \
42+
-c ./.github/.yamllint.yaml \
43+
-f colored .
44+
45+
ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
46+
-v $(shell pwd):/repo \
47+
--workdir /repo \
48+
rhysd/actionlint:latest \
49+
-color
50+
51+
MARKDOWN_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
52+
-v $(shell pwd):/app \
53+
--workdir /app \
54+
davidanson/markdownlint-cli2-rules:latest
55+
56+
PHIVE_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app
57+
3558
EXPORT_VARS = '\
3659
$${APP_NAME} \
3760
$${COMPOSE_PROJECT_NAME} \
3861
$${PROJECT_SERVICES_NAMESPACE} \
3962
$${SHARED_SERVICES_NAMESPACE} \
4063
$${COMPOSER_AUTH}'
4164

42-
65+
#
4366
# Self documenting Makefile code
4467
# ------------------------------------------------------------------------------------
4568
ifneq ($(TERM),)
@@ -63,35 +86,35 @@ else
6386
WHITE := ""
6487
RST := ""
6588
endif
66-
MAKE_LOGFILE = /tmp/laravel-starter-tpl.log
89+
MAKE_LOGFILE = /tmp/wayofdev-laravel-starter-tpl.log
6790
MAKE_CMD_COLOR := $(BLUE)
6891

6992
default: all
7093

7194
help: ## Show this menu
72-
echo ${MAKEFILE_LIST}
73-
74-
@echo 'Management commands for package:'
95+
@echo 'Management commands for project:'
7596
@echo 'Usage:'
7697
@echo ' ${MAKE_CMD_COLOR}make${RST} Prepares and spins up project with default settings'
7798
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
7899
@echo
79100
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
80101
@echo
81-
@echo ' 📦 Package laravel-starter-tpl (github.com/wayofdev/laravel-starter-tpl)'
82-
@echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
83-
@echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
102+
@echo ' 📦 Project laravel-starter-tpl (https://github.com/wayofdev/laravel-starter-tpl)'
103+
@echo ' 🤠 Author Andrij Orlenko (https://github.com/lotyp)'
104+
@echo ' 🏢 ${YELLOW}Org wayofdev (https://github.com/wayofdev)${RST}'
105+
@echo
84106
.PHONY: help
85107

86108
.EXPORT_ALL_VARIABLES:
87109

110+
#
88111
# Default action
89112
# Defines default command when `make` is executed without additional parameters
90113
# ------------------------------------------------------------------------------------
91114
all: hooks install key prepare up
92115
.PHONY: all
93116

94-
117+
#
95118
# System Actions
96119
# ------------------------------------------------------------------------------------
97120
override-create: ## Generate override file from dist
@@ -119,23 +142,31 @@ prepare:
119142
mkdir -p app/.build/php-cs-fixer
120143
.PHONY: prepare
121144

122-
145+
#
123146
# Docker Actions
124147
# ------------------------------------------------------------------------------------
125148
up: # Creates and starts containers, defined in docker-compose and override file
126149
$(DOCKER_COMPOSE) up --remove-orphans -d
150+
@sleep 1
127151
$(DOCKER_COMPOSE) exec app wait4x postgresql 'postgres://${DB_USERNAME}:${DB_PASSWORD}@database:5432/${DB_DATABASE}?sslmode=disable' -t 1m
128152
.PHONY: up
129153

130154
down: # Stops and removes containers of this project
131155
$(DOCKER_COMPOSE) down --remove-orphans
132156
.PHONY: down
133157

158+
purge: ## Stops and removes containers, volumes, networks and images
159+
$(DOCKER_COMPOSE) down --remove-orphans --volumes
160+
$(DOCKER) network prune --force
161+
$(DOCKER) volume prune --force
162+
$(DOCKER) image prune --force
163+
.PHONY: purge
164+
134165
restart: down up ## Runs down and up commands
135166
.PHONY: restart
136167

137-
clean: ## Stops containers if required and removes from system
138-
$(DOCKER_COMPOSE) rm --force --stop
168+
clean: ## Stops and removes containers of this project together with volumes
169+
$(DOCKER_COMPOSE) rm --force --stop --volumes
139170
.PHONY: clean
140171

141172
ps: ## List running project containers
@@ -154,18 +185,57 @@ ssh: ## Login inside running docker container
154185
$(APP_EXEC) sh
155186
.PHONY: ssh
156187

188+
#
189+
# Composer Commands
190+
# ------------------------------------------------------------------------------------
191+
install: ## Install composer dependencies
192+
$(APP_COMPOSER) install
193+
.PHONY: install
194+
195+
update: ## Update composer dependencies
196+
$(APP_COMPOSER) update $(package)
197+
.PHONY: update
198+
199+
du: ## Dump composer autoload
200+
$(APP_COMPOSER) dump-autoload
201+
.PHONY: du
157202

158-
# Code Quality, Git, Linting, Testing
203+
show: ## Shows information about installed composer packages
204+
$(APP_COMPOSER) show
205+
.PHONY: show
206+
207+
phive: ## Installs dependencies with phive
208+
$(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39
209+
.PHONY: phive
210+
211+
#
212+
# Code Quality, Git, Linting
159213
# ------------------------------------------------------------------------------------
160214
hooks: ## Install git hooks from pre-commit-config
161215
pre-commit install
216+
pre-commit install --hook-type commit-msg
162217
pre-commit autoupdate
163218
.PHONY: hooks
164219

220+
lint: lint-yaml lint-actions lint-md lint-php lint-stan lint-composer lint-audit ## Runs all linting commands
221+
.PHONY: lint
222+
165223
lint-yaml: ## Lints yaml files inside project
166-
yamllint .
224+
@$(YAML_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
167225
.PHONY: lint-yaml
168226

227+
lint-actions: ## Lint all github actions
228+
@$(ACTION_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
229+
.PHONY: lint-actions
230+
231+
lint-md: ## Lint all markdown files using markdownlint-cli2
232+
@$(MARKDOWN_LINT_RUNNER) --fix "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE)
233+
.PHONY: lint-md
234+
235+
lint-md-dry: ## Lint all markdown files using markdownlint-cli2 in dry-run mode
236+
@$(MARKDOWN_LINT_RUNNER) "**/*.md" "!CHANGELOG.md" "!app/vendor" "!app/node_modules" | tee -a $(MAKE_LOGFILE)
237+
.PHONY: lint-md-dry
238+
169239
lint-php: ## Lints php files inside project using php-cs-fixer
170240
$(APP_COMPOSER) cs:fix
171241
.PHONY: lint-php
@@ -182,10 +252,27 @@ lint-stan-baseline: ## Runs phpstan to update its baseline
182252
$(APP_COMPOSER) stan:baseline
183253
.PHONY: lint-stan-baseline
184254

185-
lint-deps:
186-
$(APP_COMPOSER) deptrac
255+
lint-deps: ## Runs composer-require-checker – checks for dependencies that are not used
256+
$(APP_RUNNER) .phive/composer-require-checker check \
257+
--config-file=/app/composer-require-checker.json \
258+
--verbose
187259
.PHONY: lint-deps
188260

261+
lint-ddd-deps:
262+
$(APP_RUNNER) .phive/deptrac
263+
.PHONY: lint-ddd-deps
264+
265+
lint-composer: ## Normalize composer.json and composer.lock files
266+
$(APP_RUNNER) .phive/composer-normalize normalize
267+
.PHONY: lint-composer
268+
269+
lint-audit: ## Runs security checks for composer dependencies
270+
$(APP_COMPOSER) audit
271+
.PHONY: lint-security
272+
273+
#
274+
# Testing
275+
# ------------------------------------------------------------------------------------
189276
test: ## Run project php-unit and pest tests
190277
$(APP_COMPOSER) test
191278
.PHONY: test
@@ -199,23 +286,7 @@ api-docs: ## Generate openapi docs specification file
199286
.PHONY: api-docs
200287

201288

202-
# Composer Commands
203-
# ------------------------------------------------------------------------------------
204-
install: ## Install composer dependencies
205-
$(APP_COMPOSER) install
206-
.PHONY: install
207289

208-
update: ## Update composer dependencies
209-
$(APP_COMPOSER) update $(package)
210-
.PHONY: update
211-
212-
du: ## Dump composer autoload
213-
$(APP_COMPOSER) dump-autoload
214-
.PHONY: du
215-
216-
show: ## Shows information about installed composer packages
217-
$(APP_COMPOSER) show
218-
.PHONY: show
219290

220291

221292
# Database Commands

app/.phive/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!phars.xml

app/.phive/phars.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="composer-normalize" version="^2.42.0" installed="2.42.0" location="./.phive/composer-normalize" copy="false"/>
4+
<phar name="composer-require-checker" version="^4.11.0" installed="4.11.0" location="./.phive/composer-require-checker" copy="false"/>
5+
<phar name="deptrac" version="^2.0.0" installed="2.0.0" location="./.phive/deptrac" copy="false"/>
6+
</phive>

app/composer-require-checker.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"symbol-whitelist": [
3+
"Symfony\\Component\\HttpFoundation\\Request",
4+
"Symfony\\Component\\HttpFoundation\\Response"
5+
]
6+
}

0 commit comments

Comments
 (0)