Merge ~chad.smith/cloud-init:ci-deps-fixes into cloud-init:master

Proposed by Chad Smith on 2017-06-14
Status: Merged
Merged at revision: b23d9d7c5c112612dbaaf8c8371c9e735500b2eb
Proposed branch: ~chad.smith/cloud-init:ci-deps-fixes
Merge into: cloud-init:master
Diff against target: 149 lines (+43/-18)
4 files modified
Makefile (+2/-4)
packages/bddeb (+3/-1)
tools/read-dependencies (+37/-9)
tools/run-centos (+1/-4)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2017-06-14
Scott Moser 2017-06-14 Approve on 2017-06-14
Review via email: mp+325693@code.launchpad.net

Commit Message

ci deps: Add --test-distro to read-dependencies to install all deps

read-dependencies now takes --test-distro param to indicate we want to install all system package depenencies to allow for testing and building for our continous integration environment. It allows us to install all needed deps on a fresh system with python3 ./tools/read-depenencies --distro ubuntu --test-distro [--dry-run].

Additionally read-dependencies now looks at what version of python is running the script (py2 vs p3) and opts to install python 2 or 3 system deps respectively. This behavior can still be overridden with python3 ./tools/read-dependencies ... --python-version 2.

There are also some distro-specific packaging dependencies, like devscripts on debian or ubuntu. Those pkg dependencies have now been broken out from common pkg deps to avoid trying to install them on centos/redhat/suse.

Description of the Change

ci dependency installs: Add --test-distro param to read-dependencies to install deps

read-dependencies now takes --test-distro param to indicate we want to install all system package depenencies to allow for testing and building for our continous integration environment. It allows us to install all needed deps on a fresh system with python3 ./tools/read-depenencies --distro ubuntu --test-distro [--dry-run].

Additionally read-dependencies now looks at what version of python is running the script (py2 vs p3) and opts to install python 2 or 3 system deps respectively. This behavior can still be overridden with python3 ./tools/read-dependencies ... --python-version 2.

There are also some distro-specific packaging dependencies, like devscripts on debian or ubuntu. Those pkg dependencies have now been broken out from common pkg deps to avoid trying to install them on centos/redhat/suse.

Test instructions:
   lxc launch images:ubuntu/yakkety test-y
   lxc exec test-y bash
   apt update
   apt install git
   git clone -b master https://git.launchpad.net/cloud-init
   python3 ./tools/read-dependencies --distro ubuntu --test-distro
   make deb
   ./packages/bddeb -S

To post a comment you must log in.
~chad.smith/cloud-init:ci-deps-fixes updated on 2017-06-14
1ae35e5... by Chad Smith on 2017-06-14

now --ci-deps -> --test-distro

d2e7483... by Chad Smith on 2017-06-14

use new --test-distro param for read-dependencies

Scott Moser (smoser) wrote :

2 minor requests.

review: Approve
~chad.smith/cloud-init:ci-deps-fixes updated on 2017-06-14
7e28797... by Chad Smith on 2017-06-14

warn about overriding --requirements-file when --test-distro is provided. Update note with deb bug ref

~chad.smith/cloud-init:ci-deps-fixes updated on 2017-06-14
fb499a2... by Chad Smith on 2017-06-14

make --test-distro and --requirements-file a hard error as they should be mutually exclusive

~chad.smith/cloud-init:ci-deps-fixes updated on 2017-06-14
f882215... by Chad Smith on 2017-06-14

add other continuous integraion deps one which ci depends

Chad Smith (chad.smith) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index c752530..e9f5498 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -54,12 +54,10 @@ unittest3: clean_pyc
6 nosetests3 $(noseopts) tests/unittests
7
8 ci-deps-ubuntu:
9- @$(PYVER) $(CWD)/tools/read-dependencies --distro ubuntu --install --python-version 3
10- @$(PYVER) $(CWD)/tools/read-dependencies --distro ubuntu --requirements-file test-requirements.txt --install --python-version 3
11+ @$(PYVER) $(CWD)/tools/read-dependencies --distro-ubuntu --test-distro
12
13 ci-deps-centos:
14- @$(PYVER) $(CWD)/tools/read-dependencies --distro centos --install
15- @$(PYVER) $(CWD)/tools/read-dependencies --distro centos --requirements-file test-requirements.txt --install
16+ @$(PYVER) $(CWD)/tools/read-dependencies --distro centos --test-distro
17
18 pip-requirements:
19 @echo "Installing cloud-init dependencies..."
20diff --git a/packages/bddeb b/packages/bddeb
21index e45af6e..609a94f 100755
22--- a/packages/bddeb
23+++ b/packages/bddeb
24@@ -72,7 +72,9 @@ def write_debian_folder(root, templ_data, is_python2, cloud_util_deps):
25 requires = ['cloud-utils | cloud-guest-utils'] if cloud_util_deps else []
26 # We consolidate all deps as Build-Depends as our package build runs all
27 # tests so we need all runtime dependencies anyway.
28- requires.extend(reqs + test_reqs + [python])
29+ # NOTE: python package was moved to the front after debuild -S would fail with
30+ # 'Please add apropriate interpreter' errors (as in debian bug 861132)
31+ requires.extend([python] + reqs + test_reqs)
32 templater.render_to_file(util.abs_join(find_root(),
33 'packages', 'debian', 'control.in'),
34 util.abs_join(deb_dir, 'control'),
35diff --git a/tools/read-dependencies b/tools/read-dependencies
36index 8a58534..2a64868 100755
37--- a/tools/read-dependencies
38+++ b/tools/read-dependencies
39@@ -40,8 +40,13 @@ DISTRO_INSTALL_PKG_CMD = {
40 }
41
42
43-# List of base system packages required to start using make
44-EXTRA_SYSTEM_BASE_PKGS = ['make', 'sudo', 'tar']
45+# List of base system packages required to enable ci automation
46+CI_SYSTEM_BASE_PKGS = {
47+ 'common': ['make', 'sudo', 'tar'],
48+ 'redhat': ['python-tox'],
49+ 'centos': ['python-tox'],
50+ 'ubuntu': ['devscripts', 'python3-dev', 'libssl-dev', 'tox', 'sbuild'],
51+ 'debian': ['devscripts', 'python3-dev', 'libssl-dev', 'tox', 'sbuild']}
52
53
54 # JSON definition of distro-specific package dependencies
55@@ -70,10 +75,16 @@ def get_parser():
56 dest='install',
57 help='When specified, install the required system packages.')
58 parser.add_argument(
59- '-v', '--python-version', type=str, dest='python_version', default="2",
60+ '-t', '--test-distro', action='store_true', default=False,
61+ dest='test_distro',
62+ help='Additionally install continuous integration system packages '
63+ 'required for build and test automation.')
64+ parser.add_argument(
65+ '-v', '--python-version', type=str, dest='python_version', default=None,
66 choices=["2", "3"],
67- help='The version of python we want to generate system package '
68- 'dependencies for.')
69+ help='Override the version of python we want to generate system '
70+ 'package dependencies for. Defaults to the version of python '
71+ 'this script is called with')
72 return parser
73
74
75@@ -114,13 +125,17 @@ def parse_pip_requirements(requirements_path):
76 return dep_names
77
78
79-def translate_pip_to_system_pkg(pip_requires, renames, python_ver="2"):
80+def translate_pip_to_system_pkg(pip_requires, renames, python_ver):
81 """Translate pip package names to distro-specific package names.
82
83 @param pip_requires: List of versionless pip package names to translate.
84 @param renames: Dict containg special case renames from pip name to system
85 package name for the distro.
86+ @param python_ver: Optional python version string "2" or "3". When None,
87+ use the python version that is calling this script via sys.version_info.
88 """
89+ if python_ver is None:
90+ python_ver = str(sys.version_info[0])
91 if python_ver == "2":
92 prefix = "python-"
93 else:
94@@ -147,6 +162,16 @@ def main(distro):
95 else:
96 topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
97
98+ if args.test_distro:
99+ # Give us all the system deps we need for continuous integration
100+ if args.req_files:
101+ sys.stderr.write(
102+ "Parameter --test-distro overrides --requirements-file. Use "
103+ "one or the other.\n")
104+ sys.exit(1)
105+ args.req_files = [os.path.join(topd, DEFAULT_REQUIREMENTS),
106+ os.path.join(topd, 'test-' + DEFAULT_REQUIREMENTS)]
107+ args.install = True
108 if args.req_files is None:
109 args.req_files = [os.path.join(topd, DEFAULT_REQUIREMENTS)]
110 if not os.path.isfile(args.req_files[0]):
111@@ -179,16 +204,19 @@ def main(distro):
112 else:
113 all_deps = pip_pkg_names
114 if args.install:
115- pkg_install(all_deps, args.distro, args.dry_run)
116+ pkg_install(all_deps, args.distro, args.test_distro, args.dry_run)
117 else:
118 print('\n'.join(all_deps))
119
120
121-def pkg_install(pkg_list, distro, dry_run=False):
122+def pkg_install(pkg_list, distro, test_distro=False, dry_run=False):
123 """Install a list of packages using the DISTRO_INSTALL_PKG_CMD."""
124+ if test_distro:
125+ pkg_list = list(pkg_list) + CI_SYSTEM_BASE_PKGS['common']
126+ distro_base_pkgs = CI_SYSTEM_BASE_PKGS.get(distro, [])
127+ pkg_list += distro_base_pkgs
128 print('Installing deps: {0}{1}'.format(
129 '(dryrun)' if dry_run else '', ' '.join(pkg_list)))
130- pkg_list = list(pkg_list) + EXTRA_SYSTEM_BASE_PKGS
131 install_cmd = []
132 if dry_run:
133 install_cmd.append('echo')
134diff --git a/tools/run-centos b/tools/run-centos
135index 99ba6be..b10e3bc 100755
136--- a/tools/run-centos
137+++ b/tools/run-centos
138@@ -221,10 +221,7 @@ main() {
139 }
140
141 inside_as_cd "$name" root "$cdir" \
142- ./tools/read-dependencies \
143- --requirements-file=requirements.txt \
144- --requirements-file=test-requirements.txt \
145- --distro=centos --install || {
146+ ./tools/read-dependencies --distro=centos --test-distro || {
147 errorrc "FAIL: failed to install dependencies with read-dependencies"
148 return
149 }

Subscribers

People subscribed via source and target branches