Merge "Don't build any changes that touch bionicbb."
This commit is contained in:
		@@ -64,6 +64,11 @@ def contains_cleanspec(change_id, patch_set):
 | 
				
			|||||||
    return 'CleanSpec.mk' in [os.path.basename(f) for f in files]
 | 
					    return 'CleanSpec.mk' in [os.path.basename(f) for f in files]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def contains_bionicbb(change_id, patch_set):
 | 
				
			||||||
 | 
					    files = gerrit.get_files_for_revision(change_id, patch_set)
 | 
				
			||||||
 | 
					    return any('tools/bionicbb' in f for f in files)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def should_skip_build(info):
 | 
					def should_skip_build(info):
 | 
				
			||||||
    if info['MessageType'] not in ('newchange', 'newpatchset', 'comment'):
 | 
					    if info['MessageType'] not in ('newchange', 'newpatchset', 'comment'):
 | 
				
			||||||
        raise ValueError('should_skip_build() is only valid for new '
 | 
					        raise ValueError('should_skip_build() is only valid for new '
 | 
				
			||||||
@@ -75,6 +80,7 @@ def should_skip_build(info):
 | 
				
			|||||||
    checks = [
 | 
					    checks = [
 | 
				
			||||||
        is_untrusted_committer,
 | 
					        is_untrusted_committer,
 | 
				
			||||||
        contains_cleanspec,
 | 
					        contains_cleanspec,
 | 
				
			||||||
 | 
					        contains_bionicbb,
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
    for check in checks:
 | 
					    for check in checks:
 | 
				
			||||||
        if check(change_id, patch_set):
 | 
					        if check(change_id, patch_set):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ import unittest
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestShouldSkipBuild(unittest.TestCase):
 | 
					class TestShouldSkipBuild(unittest.TestCase):
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.contains_bionicbb')
 | 
				
			||||||
    @mock.patch('gmail_listener.contains_cleanspec')
 | 
					    @mock.patch('gmail_listener.contains_cleanspec')
 | 
				
			||||||
    @mock.patch('gerrit.get_commit')
 | 
					    @mock.patch('gerrit.get_commit')
 | 
				
			||||||
    def test_accepts_googlers(self, mock_commit, *other_checks):
 | 
					    def test_accepts_googlers(self, mock_commit, *other_checks):
 | 
				
			||||||
@@ -21,6 +22,7 @@ class TestShouldSkipBuild(unittest.TestCase):
 | 
				
			|||||||
                'PatchSet': '',
 | 
					                'PatchSet': '',
 | 
				
			||||||
            }))
 | 
					            }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.contains_bionicbb')
 | 
				
			||||||
    @mock.patch('gmail_listener.contains_cleanspec')
 | 
					    @mock.patch('gmail_listener.contains_cleanspec')
 | 
				
			||||||
    @mock.patch('gerrit.get_commit')
 | 
					    @mock.patch('gerrit.get_commit')
 | 
				
			||||||
    def test_rejects_googlish_domains(self, mock_commit, *other_checks):
 | 
					    def test_rejects_googlish_domains(self, mock_commit, *other_checks):
 | 
				
			||||||
@@ -38,6 +40,7 @@ class TestShouldSkipBuild(unittest.TestCase):
 | 
				
			|||||||
                'PatchSet': '',
 | 
					                'PatchSet': '',
 | 
				
			||||||
            }))
 | 
					            }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.contains_bionicbb')
 | 
				
			||||||
    @mock.patch('gmail_listener.contains_cleanspec')
 | 
					    @mock.patch('gmail_listener.contains_cleanspec')
 | 
				
			||||||
    @mock.patch('gerrit.get_commit')
 | 
					    @mock.patch('gerrit.get_commit')
 | 
				
			||||||
    def test_rejects_non_googlers(self, mock_commit, *other_checks):
 | 
					    def test_rejects_non_googlers(self, mock_commit, *other_checks):
 | 
				
			||||||
@@ -55,6 +58,7 @@ class TestShouldSkipBuild(unittest.TestCase):
 | 
				
			|||||||
                'PatchSet': '',
 | 
					                'PatchSet': '',
 | 
				
			||||||
            }))
 | 
					            }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.contains_bionicbb')
 | 
				
			||||||
    @mock.patch('gmail_listener.is_untrusted_committer')
 | 
					    @mock.patch('gmail_listener.is_untrusted_committer')
 | 
				
			||||||
    @mock.patch('gerrit.get_files_for_revision')
 | 
					    @mock.patch('gerrit.get_files_for_revision')
 | 
				
			||||||
    def test_skips_cleanspecs(self, mock_files, *other_checks):
 | 
					    def test_skips_cleanspecs(self, mock_files, *other_checks):
 | 
				
			||||||
@@ -69,6 +73,21 @@ class TestShouldSkipBuild(unittest.TestCase):
 | 
				
			|||||||
                'PatchSet': '',
 | 
					                'PatchSet': '',
 | 
				
			||||||
            }))
 | 
					            }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.contains_cleanspec')
 | 
				
			||||||
 | 
					    @mock.patch('gmail_listener.is_untrusted_committer')
 | 
				
			||||||
 | 
					    @mock.patch('gerrit.get_files_for_revision')
 | 
				
			||||||
 | 
					    def test_skips_bionicbb(self, mock_files, *other_checks):
 | 
				
			||||||
 | 
					        mock_files.return_value = ['tools/bionicbb/common.sh']
 | 
				
			||||||
 | 
					        for other_check in other_checks:
 | 
				
			||||||
 | 
					            other_check.return_value = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for message_type in ('newchange', 'newpatchset', 'comment'):
 | 
				
			||||||
 | 
					            self.assertTrue(gmail_listener.should_skip_build({
 | 
				
			||||||
 | 
					                'MessageType': message_type,
 | 
				
			||||||
 | 
					                'Change-Id': '',
 | 
				
			||||||
 | 
					                'PatchSet': '',
 | 
				
			||||||
 | 
					            }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    unittest.main()
 | 
					    unittest.main()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user