Skip to content

Commit 15e7168

Browse files
committed
Update composer.json for Symfony compatibility and enhance testing scripts
- Adjusted Symfony package version constraints in composer.json to support versions 6.0 and above. - Updated test command in Makefile to include color output for better readability. - Added new scripts for coverage validation and translation YAML validation. - Introduced coverage report generation in the test process and improved handling of coverage output. - Added environment configuration files for Symfony 7 and 8 demos, ensuring proper setup for local development.
1 parent b3ed3d6 commit 15e7168

29 files changed

Lines changed: 943 additions & 215 deletions

.github/CODEOWNERS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CODEOWNERS for PerformanceBundle
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

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Funding platforms for nowo-tech/twig-inspector-bundle
2+
# These are supported funding model platforms
3+
4+
github: [HecFranco]
5+
# patreon:
6+
# open_collective:
7+
# ko_fi:
8+
# tidelift:
9+
# community_bridge:
10+
# liberapay:
11+
# issuehunt:
12+
# otechie:
13+
# lfx_crowdfunding:
14+
# custom:
15+
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 `PerformanceBundle` that is no longer supported. Currently supported versions are listed here: https://github.com/nowo-tech/PerformanceBundle#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 `PerformanceBundle` version by running `composer info | grep "PerformanceBundle"`.
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+
| `PerformanceBundle` 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
12+
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.

.github/SECURITY.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 2.x | :white_check_mark: |
8+
| 1.x | :x: |
9+
10+
## Reporting a Vulnerability
11+
12+
We take the security of PerformanceBundle seriously. If you believe you have found a security vulnerability, please report it privately:
13+
14+
- **Email**: security@nowo.tech
15+
- **Do not** open a public GitHub issue for security-sensitive bugs.
16+
17+
Please include:
18+
19+
- Type of issue (e.g., injection, XSS, auth bypass, deserialization risk, etc.)
20+
- Affected file(s) and version/tag/commit
21+
- Steps to reproduce
22+
- Impact assessment
23+
- PoC (if available)
24+
25+
## Response Timeline
26+
27+
- Initial acknowledgment: within 48 hours
28+
- Follow-up status: within 7 days
29+
- Resolution: depends on complexity and impact
30+
31+
## Disclosure Policy
32+
33+
- We confirm receipt and validate the report.
34+
- We prepare and publish a fix as soon as possible.
35+
- We coordinate disclosure with the reporter.
36+
- We credit responsible disclosure (unless anonymity is requested).

.github/dependabot.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Dependabot configuration for automated dependency updates
2+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
3+
4+
version: 2
5+
updates:
6+
# Maintain dependencies for Composer
7+
- package-ecosystem: "composer"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
day: "monday"
12+
time: "09:00"
13+
timezone: "Europe/Madrid"
14+
open-pull-requests-limit: 5
15+
reviewers:
16+
- "HecFranco"
17+
labels:
18+
- "dependencies"
19+
- "php"
20+
commit-message:
21+
prefix: "chore(deps):"
22+
23+
# Maintain dependencies for GitHub Actions
24+
- package-ecosystem: "github-actions"
25+
directory: "/"
26+
schedule:
27+
interval: "weekly"
28+
day: "monday"
29+
time: "09:00"
30+
timezone: "Europe/Madrid"
31+
open-pull-requests-limit: 3
32+
reviewers:
33+
- "HecFranco"
34+
labels:
35+
- "dependencies"
36+
- "github-actions"
37+
commit-message:
38+
prefix: "chore(ci):"
39+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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@v6
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Sync missing and incomplete releases
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
set -eu
25+
26+
for tag in $(git tag -l 'v*' --sort=-v:refname); do
27+
echo "Processing ${tag}..."
28+
29+
notes=""
30+
if [ -f docs/CHANGELOG.md ]; then
31+
notes=$(awk -v tag="$tag" '
32+
BEGIN {capture=0}
33+
/^## \[/ {
34+
if (capture==1) exit
35+
if ($0 ~ "^## \\\\[" tag "\\\\]") capture=1
36+
}
37+
capture==1 {print}
38+
' docs/CHANGELOG.md || true)
39+
fi
40+
41+
if [ -z "${notes}" ]; then
42+
notes="Release ${tag}"
43+
fi
44+
45+
if gh release view "$tag" >/dev/null 2>&1; then
46+
current_body="$(gh release view "$tag" --json body -q .body || true)"
47+
if [ -z "${current_body}" ] || [ "${current_body}" = "Release ${tag}" ]; then
48+
gh release edit "$tag" --notes "$notes"
49+
echo "Updated release ${tag}"
50+
else
51+
echo "Release ${tag} already has notes"
52+
fi
53+
else
54+
gh release create "$tag" --title "Release ${tag}" --notes "$notes"
55+
echo "Created release ${tag}"
56+
fi
57+
done

.scripts/check-coverage.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Checks that coverage.xml meets the minimum coverage threshold (default 100%).
7+
* Exit code 0 if coverage >= threshold, 1 otherwise.
8+
*
9+
* Usage: php scripts/check-coverage.php [coverage.xml] [--min-percent=N]
10+
*/
11+
$coverageFile = $argv[1] ?? 'coverage.xml';
12+
$minPercent = 100;
13+
foreach (array_slice($argv, 2) as $arg) {
14+
if (str_starts_with($arg, '--min-percent=')) {
15+
$minPercent = (int) substr($arg, strlen('--min-percent='));
16+
break;
17+
}
18+
}
19+
20+
if (!is_file($coverageFile)) {
21+
fwrite(\STDERR, "Coverage file not found: {$coverageFile}\n");
22+
exit(2);
23+
}
24+
25+
$xml = @simplexml_load_file($coverageFile);
26+
if ($xml === false) {
27+
fwrite(\STDERR, "Invalid XML in {$coverageFile}\n");
28+
exit(2);
29+
}
30+
31+
$projectMetrics = $xml->project->metrics;
32+
if (!$projectMetrics) {
33+
fwrite(\STDERR, "No project metrics in {$coverageFile}\n");
34+
exit(2);
35+
}
36+
37+
$statements = (int) (string) $projectMetrics['statements'];
38+
$coveredStatements = (int) (string) $projectMetrics['coveredstatements'];
39+
$elements = (int) (string) $projectMetrics['elements'];
40+
$coveredElements = (int) (string) $projectMetrics['coveredelements'];
41+
42+
$stmtPercent = $statements > 0 ? round($coveredStatements / $statements * 100, 2) : 100.0;
43+
$elemPercent = $elements > 0 ? round($coveredElements / $elements * 100, 2) : 100.0;
44+
45+
echo sprintf(
46+
'Coverage: statements %d/%d (%.2f%%), elements %d/%d (%.2f%%)' . \PHP_EOL,
47+
$coveredStatements,
48+
$statements,
49+
$stmtPercent,
50+
$coveredElements,
51+
$elements,
52+
$elemPercent,
53+
);
54+
55+
if ($stmtPercent < $minPercent || $elemPercent < $minPercent) {
56+
fwrite(\STDERR, sprintf("Coverage below %d%% threshold.\n", $minPercent));
57+
exit(1);
58+
}
59+
60+
echo "Coverage threshold {$minPercent}% met.\n";
61+
exit(0);

0 commit comments

Comments
 (0)