Skip to content

feat: add glob list support for file patterns #413

feat: add glob list support for file patterns

feat: add glob list support for file patterns #413

Workflow file for this run

name: Performance
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
bloat-check:
runs-on: ubuntu-latest
name: "cargo | bloat check"
timeout-minutes: 10
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
fetch-depth: 0
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
- uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60
with:
tool: cargo-bloat
- name: Build head branch
id: bloat_head
run: |
# Build head branch
cargo bloat --release | tee bloat_head.txt >&1
- name: Checkout base
run: |
git checkout ${{ github.event.pull_request.base.sha }}
- name: Build base branch
id: bloat_base
run: |
# Build base branch
cargo bloat --release | tee bloat_base.txt >&1
- name: Compare bloat results
shell: python
run: |
import re
from pathlib import Path
def parse_size(text):
match = re.search(r'\.text section size.*?([\d.]+)\s*([KMGT]i?B)', text)
if not match:
raise ValueError("Could not find .text section size")
value, unit = float(match.group(1)), match.group(2)
multipliers = {'B': 1, 'KiB': 1024, 'MiB': 1024**2, 'GiB': 1024**3, 'TiB': 1024**4}
size = value * multipliers.get(unit, 1)
return size, f"{value} {unit}"
head_text = Path('bloat_head.txt').read_text()
base_text = Path('bloat_base.txt').read_text()
head_bytes, head_size = parse_size(head_text)
base_bytes, base_size = parse_size(base_text)
pct_change = ((head_bytes - base_bytes) / base_bytes) * 100
pct_display = f"{pct_change:+.2f}%"
comparison = f"""\
### 📦 Cargo Bloat Comparison
**Binary size change:** {pct_display} ({base_size} → {head_size})
<details>
<summary>Expand for cargo-bloat output</summary>
#### Head Branch Results
```
{head_text}
```
#### Base Branch Results
```
{base_text}
```
</details>
"""
Path("bloat-comparison.txt").write_text(comparison)
- name: Save bloat check results
run: |
mkdir -p /tmp/bloat-check
echo ${{ github.event.pull_request.number }} > /tmp/bloat-check/pr-number.txt
mv bloat-comparison.txt /tmp/bloat-check/bloat-comparison.txt
- name: Upload bloat results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: bloat-check-results
path: /tmp/bloat-check