Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 795776: Add purge support to b2g builds. r=aki

  • Loading branch information...
commit 49682dfc301e1e6dbcc8fc022f0310bd58841ba7 1 parent be037d2
@catlee catlee authored
View
2  configs/b2g/releng-try.py
@@ -2,6 +2,7 @@
import os
config = {
"default_actions": [
+ 'purge-builds',
'checkout-gecko',
'download-gonk',
'unpack-gonk',
@@ -28,4 +29,5 @@
"CCACHE_COMPRESS": "1",
"CCACHE_UMASK": "002",
},
+ "purge_minsize": 10,
}
View
2  configs/b2g/releng.py
@@ -2,6 +2,7 @@
import os
config = {
"default_actions": [
+ 'purge-builds',
'checkout-gecko',
'download-gonk',
'unpack-gonk',
@@ -27,4 +28,5 @@
"CCACHE_COMPRESS": "1",
"CCACHE_UMASK": "002",
},
+ "purge_minsize": 10,
}
View
60 mozharness/mozilla/purge.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# ***** BEGIN LICENSE BLOCK *****
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+# ***** END LICENSE BLOCK *****
+"""Purge/clobber support
+"""
+
+# Figure out where our external_tools are
+# These are in a sibling directory to the 'mozharness' module
+import os
+import mozharness
+external_tools_path = os.path.join(
+ os.path.abspath(os.path.dirname(os.path.dirname(mozharness.__file__))),
+ 'external_tools',
+)
+
+
+# PurgeMixin {{{1
+# Depends on ShellMixin for self.run_command,
+# and BuildbotMixin for self.buildbot_config
+class PurgeMixin(object):
+ purge_tool = os.path.join(external_tools_path, 'purge_builds.py')
+
+ default_skips = ['info', 'rel-*']
+ default_maxage = 14
+
+ def purge_builds(self, basedir=None, min_size=None, skip=None, max_age=None):
+ c = self.config
+ min_size = min_size or c['purge_minsize']
+ max_age = max_age or c.get('purge_maxage') or self.default_maxage
+ skip = skip or c.get('purge_skip') or self.default_skips
+
+ if not basedir:
+ assert self.buildbot_config
+ basedir = os.path.dirname(self.buildbot_config['properties']['basedir'])
+
+ # Add --dry-run if you don't want to do this for realz
+ cmd = [self.purge_tool,
+ '-s', str(min_size),
+ ]
+
+ if max_age:
+ cmd.extend(['--max-age', str(max_age)])
+
+ for s in skip:
+ cmd.extend(['--not', s])
+
+ cmd.append(basedir)
+
+ # purge_builds.py can also clean up old shared hg repos if we set
+ # HG_SHARE_BASE_DIR accordingly
+ env = {'PATH': os.environ.get('PATH')}
+ share_base = c.get('vcs_share_base', os.environ.get("HG_SHARE_BASE_DIR", None))
+ if share_base:
+ env['HG_SHARE_BASE_DIR'] = share_base
+ retval = self.run_command(cmd, env=env)
+ if retval != 0:
+ self.fatal("failed to purge builds", exit_code=2)
View
4 scripts/b2g_build.py
@@ -17,6 +17,7 @@
from mozharness.mozilla.mock import MockMixin
from mozharness.mozilla.tooltool import TooltoolMixin
from mozharness.mozilla.buildbot import BuildbotMixin
+from mozharness.mozilla.purge import PurgeMixin
try:
import simplejson as json
@@ -25,7 +26,7 @@
import json
-class B2GBuild(MockMixin, BaseScript, VCSMixin, TooltoolMixin, TransferMixin, BuildbotMixin):
+class B2GBuild(MockMixin, BaseScript, VCSMixin, TooltoolMixin, TransferMixin, BuildbotMixin, PurgeMixin):
config_options = [
[["--repo"], {
"dest": "repo",
@@ -55,6 +56,7 @@ def __init__(self, require_config_file=False):
config_options=self.config_options,
all_actions=[
'clobber', # From BaseScript
+ 'purge-builds', # From PurgeMixin
'checkout-gecko',
# Download via tooltool repo in gecko checkout or via explicit url
'download-gonk',
Please sign in to comment.
Something went wrong with that request. Please try again.