Page MenuHomePhabricator

Tooling: MobileFrontend should check SVGS committed have been optimised.
Closed, ResolvedPublic2 Estimated Story Points

Description

See Page Previews codebase for guidance (how it checks JS assets have been compiled)
Run svgo on all checked in commits and complain if the committer didn't optimise them.

Acceptance criteria

  • If running the following script on any checked in files results in any filesize changes Jenkins should vote -1
git-staged-files() {
	git diff --cached -C -C -z --name-only --diff-filter=ACMRTUXB "$@"
}
compress-svg() {
	git-staged-files \*.svg|while map file; do
		make nodecheck
		echo "Compressing $file"
		# If anyone can figure out how to get the pretty option to work from the config
		# file, feel free to remove it here.
		node_modules/.bin/svgo --config=.svgo.yml "$file" --pretty
		git add "$file"
	done
}
  • Bear in mind that your solution will likely be adopted for all projects that are maintained by Reading Web

Event Timeline

Jdlrobson updated the task description. (Show Details)
Jdlrobson set the point value for this task to 2.May 3 2017, 5:17 PM

Change 353885 had a related patch set uploaded (by Pmiazga; owner: Pmiazga):
[mediawiki/extensions/MobileFrontend@master] Execute SVG check in CI

https://gerrit.wikimedia.org/r/353885

raynor: i checked all th compressed svgs and they are good
6:50 PM but i get a lot of errors when i run the script
New messages
6:50 PM https://www.irccloud.com/pastebin/Xn2VIYP4/

The new SVGS are fine. refresh I checked workflows for
edit
issues
references
overlay close
notifications
user page
watch
and found no UI regressions.

Jdlrobson added a subscriber: pmiazga.

Can you do a general test run on the beta cluster (en.m.wikipedia.beta.wmflabs.org) and check that no icons seem out of place - in particular the editor, the user page and the image overlay. Should be fine but better to be safe then sorry!

Change 353885 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Execute SVG check in CI

https://gerrit.wikimedia.org/r/353885

Proposed solution is a single bash script that loops through all SVG files inside resources folder that can be moved to different repositories.
When dev-scripts/svg_check.sh script finds an uncompressed file it will:

  • print the file name for developer convenience
  • end if non-zero exit code (after checking all SVG files) which will result in -1 vote from jenkins

Tested on Beta cluster and it looks pretty good. I tried a number of mobile devices and browsers, performed edits logged in and logged out, and used both source and visual editing. It appears that the icons are present and complete.

PASSED - Tried committing an uncompressed SVG file and Jenkins complained. https://gerrit.wikimedia.org/r/#/c/353959/
PASSED - Jenkins job takes around 15s so runs in suitable time
No changes in https://grafana.wikimedia.org/dashboard/db/mobile-2g?orgId=1 on account of the newly compressed SVGS - but I suspect that's because none of them were in the critical path. Less bytes = good though :)