{"action":"opened","issue":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/823","labels_url":"https://api.github.com/repos/ampproject/amphtml/issues/823/labels{/name}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/823/comments","events_url":"https://api.github.com/repos/ampproject/amphtml/issues/823/events","html_url":"https://github.com/ampproject/amphtml/issues/823","id":114478070,"number":823,"title":"Implement gulp test for binary sizes control","user":{"login":"dvoytenko","id":726049,"avatar_url":"https://avatars.githubusercontent.com/u/726049?v=3","gravatar_id":"","url":"https://api.github.com/users/dvoytenko","html_url":"https://github.com/dvoytenko","followers_url":"https://api.github.com/users/dvoytenko/followers","following_url":"https://api.github.com/users/dvoytenko/following{/other_user}","gists_url":"https://api.github.com/users/dvoytenko/gists{/gist_id}","starred_url":"https://api.github.com/users/dvoytenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvoytenko/subscriptions","organizations_url":"https://api.github.com/users/dvoytenko/orgs","repos_url":"https://api.github.com/users/dvoytenko/repos","events_url":"https://api.github.com/users/dvoytenko/events{/privacy}","received_events_url":"https://api.github.com/users/dvoytenko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-01T16:07:39Z","updated_at":"2015-11-01T16:07:39Z","closed_at":null,"body":"A new gulp test will check if any binary has a big change in size. It will work as following:\r\n\r\nFirst: add `sizes.json` file which will list minified (not gzipped) binary sizes. E.g.:\r\n```json\r\n{\r\n  'amp.js': 123456,\r\n  'amp-anim-0.1.js': 9456\r\n}\r\n```\r\n\r\nSecond: add `gulp check-sizes` task that will\r\n\r\n1. Build all binaries\r\n2. Calculate their minified sizes similar to how `gulp size` does it now - these are new sizes\r\n3. Read `sizes.json` - these are old sizes\r\n4. Compare the new size to the old size. If the `abs(%change)` is greater than 5%, report binary, old size, new size and %change to console.\r\n5. If there were any binaries reported, fail the test\r\n\r\nThe %change is calculated as following:\r\n\r\n1. If the old size is undefined (new binary), the `%change = 1000%`\r\n2. Otherwise, `%change = (newSize - oldSize) / oldSize`\r\n\r\nThird: the pull request author who gets the test failure will have to do the following:\r\n\r\n1. If the size change is not expected, find a problem and fix.\r\n2. If the size change is expected, update `sizes.json` with the new sizes reported in the console and include `sizes.json` in the same pull request.\r\n\r\nFourth: the reviewer will have to either agree or challenge the size change. E.g. the reviewer can ask to change the author to switch to lazy loading, different component composition, or use of different 3rd party libraries.\r\n\r\nThat's all.\r\n\r\nNotice that in this system the 5% threshold could be exceeded via a simple incremental change. This is ok since the main goal is to catch big diffs. We can also, later, implement a periodic automatic size recalc/merge to reduce the probability of this happening.\r\n"}}