Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Bug 795776: Add purge support to b2g builds. r=aki
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris AtLee committed Oct 2, 2012
1 parent be037d2 commit 49682df
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions configs/b2g/releng-try.py
Expand Up @@ -2,6 +2,7 @@
import os
config = {
"default_actions": [
'purge-builds',
'checkout-gecko',
'download-gonk',
'unpack-gonk',
Expand All @@ -28,4 +29,5 @@
"CCACHE_COMPRESS": "1",
"CCACHE_UMASK": "002",
},
"purge_minsize": 10,
}
2 changes: 2 additions & 0 deletions configs/b2g/releng.py
Expand Up @@ -2,6 +2,7 @@
import os
config = {
"default_actions": [
'purge-builds',
'checkout-gecko',
'download-gonk',
'unpack-gonk',
Expand All @@ -27,4 +28,5 @@
"CCACHE_COMPRESS": "1",
"CCACHE_UMASK": "002",
},
"purge_minsize": 10,
}
60 changes: 60 additions & 0 deletions 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)
4 changes: 3 additions & 1 deletion scripts/b2g_build.py
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 49682df

Please sign in to comment.