Merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-enable-tarmac into lp:core-image-watcher

Proposed by Thomi Richards
Status: Merged
Approved by: Celso Providelo
Approved revision: 6
Merged at revision: 7
Proposed branch: lp:~thomir-deactivatedaccount/core-image-watcher/trunk-enable-tarmac
Merge into: lp:core-image-watcher
Diff against target: 106 lines (+102/-0)
1 file modified
called-by-tarmac.py (+102/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-enable-tarmac
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+254345@code.launchpad.net

Commit message

Enable tarmac for the core-image-watcher.

Description of the change

Enable tarmac for the core-image-watcher.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Yay, not more missing pip-cache deps hitting production.

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'called-by-tarmac.py'
2--- called-by-tarmac.py 2015-03-25 02:16:17 +0000
3+++ called-by-tarmac.py 2015-03-27 04:23:44 +0000
4@@ -0,0 +1,102 @@
5+#!/usr/bin/env python3
6+#
7+# core-image-watcher
8+# Copyright (C) 2015 Canonical
9+#
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation, either version 3 of the License, or
13+# (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+#
23+# called-by-tarmac.py is intended to be called by the tarmac merge engine
24+# to perform automatic unit testing on branch landing.
25+# It replaces the manual commands:
26+# bzr branch $PIP_CACHE_BRANCH pip_cache
27+# virtualenv -p python3 ve && \
28+# ./ve/bin/pip install --no-index --find-links=pip-cache \
29+# -r requirements.txt && \
30+# ./ve/bin/pip install -r test_requirements.txt && \
31+# ./ve/bin/python3 setup.py test && \
32+# rm -rf ve
33+#
34+
35+import os
36+import subprocess
37+import sys
38+import tempfile
39+
40+SERVICE_NAME = 'core-image-watcher'
41+VENV_DIR = 'venv-{}'.format(SERVICE_NAME)
42+PIP_DIR = 'pip-cache-'.format(SERVICE_NAME)
43+PIP_CACHE_BRANCH = 'lp:~canonical-ci-engineering/{}/' \
44+ 'pip-cache'.format(SERVICE_NAME)
45+
46+
47+def _run_command(cmd):
48+ '''Run the command and return the return code or 0 on success.'''
49+
50+ print('INFO: Executing: {}'.format(' '.join(cmd)))
51+ try:
52+ subprocess.check_call(cmd, stderr=subprocess.STDOUT)
53+ except subprocess.CalledProcessError as e:
54+ print('ERROR: Calling `{}` failed (with code {})'.format(
55+ e.cmd, e.returncode))
56+ return e.returncode
57+ return 0
58+
59+
60+def main():
61+ with tempfile.TemporaryDirectory(PIP_DIR) as pip_dir, \
62+ tempfile.TemporaryDirectory(prefix=VENV_DIR) as ve_dir:
63+ pip_cache = os.path.join(pip_dir, 'cache')
64+ all_cmds = (
65+ [
66+ 'bzr',
67+ 'branch',
68+ PIP_CACHE_BRANCH,
69+ pip_cache,
70+ ],
71+ [
72+ 'virtualenv',
73+ '-p',
74+ 'python3',
75+ ve_dir,
76+ ],
77+ [
78+ os.path.join(ve_dir, 'bin', 'pip'),
79+ 'install',
80+ '--no-index',
81+ '--find-links={}'.format(pip_cache),
82+ '-r',
83+ 'requirements.txt',
84+ ],
85+ [
86+ os.path.join(ve_dir, 'bin', 'pip'),
87+ 'install',
88+ '-r',
89+ 'test_requirements.txt',
90+ ],
91+ [
92+ os.path.join(ve_dir, 'bin', 'python3'),
93+ 'setup.py',
94+ 'test',
95+ ],
96+ )
97+ for cmd in all_cmds:
98+ ret = _run_command(cmd)
99+ if ret:
100+ # A cmd failed, bubble up the return code to the caller
101+ return ret
102+ return 0
103+
104+
105+if __name__ == '__main__':
106+ sys.exit(main())

Subscribers

People subscribed via source and target branches

to all changes: