Skip to content

Commit ddc033a

Browse files
committed
Enhance development setup and documentation
- Updated .gitignore to include coverage-php.txt for test coverage output. - Modified Makefile to log test coverage results to coverage-php.txt and added a script to calculate coverage percentage. - Refined phpunit.xml.dist to separate unit and integration test suites for better organization. - Improved README with clearer instructions on demo usage and added a section on overriding bundle templates. - Updated demo configurations to ensure consistent environment settings across Symfony versions. - Removed obsolete test files to streamline the codebase.
1 parent f098581 commit ddc033a

50 files changed

Lines changed: 759 additions & 136 deletions

Some content is hidden

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

.github/CODEOWNERS

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# CODEOWNERS for PasswordToggleBundle
2+
# Default owner for everything in the repository
3+
* @HecFranco
4+
5+
# GitHub metadata and workflows
6+
/.github/ @HecFranco
7+
8+
# Source code
9+
/src/ @HecFranco
10+
11+
# Tests
12+
/tests/ @HecFranco
13+
14+
# Optional: scripts / tooling
15+
/.scripts/ @HecFranco
16+
/bin/ @HecFranco
17+
# CODEOWNERS for PasswordToggleBundle
18+
# Default owner for everything in the repository
19+
* @HecFranco
20+
21+
# GitHub metadata and workflows
22+
/.github/ @HecFranco
23+
24+
# Source code
25+
/src/ @HecFranco
26+
27+
# Tests
28+
/tests/ @HecFranco
29+
30+
# Optional: scripts / tooling
31+
/.scripts/ @HecFranco
32+
/bin/ @HecFranco
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: "🐞 Bug report"
3+
about: Something is broken?
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
<!--
11+
- Please do not report an issue for a version of `PasswordToggleBundle` that is no longer supported. Currently supported versions are listed here: https://github.com/nowo-tech/PasswordToggleBundle#version-information
12+
- Please fill in this template according to your issue.
13+
- Please keep the table shown below at the top of your issue.
14+
- You can retrieve `PasswordToggleBundle` version by running `composer info | grep "PasswordToggleBundle"`.
15+
- You can retrieve PHP version by running `php -v`.
16+
- Please post code as text (using proper markup). Do not post screenshots of code.
17+
- Please remove this comment before submitting your issue.
18+
-->
19+
20+
| Q | A
21+
| ----------------------------| -----------------------
22+
| `PasswordToggleBundle` version | x.y.z
23+
| PHP version | x.y.z
24+
| Database | MySQL / PostgreSQL / SQLite / Other
25+
26+
#### Summary
27+
28+
<!-- Provide a summary describing the problem you are experiencing. -->
29+
30+
#### Current behavior
31+
32+
<!-- What is the current (buggy) behavior? -->
33+
34+
#### How to reproduce
35+
36+
<!-- Provide steps to reproduce the bug. -->
37+
38+
#### Expected behavior
39+
40+
<!-- What was the expected (correct) behavior? -->
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: "🎉 Feature Request"
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Provide a summary of the feature you would like to see implemented. -->
11+
<!-- Provide a summary of the feature you would like to see implemented. -->
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: "❓ Support Question"
3+
about: You have a question about this bundle or need help?
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Description
2+
3+
Please include a concise summary of the changes and the related issue (if applicable).
4+
5+
Fixes # (issue number)
6+
7+
## Type of Change
8+
9+
- [ ] Bug fix (non-breaking change which fixes an issue)
10+
- [ ] New feature (non-breaking change which adds functionality)
11+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
12+
- [ ] Documentation update
13+
14+
## Checklist
15+
16+
- [ ] My code follows the project's coding standards (PSR-12)
17+
- [ ] I have performed a self-review of my code
18+
- [ ] I have added tests that prove my fix is effective or that my feature works
19+
- [ ] New and existing unit/integration tests pass locally with my changes
20+
- [ ] I have updated the documentation accordingly
21+
- [ ] I have updated `docs/CHANGELOG.md` if applicable
22+
23+
## Testing
24+
25+
Please describe the tests you ran to verify your changes:
26+
27+
```bash
28+
composer test
29+
composer cs-check
30+
```
31+
32+
## Screenshots (if applicable)
33+
34+
Add screenshots to help explain your changes.
35+
36+
## Additional Notes
37+
38+
Add any other notes about the PR here.
39+
## Description
40+
41+
Please include a concise summary of the changes and the related issue (if applicable).
42+
43+
Fixes # (issue number)
44+
45+
## Type of Change
46+
47+
- [ ] Bug fix (non-breaking change which fixes an issue)
48+
- [ ] New feature (non-breaking change which adds functionality)
49+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
50+
- [ ] Documentation update
51+
52+
## Checklist
53+
54+
- [ ] My code follows the project's coding standards (PSR-12)
55+
- [ ] I have performed a self-review of my code
56+
- [ ] I have added tests that prove my fix is effective or that my feature works
57+
- [ ] New and existing unit/integration tests pass locally with my changes
58+
- [ ] I have updated the documentation accordingly
59+
- [ ] I have updated `docs/CHANGELOG.md` if applicable
60+
61+
## Testing
62+
63+
Please describe the tests you ran to verify your changes:
64+
65+
```bash
66+
composer test
67+
composer cs-check
68+
```
69+
70+
## Screenshots (if applicable)
71+
72+
Add screenshots to help explain your changes.
73+
74+
## Additional Notes
75+
76+
Add any other notes about the PR here.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Sync Releases
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 3 * * 1'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
sync-releases:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Sync missing/incomplete releases for v* tags
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
set -euo pipefail
25+
tags="$(git tag -l 'v*')"
26+
if [ -z "${tags}" ]; then
27+
echo "No v* tags found."
28+
exit 0
29+
fi
30+
31+
for tag in ${tags}; do
32+
echo "Processing ${tag}..."
33+
release_json="$(gh release view "${tag}" --json tagName,body 2>/dev/null || true)"
34+
tag_message="$(git tag -l --format='%(contents)' "${tag}" | sed '/^[[:space:]]*$/d' || true)"
35+
[ -z "${tag_message}" ] && tag_message="Release ${tag}"
36+
37+
if [ ! -f docs/CHANGELOG.md ]; then
38+
changelog_block=""
39+
else
40+
version="${tag#v}"
41+
changelog_block="$(awk -v ver="${version}" '
42+
BEGIN {capture=0}
43+
$0 ~ "^## \\[" ver "\\]" {capture=1}
44+
capture {print}
45+
capture && $0 ~ "^## \\[" && $0 !~ "^## \\[" ver "\\]" {exit}
46+
' docs/CHANGELOG.md | sed '$d' || true)"
47+
fi
48+
49+
body="${tag_message}"
50+
if [ -n "${changelog_block}" ]; then
51+
body="${body}\n\n${changelog_block}"
52+
fi
53+
54+
if [ -z "${release_json}" ]; then
55+
gh release create "${tag}" --title "Release ${tag}" --notes "${body}"
56+
continue
57+
fi
58+
59+
current_body="$(printf '%s' "${release_json}" | jq -r '.body // ""')"
60+
if [ -z "${current_body}" ] || [ "${current_body}" = "null" ]; then
61+
gh release edit "${tag}" --title "Release ${tag}" --notes "${body}"
62+
fi
63+
done

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Test coverage
1010
/coverage
1111
/coverage.xml
12+
/coverage-php.txt
1213

1314
# PHP tool caches
1415
/.php-cs-fixer.cache

.scripts/php-coverage-percent.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
# REQ-TEST-008 contract:
5+
# - composer.json must define:
6+
# - "test": "phpunit ..."
7+
# - "test-coverage": "phpunit ... --coverage-text ... --coverage-clover coverage.xml ..."
8+
# - Makefile target `test-coverage` must run:
9+
# composer test-coverage | tee coverage-php.txt
10+
# ./.scripts/php-coverage-percent.sh coverage-php.txt
11+
# - .gitignore must include /coverage-php.txt
12+
13+
RAW_FILE="${1:-coverage-php.txt}"
14+
15+
if [ ! -f "$RAW_FILE" ]; then
16+
echo "ERROR: coverage output file not found: $RAW_FILE" >&2
17+
exit 1
18+
fi
19+
20+
# Strip ANSI color sequences if present before extracting value.
21+
VALUE="$(
22+
sed 's/\x1B\[[0-9;]*[A-Za-z]//g' "$RAW_FILE" \
23+
| awk '/^[[:space:]]*Lines:[[:space:]]+/ { gsub(/%/, "", $2); print $2; exit }'
24+
)"
25+
26+
if [ -z "${VALUE:-}" ]; then
27+
echo "ERROR: Could not extract PHP Lines coverage percentage from ${RAW_FILE}" >&2
28+
exit 1
29+
fi
30+
31+
if [ -t 1 ]; then
32+
RED="$(printf '\033[31m')"
33+
ORANGE="$(printf '\033[38;5;208m')"
34+
GREEN="$(printf '\033[32m')"
35+
RESET="$(printf '\033[0m')"
36+
else
37+
RED=""
38+
ORANGE=""
39+
GREEN=""
40+
RESET=""
41+
fi
42+
43+
COLOR="$GREEN"
44+
if awk "BEGIN { exit !(${VALUE} < 50) }"; then
45+
COLOR="$RED"
46+
elif awk "BEGIN { exit !(${VALUE} <= 85) }"; then
47+
COLOR="$ORANGE"
48+
fi
49+
50+
printf 'Global PHP coverage (Lines): %s%s%%%s\n' "$COLOR" "$VALUE" "$RESET"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bundles": {
3+
"Nowo\\PasswordToggleBundle\\NowoPasswordToggleBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"config/": "%CONFIG_DIR%/"
7+
}
8+
}

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ COMPOSE_FILE := docker-compose.yml
66
COMPOSE := docker-compose -f $(COMPOSE_FILE)
77
SERVICE_PHP := php
88

9-
.PHONY: help up down build shell install test test-coverage cs-check cs-fix rector rector-dry phpstan qa release-check release-check-demos composer-sync clean update validate assets setup-hooks
9+
.PHONY: help up down build shell install test test-coverage coverage-php-percent cs-check cs-fix rector rector-dry phpstan qa release-check release-check-demos composer-sync clean update validate assets setup-hooks
1010

1111
# Default target
1212
help:
@@ -80,7 +80,8 @@ test: ensure-up
8080

8181
# Run tests with coverage (no -T so coverage is shown in console with colors)
8282
test-coverage: ensure-up
83-
$(COMPOSE) exec $(SERVICE_PHP) composer test-coverage
83+
$(COMPOSE) exec $(SERVICE_PHP) composer test-coverage | tee coverage-php.txt
84+
./.scripts/php-coverage-percent.sh coverage-php.txt
8485

8586
# Check code style
8687
cs-check: ensure-up
@@ -107,7 +108,7 @@ qa: ensure-up
107108
$(COMPOSE) exec -T $(SERVICE_PHP) composer qa
108109

109110
# Pre-release checks (no demos healthcheck if demo/Makefile has no release-verify; optional)
110-
release-check: cs-fix cs-check rector-dry phpstan test-coverage release-check-demos
111+
release-check: ensure-up composer-sync cs-fix cs-check rector-dry phpstan test-coverage release-check-demos
111112

112113
release-check-demos:
113114
@if [ -f demo/Makefile ]; then $(MAKE) -C demo release-check 2>/dev/null || true; else true; fi

0 commit comments

Comments
 (0)