Skip to content

Commit 4e6274b

Browse files
committed
chore(pkg): add shared code and runner
1 parent fdad1e8 commit 4e6274b

File tree

23 files changed

+478
-1166
lines changed

23 files changed

+478
-1166
lines changed

booster/.github/CONTRIBUTING.md

Lines changed: 98 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,30 @@ contribution.
66
## Table of Contents
77

88
- [Contributions](#contributions)
9-
- [Initial Setup](#initial-setup)
10-
- [Contributing](#contributing)
11-
- [Branch Naming](#branch-naming)
12-
- [Commit Message Format](#commit-message-format)
13-
- [Developer Tooling](#developer-tooling)
14-
- [Environment Variables](#environment-variables)
15-
- [Hook Footers](#hook-footers)
16-
- [Configuration Reference](#configuration-reference)
17-
- [Common Workflow Examples](#common-workflow-examples)
18-
- [Performance Monitoring](#performance-monitoring)
19-
- [Troubleshooting](#troubleshooting)
20-
- [Tools We Use](#tools-we-use)
21-
- [Required Visual Studio Code Extensions](#required-visual-studio-code-extensions)
22-
- [Required PHPStorm Extensions](#required-phpstorm-extensions)
23-
- [Code Quality with SonarQube](#code-quality-with-sonarqube)
9+
- [Initial Setup](#initial-setup)
10+
- [Contributing](#contributing)
11+
- [Branch Naming](#branch-naming)
12+
- [Developer Tooling](#developer-tooling)
13+
- [Environment Variables](#environment-variables)
14+
- [Hook Footers](#hook-footers)
15+
- [Commit Messages](#commit-messages)
16+
- [Tools We Use](#tools-we-use)
17+
- [Required Visual Studio Code Extensions](#required-visual-studio-code-extensions)
18+
- [Required PHPStorm Extensions](#required-phpstorm-extensions)
19+
- [Code Quality with SonarQube](#code-quality-with-sonarqube)
2420

2521
## Initial setup
2622

27-
1. Clone the repository to your own machine
28-
2. Check out the `main` branch
29-
3. Set up the project locally
30-
4. Install composer and node dependencies
31-
5. Ensure you can run the project
23+
Please refer to the [README.md](../README.md#local-development-environment) for instructions on setting up the local development environment.
3224

3325
## Contributing
3426

3527
1. Pick a ticket from JIRA or Easy Red Mine
3628
2. Create a new branch from `main` (see below)
3729
3. Make your changes:
38-
1. Code according to our style guidelines (see below).
39-
2. Commit your changes: Use conventional commits (see below)
40-
3. Create a PR and assign it to someone for code review
30+
4. Code according to our style guidelines (see below).
31+
5. Commit your changes: Use conventional commits (see below)
32+
6. Create a PR and assign it to someone for code review
4133

4234
## Conventions used
4335

@@ -49,28 +41,43 @@ clean and readable.
4941
Enforced automatically via the `commit-msg` git hook (see `validate-branch-name.config.cjs`).
5042

5143
Format:
44+
5245
```
5346
<type>/[<ticket-id>-]<description>
5447
```
48+
5549
Where:
56-
* `type``feature|fix|chore|story|task|bug|sub-task`
57-
* Optional `ticket-id` matches `(PRJ|ERM)-<number>` and when present must be followed by a dash and description parts
58-
* Description: alphanumeric segments separated by single dashes (no leading/trailing/consecutive dashes)
59-
* Skipped branches (not validated): `wip`, `main`, `master`, `develop/test`, `develop/host1`, `develop/host2`
50+
51+
- `type``feature|fix|chore|story|task|bug|sub-task`
52+
- Optional `ticket-id` matches `(PRJ|ERM)-<number>` and when present must be followed by a dash and description parts
53+
- Description: alphanumeric segments separated by single dashes (no leading/trailing/consecutive dashes)
54+
- Skipped branches (not validated): `wip`, `main`, `master`, `develop/test`, `develop/host1`, `develop/host2`
6055

6156
Examples:
62-
* `feature/PRJ-1234-add-login-feature`
63-
* `fix/ERM-5678-correct-auth-bug`
64-
* `chore/update-dependencies`
57+
58+
- `feature/PRJ-1234-add-login-feature`
59+
- `fix/ERM-5678-correct-auth-bug`
60+
- `chore/update-dependencies`
6561

6662
If the ticket pattern is enabled in config and you use a ticket prefix, it must include the number (e.g. `PRJ-123-...`).
6763

68-
### Commit Message Format
64+
### Commits and commit messages
65+
66+
Commit Size: Aim for small, focused commits that address a single issue or feature
67+
Commit Messages: Follow the Conventional Commits specification
68+
69+
We use Conventional Commits to maintain a clear and informative commit history. This helps us automate changelog
70+
generation, versioning, and other project
71+
management tasks.
72+
73+
### Commit Messages
6974

7075
Follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for clear and consistent commit messages.
7176

7277
Each commit message should adhere to the following format:
7378

79+
#### Format
80+
7481
```
7582
<type>[optional scope]: <description>
7683
@@ -79,14 +86,20 @@ Each commit message should adhere to the following format:
7986
[optional footer(s)]
8087
```
8188

82-
Where:
83-
- **type**: The type of change (e.g., feat, fix, chore, docs)
84-
- **scope** (optional): The area of the codebase affected
85-
- **description**: A brief summary of the change
86-
- **body** (optional): Detailed explanation, if needed
87-
- **footer(s)** (optional): Additional info like breaking changes or issue references
89+
- type: The type of change (e.g., feat, fix, chore, docs, etc.).
90+
- scope (optional): The scope of the change (e.g., the component or module affected).
91+
- description: A brief description of the change.
92+
- body (optional): A more detailed explanation of the change, if necessary.
93+
- footer(s) (optional): Additional information like breaking changes or issue references (e.g., "BREAKING CHANGE: ..."
94+
or "Fixes #123").
95+
- **type**: The type of change (e.g., feat, fix, chore, docs).
96+
- **scope** (optional): The area of the codebase affected.
97+
- **description**: A brief summary of the change.
98+
- **body** (optional): Detailed explanation, if needed.
99+
- **footer(s)** (optional): Additional info like breaking changes or issue references.
100+
101+
#### Examples
88102

89-
Examples:
90103
- `feat: add user authentication`
91104
- `fix(auth): correct password validation error`
92105
- `chore: update dependencies`
@@ -96,93 +109,72 @@ Commitlint plus the `commit-msg` hook will append the ticket footer automaticall
96109

97110
### Developer Tooling
98111

99-
Git hooks (TypeScript/ZX-based, see `.husky/`) enforce naming, formatting and static analysis:
100-
* `commit-msg`: branch validation, commitlint, ticket footer insertion
101-
* `pre-commit`: PHP lint, Rector, ECS, Deptrac, PHPStan, Psalm (auto-fix where possible)
102-
* `pre-push`: Deptrac, tests, API spec & HTML doc generation (conditional)
103-
104-
### Environment Variables
105-
106-
| Variable | Effect |
107-
|----------|--------|
108-
| **Global Hook Control** | |
109-
| `SKIP_PRECOMMIT=1` | Skips the entire pre-commit hook (for emergency commits). |
110-
| `SKIP_PREPUSH=1` | Skips the entire pre-push hook (for emergency commits). |
111-
| `SKIP_COMMITMSG=1` | Skips the entire commit-msg hook (for emergency commits). |
112-
| `GIT_HOOKS_VERBOSE=1` | Enable verbose output for all git hooks (debugging). |
113-
| **Tool-specific Skip Controls (pre-commit)** | |
114-
| `SKIP_RECTOR=1` | Skip Rector refactoring. |
115-
| `SKIP_ECS=1` | Skip ECS code style fixes. |
116-
| `SKIP_PHPSTAN=1` | Skip PHPStan static analysis. |
117-
| `SKIP_PSALM=1` | Skip Psalm static analysis. |
118-
| `SKIP_DEPTRAC=1` | Skip Deptrac architecture analysis. |
119-
| **Tool-specific Skip Controls (pre-push)** | |
120-
| `SKIP_PHPUNIT=1` | Skip PHPUnit tests. |
121-
| `SKIP_API_DOCS=1` | Skip API documentation generation. |
112+
Git hooks (managed via Husky and `zx`) enforce naming, formatting and static analysis.
113+
114+
**Hooks:**
115+
116+
- `commit-msg`: Validates branch name and commit message format. Appends ticket ID footer.
117+
- `pre-commit`: Runs linters and static analysis.
118+
- **PHP**: Rector, PHPStan, Psalm, EasyCodingStandard.
119+
- **JS/TS**: ESLint, Prettier, Stylelint.
120+
- `pre-push`: Runs tests (`Pest`) and generates API documentation.
121+
122+
### Environment Variables (Skipping Checks)
123+
124+
For a complete list of environment variables to skip specific checks (e.g., `SKIP_PRECOMMIT`, `SKIP_PHPSTAN`), please refer to the [Git Hooks Documentation](../.husky/README.md#environment-variables).
122125

123126
### Hook Footers
124127

125128
If a ticket is required & detected, the hook appends a footer:
129+
126130
```
127131
Closes: PRJ-123
128132
```
133+
129134
Footer label is configurable via `commitFooterLabel` in `validate-branch-name.config.cjs`. Valid characters: alphanumeric, `_`, `-` (must start with a letter). Default: `Closes`.
130135

131136
### Configuration Reference (`validate-branch-name.config.cjs`)
132137

133-
| Key | Description |
134-
|-----|-------------|
135-
| `types` | Allowed branch type prefixes. |
136-
| `ticketIdPrefix` | Alternation of allowed ticket prefixes (e.g. `PRJ|ERM`). |
137-
| `ticketNumberPattern` | Numeric pattern for ticket IDs. |
138-
| `namePattern` | Pattern for the descriptive part. |
139-
| `skipped` | Branch names bypassing validation. |
140-
| `commitFooterLabel` | Footer label appended with ticket ID. |
141-
142-
### Common Workflow Examples
143-
144-
```bash
145-
# Skip just static analysis for a quick commit
146-
SKIP_PHPSTAN=1 SKIP_PSALM=1 git commit -m "fix: urgent hotfix"
147-
148-
# Skip specific tools
149-
SKIP_RECTOR=1 git commit -m "refactor: manual cleanup"
150-
151-
# Emergency commit bypassing all validation
152-
SKIP_PRECOMMIT=1 SKIP_COMMITMSG=1 git commit -m "hotfix: emergency fix"
138+
| Key | Description |
139+
| --------------------- | ------------------------------------------------- | ------ |
140+
| `types` | Allowed branch type prefixes. |
141+
| `ticketIdPrefix` | Alternation of allowed ticket prefixes (e.g. `PRJ | ERM`). |
142+
| `ticketNumberPattern` | Numeric pattern for ticket IDs. |
143+
| `namePattern` | Pattern for the descriptive part. |
144+
| `skipped` | Branch names bypassing validation. |
145+
| `commitFooterLabel` | Footer label appended with ticket ID. |
153146

154-
# Skip tests and documentation before push
155-
SKIP_PHPUNIT=1 SKIP_API_DOCS=1 git push
156-
157-
# Verbose output for debugging
158-
GIT_HOOKS_VERBOSE=1 git commit -m "feat: new feature"
159-
```
147+
### Troubleshooting
160148

161-
### Performance Monitoring
149+
| Issue | Resolution |
150+
| --------------- | ----------------------------------------------------------------------------- |
151+
| Branch rejected | Check branch name format against `validate-branch-name.config.cjs` rules. |
152+
| Missing footer | Ensure branch has valid ticket segment & config has prefixes. |
153+
| Slow pre-commit | Use `SKIP_...` variables if necessary (e.g. `SKIP_PHPSTAN=1 git commit ...`). |
162154

163-
All git hooks now include built-in performance monitoring:
155+
## Tools We Use
164156

165-
- **Individual tool timing**: Each tool shows execution time (e.g., "PHPStan completed successfully (2.3s)")
166-
- **Total execution time**: Hooks display total time taken (e.g., "All pre-commit checks passed! (Total time: 8.7s)")
167-
- **Failed tool timing**: Even failed tools show how long they ran before failing
168-
- **Performance insights**: Use `GIT_HOOKS_VERBOSE=1` to see detailed output and identify slow tools
157+
### Linters & Static Analysis
169158

170-
### Troubleshooting
159+
This project uses the following tools to ensure code quality. Most run automatically via git hooks, but you can run them manually via `ddev`.
171160

172-
| Issue | Resolution |
173-
|-------|------------|
174-
| Branch rejected | Check branch name format against `validate-branch-name.config.cjs` rules. |
175-
| Missing footer | Ensure branch has valid ticket segment & config has prefixes. |
176-
| Slow pre-commit | Use `SKIP_PRECOMMIT=1`, or tool-specific skips (e.g., `SKIP_PHPSTAN=1 SKIP_PSALM=1`). Check performance timing to identify slow tools. |
177-
| Emergency commit needed | Use `SKIP_PRECOMMIT=1` + `SKIP_COMMITMSG=1` for complete bypass. |
178-
| Performance analysis | Enable `GIT_HOOKS_VERBOSE=1` to see detailed tool execution times and identify bottlenecks. |
161+
- **[Rector](https://getrector.org/)**: PHP refactoring and upgrades.
162+
- Command: `ddev composer rector`
163+
- Config: `rector.php`
164+
- **[PHPStan](https://phpstan.org/)**: PHP static analysis.
165+
- Command: `ddev composer phpstan`
166+
- Config: `phpstan.neon.dist`
167+
- **[Psalm](https://psalm.dev/)**: PHP static analysis.
168+
- Command: `ddev composer psalm`
169+
- Config: `psalm.xml`
170+
- **[EasyCodingStandard (ECS)](https://github.com/easy-coding-standard/easy-coding-standard)**: PHP coding standard enforcement (PSR-12).
171+
- Command: `ddev composer ecs` (check) or `ddev composer fix-cs` (fix)
172+
- Config: `ecs.php`
173+
- **JS/TS Tools**: `ESLint`, `Prettier`, `Stylelint`.
179174

180-
## Tools We Use
175+
### Git Hooks
181176

182-
- We use [ZX](https://google.github.io/zx/) for TypeScript-based git hooks that enforce code quality and commit message standards.
183-
- We use [CommitLint](https://commitlint.js.org/) to ensure that all commit messages follow the Conventional Commits specification.
184-
- We use a pull request template to ensure consistent and informative pull requests.
185-
- For detailed git hooks documentation, see the project's Git Hooks documentation.
177+
We use [Husky](https://typicode.github.io/husky/) to manage Git hooks. For detailed configuration and troubleshooting, see [.husky/README.md](../.husky/README.md).
186178

187179
### Required Visual Studio Code Extensions
188180

0 commit comments

Comments
 (0)