Skip to content

Commit 827eb8a

Browse files
authored
Merge branch 'symfony:2.x' into svelte-5-support
2 parents 00a8db4 + b536b09 commit 827eb8a

File tree

567 files changed

+12210
-5740
lines changed

Some content is hidden

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

567 files changed

+12210
-5740
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/LazyImage @Kocal
2+
src/Map @Kocal
3+
src/Translator @Kocal

.github/ISSUE_TEMPLATE/1-bug_report.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,31 @@
22
name: '🐞 Bug Report'
33
about: Report a bug in existing features
44
title: ''
5-
labels: 'bug'
5+
labels: ['Bug']
66
assignees: ''
77

88
---
9+
10+
<!-- ======================== Guidelines ============================
11+
12+
Thank you for taking the time to report a bug! 🙏
13+
14+
Please follow these guidelines to help us understand & fix the issue:
15+
16+
Describe Your Problem 🎯
17+
- Clearly explain the problem you're facing;
18+
- Describe what you expected to happen versus what actually occurred;
19+
- List the steps to reproduce the bug.
20+
21+
Provide Detailed Information 📋
22+
- Share relevant details: Component version, errors, screenshots;
23+
- If possible, provide a minimal reproducer in a GitHub repository.
24+
25+
Be Kind and Respectful 🙂
26+
- Stay patient & open to feedback, and act with kindness and respect;
27+
- Remember that this is a volunteer-driven project.
28+
29+
============================= Guidelines ======================== -->
30+
31+
32+

.github/ISSUE_TEMPLATE/2-feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: '🚀 Feature Request'
33
about: Suggest ideas for new features or enhancements
44
title: ''
5-
labels: 'RFC'
5+
labels: ['RFC']
66
assignees: ''
77

88
---
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/**
2+
* Generate a markdown table with the difference in size of the dist files between the base and the PR.
3+
*/
4+
5+
/*
6+
Usage:
7+
```shell
8+
BASE_DIST_FILES='{"src/Autocomplete/assets/dist/controller.js":{"size":15382,"size_gz":3716},"src/Chartjs/assets/dist/controller.js":{"size":2281,"size_gz":771},"src/Cropperjs/assets/dist/controller.js":{"size":1044,"size_gz":475}}' \
9+
HEAD_DIST_FILES='{"src/Chartjs/assets/dist/controller.js":{"size":1281,"size_gz":171},"src/Cropperjs/assets/dist/controller.js":{"size":1044,"size_gz":475},"src/Cropperjs/assets/dist/style.min.css":{"size":32,"size_gz":66},"src/Dropzone/assets/dist/controller.js":{"size":3199,"size_gz":816},"src/Map/src/Bridge/Google/assets/dist/foo.js":{"size":3199,"size_gz":816}}' \
10+
HEAD_REPO_NAME='kocal/symfony-ux' \
11+
HEAD_REF='my-branch-name' \
12+
node .github/generate-dist-files-size-diff.mjs
13+
```
14+
*/
15+
16+
if (!process.env.BASE_DIST_FILES) {
17+
throw new Error('Missing or invalid "BASE_DIST_FILES" env variable.');
18+
}
19+
20+
if (!process.env.HEAD_DIST_FILES) {
21+
throw new Error('Missing or invalid "HEAD_DIST_FILES" env variable.');
22+
}
23+
24+
if (!process.env.HEAD_REPO_NAME) {
25+
throw new Error('Missing or invalid "HEAD_REPO_NAME" env variable.');
26+
}
27+
28+
if (!process.env.HEAD_REF) {
29+
throw new Error('Missing or invalid "HEAD_REF" env variable.');
30+
}
31+
32+
/**
33+
* Adapted from https://gist.github.com/zentala/1e6f72438796d74531803cc3833c039c?permalink_comment_id=4455218#gistcomment-4455218
34+
* @param {number} bytes
35+
* @param {number} digits
36+
* @returns {string}
37+
*/
38+
function formatBytes(bytes, digits = 2) {
39+
if (bytes === 0) {
40+
return '0 B';
41+
}
42+
const sizes = [`B`, 'kB', 'MB'];
43+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
44+
45+
return parseFloat((bytes / Math.pow(1024, i)).toFixed(digits)) + ' ' + sizes[i];
46+
}
47+
48+
/**
49+
* @param {number} from
50+
* @param {number} to
51+
* @returns {number}
52+
*/
53+
function computeDiffPercent(from, to) {
54+
if (from === to) {
55+
return 0;
56+
}
57+
58+
return Math.round((from - to) / from * -100);
59+
}
60+
61+
/**
62+
* @param {number} percent
63+
* @returns {string}
64+
*/
65+
function formatDiffPercent(percent) {
66+
return percent > 0 ? `+${percent}% 📈` : percent < 0 ? `${percent}% 📉` : `${percent}%`;
67+
}
68+
69+
export function main() {
70+
const repoUrl = `https://github.com/${process.env.HEAD_REPO_NAME}`;
71+
/** @type {Record<string, {size: number, size_gz: number}>} */
72+
const base = JSON.parse(process.env.BASE_DIST_FILES);
73+
/** @type {Record<string, {size: number, size_gz: number}>} */
74+
const pr = JSON.parse(process.env.HEAD_DIST_FILES);
75+
let output = '<h1>📊 Packages dist files size difference</h1>\n\n';
76+
77+
/**
78+
* @type {Map<string, {
79+
* meta: {
80+
* packageName: string,
81+
* bridgeName: string,
82+
* url: string,
83+
* },
84+
* files: Set<{
85+
* state: 'added' | 'removed' | 'changed',
86+
* before: {size: number, sizeGz: number},
87+
* after: {size: number, sizeGz: number},
88+
* diffPercent: {size: number, sizeGz: number},
89+
* meta: {fileNameShort: string, fileNameUrl: string}
90+
* }>
91+
* }>}
92+
*/
93+
const packagesFiles = [...new Set([...Object.keys(pr), ...Object.keys(base)])]
94+
.sort()
95+
.reduce((acc, file) => {
96+
const beforeSize = base[file]?.size || 0;
97+
const afterSize = pr[file]?.size || 0;
98+
const beforeSizeGz = base[file]?.size_gz || 0;
99+
const afterSizeGz = pr[file]?.size_gz || 0;
100+
101+
if (beforeSize !== afterSize) {
102+
const isBridge = file.includes('src/Bridge'); // we assume that's enough for now
103+
const packageName = file.split('/')[1];
104+
const bridgeName = isBridge ? file.split('/')[4] : '';
105+
const key = isBridge ? `${packageName} (Bridge ${bridgeName})` : packageName;
106+
if (!acc.has(key)) {
107+
acc.set(key, {
108+
meta: {
109+
packageName,
110+
bridgeName,
111+
url: isBridge ? `${repoUrl}/tree/${process.env.HEAD_REF}/src/${packageName}/src/Bridge/${bridgeName}/assets/dist` : `${repoUrl}/tree/${process.env.HEAD_REF}/src/${packageName}/assets/dist`,
112+
}, files: new Set(),
113+
});
114+
}
115+
116+
const added = !base[file] && pr[file];
117+
const removed = base[file] && !pr[file];
118+
119+
acc.get(key).files.add({
120+
state: added ? 'added' : (removed ? 'removed' : 'changed'),
121+
before: { size: beforeSize, sizeGz: beforeSizeGz },
122+
after: { size: afterSize, sizeGz: afterSizeGz },
123+
diffPercent: {
124+
size: removed ? -100 : (added ? 100 : computeDiffPercent(beforeSize, afterSize)),
125+
sizeGz: removed ? -100 : (added ? 100 : computeDiffPercent(beforeSizeGz, afterSizeGz)),
126+
},
127+
meta: {
128+
fileNameShort: file.replace(isBridge ? `src/${file.split('/')[1]}/src/Bridge/${file.split('/')[4]}/assets/dist/` : `src/${file.split('/')[1]}/assets/dist/`, ''),
129+
fileNameUrl: `${repoUrl}/blob/${process.env.HEAD_REF}/${file}`,
130+
},
131+
});
132+
}
133+
134+
return acc;
135+
}, new Map);
136+
137+
if (packagesFiles.size === 0) {
138+
output += 'ℹ️ No difference in dist packagesFiles.\n';
139+
return output;
140+
}
141+
142+
output += 'Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.\n';
143+
output += 'Please review the changes and make sure they are expected.\n\n';
144+
output += `<table>
145+
<thead><tr><th>File</th><th>Before (Size / Gzip)</th><th>After (Size / Gzip)</th></tr></thead>
146+
<tbody>`;
147+
for (const [pkgKey, pkg] of packagesFiles.entries()) {
148+
output += `<tr><td colspan="3"><a href="${pkg.meta.url}"><b>${pkgKey}</b></a></td></tr>`;
149+
for (const file of pkg.files) {
150+
output += `<tr>
151+
<td><a href="${file.meta.fileNameUrl}"><code>${file.meta.fileNameShort}</code></a></td>
152+
`;
153+
output += file.state === 'added'
154+
? `<td><em>Added</em></td>`
155+
: `<td>
156+
<code>${formatBytes(file.before.size)}</code>
157+
/ <code>${formatBytes(file.before.sizeGz)}</code>
158+
</td>`;
159+
output += file.state === 'removed'
160+
? `<td><em>Removed</em></td>`
161+
: `<td>
162+
<code>${formatBytes(file.after.size)}</code>${file.state === 'changed' ? `<sup>${formatDiffPercent(file.diffPercent.size)}</sup>` : ''}
163+
/ <code>${formatBytes(file.after.sizeGz)}</code>${file.state === 'changed' ? `<sup>${formatDiffPercent(file.diffPercent.sizeGz)}</sup>` : ''}
164+
</td>`;
165+
output += `</tr>`;
166+
}
167+
}
168+
output += `</tbody>
169+
</table>
170+
`;
171+
172+
return output;
173+
}
174+
175+
if (!process.env.CI) {
176+
console.log(main());
177+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Dist Files Size Diff (Comment)
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Dist Files Size Diff"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
dist-files-size-diff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Download artifacts
14+
uses: actions/download-artifact@v4
15+
with:
16+
name: dist-size-diff
17+
run-id: ${{ github.event.workflow_run.id }}
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Read pr-number artifact to env var
21+
id: read-pr-number
22+
run: |
23+
echo "pr-number=$(cat ./pr-number)" >> $GITHUB_OUTPUT
24+
25+
- name: Comment on the pull request (if success)
26+
uses: marocchino/sticky-pull-request-comment@v2
27+
with:
28+
number: ${{ steps.read-pr-number.outputs.pr-number }}
29+
path: ./diff.md
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Dist Files Size Diff
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'src/*/assets/dist/**'
8+
- 'src/*/src/Bridge/*/assets/dist/**'
9+
10+
jobs:
11+
dist-files-size-diff:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Configure git
15+
run: |
16+
git config --global user.email ""
17+
git config --global user.name "github-action[bot]"
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.base_ref }}
22+
23+
- name: Get dist files size (from base branch)
24+
id: base-dist-files
25+
run: |
26+
set -e
27+
28+
FILES=$(find src -mindepth 2 -type f -path '*/assets/dist/*' -not \( -path '*/tests/*' -o -path '*/public/*' -o -path '*/vendor/*' \) | sort | while read -r file; do
29+
echo "{\"$file\": {\"size\": $(wc -c < "$file"), \"size_gz\": $(gzip -c "$file" | wc -c)}}"
30+
done | jq -s 'add' -c)
31+
32+
echo "files=$FILES" >> $GITHUB_OUTPUT
33+
34+
- uses: actions/checkout@v4
35+
36+
- name: Get dist files size (from pull request)
37+
id: pr-dist-files
38+
run: |
39+
set -e
40+
41+
FILES=$(find src -mindepth 2 -type f -path '*/assets/dist/*' -not \( -path '*/tests/*' -o -path '*/public/*' -o -path '*/vendor/*' \) | sort | while read -r file; do
42+
echo "{\"$file\": {\"size\": $(wc -c < "$file"), \"size_gz\": $(gzip -c "$file" | wc -c)}}"
43+
done | jq -s 'add' -c)
44+
45+
echo "files=$FILES" >> $GITHUB_OUTPUT
46+
47+
- name: Generate the diff
48+
id: diff
49+
uses: actions/github-script@v7
50+
env:
51+
BASE_DIST_FILES: ${{ steps.base-dist-files.outputs.files }}
52+
HEAD_DIST_FILES: ${{ steps.pr-dist-files.outputs.files }}
53+
HEAD_REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
54+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
55+
with:
56+
result-encoding: string
57+
script: |
58+
const fs = require('fs')
59+
const { main } = await import('${{ github.workspace }}/.github/generate-dist-files-size-diff.mjs')
60+
61+
const diff = await main()
62+
console.log(diff);
63+
64+
fs.writeFileSync(process.env.GITHUB_WORKSPACE + '/diff.md', diff)
65+
66+
- name: Save PR number
67+
run: |
68+
echo "${{ github.event.number }}" > pr-number
69+
70+
- name: Upload artifacts
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: dist-size-diff
74+
path: |
75+
./diff.md
76+
./pr-number

0 commit comments

Comments
 (0)