{"id":15390372,"url":"https://github.com/danny-andrews/thresh","last_synced_at":"2025-04-15T21:35:12.921Z","repository":{"id":39737602,"uuid":"95926506","full_name":"danny-andrews/thresh","owner":"danny-andrews","description":"A CircleCI Plugin for posting bundle diffs to your GitHub PRs.","archived":false,"fork":false,"pushed_at":"2024-02-14T14:59:05.000Z","size":1217,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T09:18:52.722Z","etag":null,"topics":["bundle","circleci","diff","github","size"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danny-andrews.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-30T21:51:55.000Z","updated_at":"2021-05-08T17:52:31.000Z","dependencies_parsed_at":"2022-09-16T14:51:00.087Z","dependency_job_id":null,"html_url":"https://github.com/danny-andrews/thresh","commit_stats":null,"previous_names":["danny-andrews/circleci-weigh-in"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danny-andrews%2Fthresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danny-andrews%2Fthresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danny-andrews%2Fthresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danny-andrews%2Fthresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danny-andrews","download_url":"https://codeload.github.com/danny-andrews/thresh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219925960,"owners_count":16570090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","circleci","diff","github","size"],"created_at":"2024-10-01T15:05:33.516Z","updated_at":"2024-10-17T00:42:49.399Z","avatar_url":"https://github.com/danny-andrews.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thresh\n\n## Separate the wheat from the chaff in your build files!\n\n![Example PR Status](public/pr-status-example.png)\n\n`thresh` is a CI integration for tracking file size changes across builds. Pluggable for different CI providers. (Currently plugins only exist for CircleCI.)\n\n## What it Does\n\nAt its core, thresh does two things:\n1. Outputs file sizes of files targeted by your thresh config. (Where and how these are output depends on the `artifactStore` plugin you use.)\n1. If the current bulid is associated with an existing PR, it posts a commit status. This status will be `success` if there are no target files which violate size thresholds defined in your thresh config, `failure` if there are target files which violate sizes thresholds, and `error` if any errors were encountered. The contents of this status will contain target diffs if they could be calculated.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample target-sizes.json:\u003c/summary\u003e\n\n```json\n[\n  {\n    \"filepath\": \"example/dist/app1.js\",\n    \"size\": 53\n  },\n  {\n    \"filepath\": \"example/dist/app2.js\",\n    \"size\": 95\n  }\n]\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample target-diffs.json:\u003c/summary\u003e\n\n```json\n{\n  \"diffs\": [\n    {\n      \"targets\": [\n        \"example/dist/*.js\"\n      ],\n      \"previous\": 148,\n      \"current\": 148,\n      \"difference\": 0,\n      \"percentChange\": 0\n    }\n  ],\n  \"failures\": []\n}\n```\n\u003c/details\u003e\n\n## CLI Options\n\n### --config-path\n\n- Description: Filepath to your thresh conifg file.\n- Type: `String`\n- Default: `./.threshrc.toml`\n\n## Setup\n\n### Create threshrc.toml File\n\nA threshrc config file has the following format:\n\n```\ntype Config = {\n  thresholds :: [Threshold],\n  artifactStore :: String,\n  ciAdapter :: String\n}\n```\n\nwhere:\n\n- `thresholds` - A list of configuration objects used to determine the conditions under which the [GitHub status](https://developer.github.com/v3/repos/statuses/#create-a-status) will be posted as \"failed.\"\n- `artifactStore = '@danny-andrews/thresh-artifact-store-circleci'` - The module name of the artifact store plugin you want to use. (Defaults to CircleCI.)\n- `ciAdapter = '@danny-andrews/thresh-ci-adapter-circleci'` - The module name of the CI adapter you want to use. (Defaults to CircleCI.)\n\nWith `Threshold` being:\n\n```\ntype Threshold = {\n  targets: String | [String],\n  maxSize: Number\n}\n```\n\nwhere:\n\n- `targets` - The target(s) of the threshold. Each target can be either a file path or a glob.\n- `maxSize` - The max size of the total of all the files selected by `targets`.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExample config file:\u003c/summary\u003e\n\n```toml\n[[thresholds]]\ntargets = \"dist/*.js\"\nmaxSize = 20000\n```\nThis example would post a failed GitHub status if the total size of all JavaScript files contained in the `dist` directory was larger than 20kB.\n\u003c/details\u003e\n\n### Define Environment Variables\n\n- `GITHUB_API_TOKEN`\n  - Must have read access to repository (`public_repo` scope for public repos, and `repo` scope for private repos)\n  - Must have `repo:status` scope\n\n(Check out the README of the artifact store plugin you are using for any additional environment variable requirements.)\n\n## Comparison with Other Offerings\n\n| | [bundlesize](https://github.com/siddharthkp/bundlesize) | [buildsize](https://buildsize.org/) | [thresh](https://github.com/danny-andrews/thresh) |\n| --- | :---: | :---: | :---: |\n| Handles Fingerprinting? | Y | Y | Y |\n| Posts PR Status Filesize Diffs? | Y | Y | Y |\n| Relies on 3rd-party service? | Y | Y | N |\n| CIs Supported | Travis CI, CircleCI, Wercker, and Drone | Circle CI | Circle CI, easy to add more |\n| Configuration | Expose GitHub access token to environment | None | Expose GitHub/CircleCI access token to environment |\n\n## Writing plugins\n\n### `ciAdapter` Plugins\n\nA valid thresh ci adapter is just a function which returns an object with the following type:\n\n```\ntype CIAdapter = {\n  isRunning :: () -\u003e Boolean\n  getEnvVars :: () -\u003e EnvVars\n}\n\ntype EnvVars = {\n  buildSha :: String,\n  buildUrl :: String,\n  artifactsDirectory :: String,\n  repoOwner :: String,\n  repoName :: String,\n  pullRequestId :: Maybe String\n}\n```\n\n### `artifactStore` Plugins\n\nA valid thresh artifactStore is just a function which returns an object with the following type:\n\n```\ntype ArtifactStore = {\n  getTargetStats :: (baseBranch = String)\n    -\u003e (targetStatsFilepath = String)\n    -\u003e ReaderPromise TargetStat\n}\n\ntype TargetStat = {\n  filepath :: String,\n  size :: Int\n}\n```\n\n## Future Plans\n\nCreate more plugins for different CI environments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanny-andrews%2Fthresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanny-andrews%2Fthresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanny-andrews%2Fthresh/lists"}