Skip to content

[Inspector] Add a browser inspector for Symfony UX #632

[Inspector] Add a browser inspector for Symfony UX

[Inspector] Add a browser inspector for Symfony UX #632

name: Dist Files Size Diff
on:
pull_request:
types: [opened, synchronize]
paths:
- 'src/*/assets/dist/**'
- 'src/*/src/Bridge/*/assets/dist/**'
permissions: {}
jobs:
dist-files-size-diff:
runs-on: ubuntu-latest
steps:
- name: Configure git
run: |
git config --global user.email ""
git config --global user.name "github-action[bot]"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.base_ref }}
persist-credentials: false
- name: Get dist files size (from base branch)
id: base-dist-files
run: |
set -e
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
echo "{\"$file\": {\"size\": $(wc -c < "$file"), \"size_gz\": $(gzip -c "$file" | wc -c)}}"
done | jq -s 'add' -c)
echo "files=$FILES" >> $GITHUB_OUTPUT
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Get dist files size (from pull request)
id: pr-dist-files
run: |
set -e
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
echo "{\"$file\": {\"size\": $(wc -c < "$file"), \"size_gz\": $(gzip -c "$file" | wc -c)}}"
done | jq -s 'add' -c)
echo "files=$FILES" >> $GITHUB_OUTPUT
- name: Generate the diff
id: diff
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
BASE_DIST_FILES: ${{ steps.base-dist-files.outputs.files }}
HEAD_DIST_FILES: ${{ steps.pr-dist-files.outputs.files }}
HEAD_REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
with:
result-encoding: string
script: |
const fs = require('fs')
const { main } = await import('${{ github.workspace }}/.github/generate-dist-files-size-diff.mjs')
const diff = await main()
console.log(diff);
fs.writeFileSync(process.env.GITHUB_WORKSPACE + '/diff.md', diff)
- name: Save PR number
run: |
echo "${{ github.event.number }}" > pr-number
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-size-diff
path: |
./diff.md
./pr-number