Sizeguard

This directory contains scripts used to monitor and gate the size of Filament artifacts.

Scripts

dump_artifact_size.py

Computes the sizes of build artifacts (e.g., .aar, .tgz) and their internal contents. It outputs a JSON representation of these sizes.

Usage:

python3 dump_artifact_size.py out/*.aar > current_size.json

check_size.py

Compares a current size JSON (generated by dump_artifact_size.py) against historical data stored in the filament-assets repository. It fails if any artifact's size increase exceeds a specified threshold.

Key Arguments:

  • current_json: Path to the local JSON file.
  • --threshold: Size increase threshold in bytes (default: 20KB).
  • --bypass: If provided, the script will print the comparison but exit successfully even if thresholds are exceeded.

check_bypass.py

A utility script that checks the commit message for a specific tag to determine if the sizeguard check should be bypassed.

Usage:

  • Returns exit code 0 if the tag SIZEGUARD_BYPASS is found in the commit message.
  • Returns exit code 1 otherwise.

Continuous Integration

These scripts are integrated into the GitHub Actions workflows (e.g., .github/workflows/presubmit.yml).

To bypass a failing sizeguard check in a PR, add the following tag on a new line in your commit message:

SIZEGUARD_BYPASS