Skip to content

Commit ca071fa

Browse files
committed
feat: apply composer require checker linting
Added missing composer dependencies ci: added support for phive style: applied composer normalize ci: added support for commitlint and commitizen to support conventional-commits ci: added rhysd/actionlint to lint github actions
1 parent 31e40d9 commit ca071fa

File tree

11 files changed

+555
-294
lines changed

11 files changed

+555
-294
lines changed

.github/.commitlint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js
2+
const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/
3+
4+
export default {
5+
extends: ['@commitlint/config-conventional'],
6+
/*
7+
This resolves a linting conflict between commitlint's body-max-line-length
8+
due to @semantic-release/git putting release notes in the commit body
9+
https://github.com/semantic-release/git/issues/331
10+
*/
11+
ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)],
12+
rules: {
13+
'body-leading-blank': [1, 'always'],
14+
'body-max-line-length': [2, 'always', 120],
15+
'footer-leading-blank': [1, 'always'],
16+
'footer-max-line-length': [2, 'always', 120],
17+
'header-max-length': [2, 'always', 100],
18+
'scope-case': [2, 'always', 'lower-case'],
19+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
20+
'subject-empty': [2, 'never'],
21+
'subject-full-stop': [2, 'never', '.'],
22+
'type-case': [2, 'always', 'lower-case'],
23+
'type-empty': [2, 'never'],
24+
'type-enum': [
25+
2,
26+
'always',
27+
[
28+
'feat', // New feature
29+
'fix', // Bug fix
30+
'perf', // Performance improvement
31+
'docs', // Documentation changes
32+
'style', // Code style update (formatting, missing semi colons, etc)
33+
'deps', // Dependency updates
34+
'refactor', // Code refactoring
35+
'ci', // Continuous integration changes
36+
'test', // Adding missing tests
37+
'revert', // Revert to a previous commit
38+
'build', // Changes that affect the build system
39+
'chore', // Other changes that don't modify src or test files
40+
'security', // Security improvements
41+
],
42+
],
43+
},
44+
}

.github/.cz.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// @see https://cz-git.qbb.sh/config/#configure-template
2+
module.exports = {
3+
alias: { fd: 'docs: fix typos' },
4+
messages: {
5+
type: 'Select the type of change that you\'re committing:',
6+
scope: 'Denote the SCOPE of this change (optional):',
7+
customScope: 'Denote the SCOPE of this change:',
8+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
9+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
10+
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
11+
footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):',
12+
customFooterPrefix: 'Input ISSUES prefix:',
13+
footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
14+
generatingByAI: 'Generating your AI commit subject...',
15+
generatedSelectByAI: 'Select suitable subject by AI generated:',
16+
confirmCommit: 'Are you sure you want to proceed with the commit above?'
17+
},
18+
types: [
19+
{ value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:' },
20+
{ value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' },
21+
{ value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' },
22+
{ value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' },
23+
{ value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' },
24+
{ value: 'deps', name: 'deps: A dependency update', emoji: ':package:' },
25+
{ value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' },
26+
{ value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' },
27+
{ value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' },
28+
{ value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' },
29+
{ value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' },
30+
{ value: 'chore', name: 'chore: Other changes that don\'t modify src or test files', emoji: ':hammer:' },
31+
{ value: 'security', name: 'security: A code change that fixes a security issue', emoji: ':lock:' }
32+
],
33+
useEmoji: false,
34+
emojiAlign: 'center',
35+
useAI: false,
36+
aiNumber: 1,
37+
themeColorCode: '',
38+
scopes: [],
39+
allowCustomScopes: true,
40+
allowEmptyScopes: true,
41+
customScopesAlign: 'bottom',
42+
customScopesAlias: 'custom',
43+
emptyScopesAlias: 'empty',
44+
upperCaseSubject: false,
45+
markBreakingChangeMode: false,
46+
allowBreakingChanges: ['feat', 'fix'],
47+
breaklineNumber: 100,
48+
breaklineChar: '|',
49+
skipQuestions: [],
50+
issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }],
51+
customIssuePrefixAlign: 'top',
52+
emptyIssuePrefixAlias: 'skip',
53+
customIssuePrefixAlias: 'custom',
54+
allowCustomIssuePrefix: true,
55+
allowEmptyIssuePrefix: true,
56+
confirmColorize: true,
57+
maxHeaderLength: Infinity,
58+
maxSubjectLength: Infinity,
59+
minSubjectLength: 0,
60+
scopeOverrides: undefined,
61+
defaultBody: '',
62+
defaultIssues: '',
63+
defaultScope: '',
64+
defaultSubject: ''
65+
}

.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

.phive/phars.xml

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

Makefile

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
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
912
DOCKER_COMPOSE ?= docker compose
1013

@@ -25,13 +28,27 @@ BUILDER_WIRED ?= $(BUILDER_PARAMS) --network project.$(COMPOSE_PROJECT_NAME) $(S
2528
# Shorthand envsubst command, executed through build-deps
2629
ENVSUBST ?= $(BUILDER) envsubst
2730

28-
EXPORT_VARS = '\
29-
$${COMPOSE_PROJECT_NAME} \
30-
$${COMPOSER_AUTH}'
31+
# Yamllint docker image
32+
YAML_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
33+
-v $(PWD):/data \
34+
cytopia/yamllint:latest \
35+
-f colored .
36+
37+
ACTION_LINT_RUNNER ?= $(DOCKER) run --rm $$(tty -s && echo "-it" || echo) \
38+
-v $(shell pwd):/repo \
39+
--workdir /repo \
40+
rhysd/actionlint:latest \
41+
-color
42+
43+
PHIVE_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app
3144

3245
NPM_RUNNER ?= pnpm
3346

47+
EXPORT_VARS = '\
48+
$${COMPOSE_PROJECT_NAME} \
49+
$${COMPOSER_AUTH}'
3450

51+
#
3552
# Self documenting Makefile code
3653
# ------------------------------------------------------------------------------------
3754
ifneq ($(TERM),)
@@ -71,17 +88,19 @@ help:
7188
@echo ' 📦 Package laravel-cycle-orm-adapter (github.com/wayofdev/laravel-cycle-orm-adapter)'
7289
@echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
7390
@echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
91+
@echo
7492
.PHONY: help
7593

7694
.EXPORT_ALL_VARIABLES:
7795

96+
#
7897
# Default action
7998
# Defines default command when `make` is executed without additional parameters
8099
# ------------------------------------------------------------------------------------
81-
all: install hooks
100+
all: env prepare install hooks phive up
82101
.PHONY: all
83102

84-
103+
#
85104
# System Actions
86105
# ------------------------------------------------------------------------------------
87106
env: ## Generate .env file from example, use `make env force=true`, to force re-create file
@@ -101,7 +120,7 @@ prepare:
101120
mkdir -p .build/php-cs-fixer
102121
.PHONY: prepare
103122

104-
123+
#
105124
# Docker Actions
106125
# ------------------------------------------------------------------------------------
107126
up: # Creates and starts containers, defined in docker-compose and override file
@@ -135,7 +154,7 @@ ssh: ## Login inside running docker container
135154
$(APP_RUNNER) sh
136155
.PHONY: ssh
137156

138-
157+
#
139158
# Composer
140159
# ------------------------------------------------------------------------------------
141160
install: ## Installs composer dependencies
@@ -146,21 +165,30 @@ update: ## Updates composer dependencies by running composer update command
146165
$(APP_COMPOSER) update
147166
.PHONY: update
148167

168+
phive: ## Installs dependencies with phive
169+
$(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0x033E5F8D801A2F8D
170+
.PHONY: phive
149171

150-
# Code Quality, Git, Linting, Testing
172+
#
173+
# Code Quality, Git, Linting
151174
# ------------------------------------------------------------------------------------
152175
hooks: ## Install git hooks from pre-commit-config
153176
pre-commit install
177+
pre-commit install --hook-type commit-msg
154178
pre-commit autoupdate
155179
.PHONY: hooks
156180

157-
lint: lint-yaml lint-php lint-stan ## Runs all linting commands
181+
lint: lint-yaml lint-actions lint-php lint-stan lint-composer lint-audit ## Runs all linting commands
158182
.PHONY: lint
159183

160184
lint-yaml: ## Lints yaml files inside project
161-
yamllint .
185+
@$(YAML_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
162186
.PHONY: lint-yaml
163187

188+
lint-actions: ## Lint all github actions
189+
@$(ACTION_LINT_RUNNER) | tee -a $(MAKE_LOGFILE)
190+
.PHONY: lint-actions
191+
164192
lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer
165193
$(APP_COMPOSER) cs:fix
166194
.PHONY: lint-php
@@ -177,6 +205,51 @@ lint-stan-ci:
177205
$(APP_COMPOSER) stan:ci
178206
.PHONY: lint-stan-ci
179207

208+
lint-stan-baseline: ## Runs phpstan to update its baseline
209+
$(APP_COMPOSER) stan:baseline
210+
.PHONY: lint-stan-baseline
211+
212+
lint-psalm: ## Runs vimeo/psalm – static analysis tool
213+
$(APP_COMPOSER) psalm
214+
.PHONY: lint-psalm
215+
216+
lint-psalm-ci: ## Runs vimeo/psalm – static analysis tool with github output (CI mode)
217+
$(APP_COMPOSER) psalm:ci
218+
.PHONY: lint-psalm-ci
219+
220+
lint-psalm-baseline: ## Runs vimeo/psalm to update its baseline
221+
$(APP_COMPOSER) psalm:baseline
222+
.PHONY: lint-psalm-baseline
223+
224+
lint-deps: ## Runs composer-require-checker – checks for dependencies that are not used
225+
$(APP_RUNNER) .phive/composer-require-checker check \
226+
--config-file=/app/composer-require-checker.json \
227+
--verbose
228+
.PHONY: lint-deps
229+
230+
lint-composer: ## Normalize composer.json and composer.lock files
231+
$(APP_COMPOSER) normalize
232+
.PHONY: lint-composer
233+
234+
lint-audit: ## Runs security checks for composer dependencies
235+
$(APP_COMPOSER) audit
236+
.PHONY: lint-security
237+
238+
refactor: ## Runs rector – code refactoring tool
239+
$(APP_COMPOSER) refactor
240+
.PHONY: refactor
241+
242+
#
243+
# Testing
244+
# ------------------------------------------------------------------------------------
245+
infect: ## Runs mutation tests with infection/infection
246+
$(APP_COMPOSER) infect
247+
.PHONY: infect
248+
249+
infect-ci: ## Runs infection – mutation testing framework with github output (CI mode)
250+
$(APP_COMPOSER) infect:ci
251+
.PHONY: lint-infect-ci
252+
180253
test: ## Run project php-unit and pest tests
181254
$(APP_COMPOSER) test
182255
.PHONY: test
@@ -185,6 +258,14 @@ test-cc: ## Run project php-unit and pest tests in coverage mode and build repor
185258
$(APP_COMPOSER) test:cc
186259
.PHONY: test-cc
187260

261+
#
262+
# Release
263+
# ------------------------------------------------------------------------------------
264+
commit:
265+
czg commit --config="./.github/.cz.config.js"
266+
.PHONY: commit
267+
268+
#
188269
# Documentation
189270
# ------------------------------------------------------------------------------------
190271
docs-deps-update: ## Check for outdated dependencies and automatically update them using pnpm

composer-require-checker.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"symbol-whitelist": [
3+
"Laravel\\Telescope\\IncomingEntry",
4+
"Laravel\\Telescope\\Telescope",
5+
"Laravel\\Telescope\\Watchers\\FetchesStackTrace",
6+
"Laravel\\Telescope\\Watchers\\Watcher",
7+
"PHPUnit\\Framework\\Constraint\\Constraint",
8+
"PHPUnit\\Framework\\Constraint\\LogicalNot"
9+
]
10+
}

0 commit comments

Comments
 (0)