cr-audit-commits is a GAE go app intended to verify that changes landed in the git repositories monitored, comply with certain policies. E.g. Timely code review approvals, automated rolls only modify allowed files, automated reverts always identify a valid CI failure, release branch merges have correct approvals, etc.
Monitor a ref in a git repo continuously, apply custom rules to relevant commits to decide if they comply with policies, issue notifications (bug filing, email sending) if a violation is detected.
At the moment, in order to decide whether a policy has been broken, the application has access to the commit‘s information as exposed by gitiles, the originating changelist information as exposed by gerrit and information from the continuous integration system, i.e. chromium’s main waterfall.
A Scheduler cron job periodically runs and it iterates over the configured repositories defined in the RuleMap, it resolves any dynamic refs and creates datastore entries for any monitored repos that do not have it yet (i.e. for the first run after a repo has been added to the configuration or when a dynamic ref changes) It then schedules audit tasks for each monitored repository.
The audit task is a TaskQueue task that does the following
Rules are functions (wrapped as a method of an empty struct) that decide whether a given commit complies with a given policy.
Rules receive some information about the repo being audited, and the information about the commit to audit, as well a set of clients initialized and ready to talk to external services (such as monorail) that may be needed to determine if the commit complies with policy.
Rules are expected to return a RuleResult.
For ownership and organization, it is expected that related rules live together in a separate file. E.g. tbr_rules.go
Each RuleSet is responsible for providing a notification function, that will be called with each commit that has failed an audit (or has been determined that needs to issue a notification for some other reason that may not be a policy violation).
Details can be seen at notification.go
This is an example CL that adds support for a repository.
gclient sync
go test
from the app directorygae.py upload
to deploy a new version.gae.py switch
to make the new version default. Or use the web console.See bug queue