circleci-weigh-in
v0.2.5
Published
A CircleCI integration script for tracking file size changes across deploys.
Downloads
19
Maintainers
Readme
circleci-weigh-in
NOTE: Only works with GitHub repositories.
A CircleCI integration for tracking file size changes across deploys.
What it Does
Saves file containing file sizes of assets (by reading from webpack stats output) to the
$CIRCLE_ARTIFACTS/circleci-weigh-in/bundle-sizes.jsondirectory in order to save it as an artifact for later reference.Example output:
{
"app.css": {
"size": 52336,
"path": "webcreator_public/css/app.54bbcf6f50ed582c98f5cf3841d5c837.css"
},
"app.js": {
"size": 408489,
"path": "webcreator_public/js/app.18db3f4eb6b95f3ac8ea.js"
},
"manifest.js": {
"size": 1463,
"path": "webcreator_public/js/manifest.5cb70be29d3945c8ee59.js"
},
"vendor.js": {
"size": 2284786,
"path": "webcreator_public/js/vendor.af1abaa45f10408b578e.js"
}
}Generates diff of base branch file sizes with current branch.
Saves file containing that diff information to
$CIRCLE_ARTIFACTS/circleci-weigh-in/bundle-sizes-diff.json.Example output
{
"app.css": {
"current": 52336,
"original": 52336,
"difference": 0,
"percentChange": 0
},
"app.js": {
"current": 408489,
"original": 408489,
"difference": 0,
"percentChange": 0
},
"manifest.js": {
"current": 1463,
"original": 1463,
"difference": 0,
"percentChange": 0
},
"vendor.js": {
"current": 2284786,
"original": 2284786,
"difference": 0,
"percentChange": 0
}
}- Posts that diff as a status to PR associated with the build.
CLI Options
Required Environment Variables
CircleCI Built-ins
CIRCLE_ARTIFACTS2.0CIRCLE_PROJECT_USERNAMECIRCLE_PROJECT_REPONAMECIRCLE_SHA1CI_PULL_REQUESTCIRCLE_BUILD_URL
Manual
GITHUB_API_TOKEN- Must have read access to repository (
public_reposcope for public repos, andreposcope for private repos) - Must have
repo:statusscope
- Must have read access to repository (
CIRCLE_API_TOKEN- Must have
view-buildsscope
- Must have
CircleCI 2.0 Notes
The CIRCLE_ARTIFACTS environment variable was removed in CircleCI 2.0. To workaround this, you need to define it yourself and then move the files stored there in a store_artifacts step. Example config file:
version: 2
jobs:
build:
# ...
environment:
- CIRCLE_ARTIFACTS: ./example/dist/artifacts
steps:
# ...
- store_artifacts:
# Wish I could use $CIRCLE_ARTIFACTS here :( (http://bit.ly/2vlqGiR)
path: ./example/dist/artifacts
destination: ./