Merge ~nacc/git-ubuntu:script-add-options into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Merge reported by: Nish Aravamudan
Merged at revision: 0b10138cd2029a9727ead8407d1bfd302ad5c186
Proposed branch: ~nacc/git-ubuntu:script-add-options
Merge into: git-ubuntu:master
Diff against target: 221 lines (+57/-5)
5 files modified
bin/import-source-packages.py (+1/-0)
bin/source-package-walker.py (+14/-2)
gitubuntu/scriptutils.py (+10/-2)
gitubuntu/scriptutils_test.py (+31/-0)
snap/wrappers/git-ubuntu-self-test (+1/-1)
Reviewer Review Type Date Requested Status
Nish Aravamudan Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+340139@code.launchpad.net

Description of the change

General fixes/cleanups again.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:0b10138cd2029a9727ead8407d1bfd302ad5c186
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/332/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/332/rebuild

review: Approve (continuous-integration)
Revision history for this message
Nish Aravamudan (nacc) wrote :

Self-approving.

review: Approve
Revision history for this message
Nish Aravamudan (nacc) wrote :

Self-approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/import-source-packages.py b/bin/import-source-packages.py
2index 5c52948..aa51c63 100755
3--- a/bin/import-source-packages.py
4+++ b/bin/import-source-packages.py
5@@ -150,6 +150,7 @@ def import_new_published_sources(
6 ret = scriptutils.pool_map_import_srcpkg(
7 num_workers=num_workers,
8 dry_run=dry_run,
9+ reimport=False,
10 pkgnames=filtered_pkgnames,
11 )
12
13diff --git a/bin/source-package-walker.py b/bin/source-package-walker.py
14index 28e2425..0395b18 100755
15--- a/bin/source-package-walker.py
16+++ b/bin/source-package-walker.py
17@@ -43,6 +43,7 @@ def import_all_published_sources(
18 phasing_main,
19 phasing_universe,
20 dry_run,
21+ reimport,
22 ):
23 """Import all publishes satisfying a {white,black}list and phasing
24
25@@ -53,6 +54,7 @@ def import_all_published_sources(
26 phasing_main - a integer percentage of all packages in main to import
27 phasing_universe - a integer percentage of all packages in universe to import
28 dry_run - a boolean to indicate a dry-run operation
29+ reimport - a boolean to indicate source packages should be reimported
30
31 Returns:
32 A tuple of two lists, the first containing the names of all
33@@ -88,7 +90,6 @@ def import_all_published_sources(
34 url + compression
35 ) as source_url_file:
36 with opener(source_url_file, mode='r') as sources:
37- print(url + compression)
38 for src in Sources.iter_paragraphs(
39 sources,
40 use_apt_pkg=False,
41@@ -124,6 +125,7 @@ def import_all_published_sources(
42 return scriptutils.pool_map_import_srcpkg(
43 num_workers=num_workers,
44 dry_run=dry_run,
45+ reimport=reimport,
46 pkgnames=pkgnames,
47 )
48
49@@ -135,6 +137,7 @@ def main(
50 phasing_universe=scriptutils.DEFAULTS.phasing_universe,
51 dry_run=scriptutils.DEFAULTS.dry_run,
52 use_whitelist=scriptutils.DEFAULTS.use_whitelist,
53+ reimport=scriptutils.DEFAULTS.reimport,
54 ):
55 """Main entry point to the script
56
57@@ -151,6 +154,7 @@ def main(
58 dry_run - a boolean to indicate a dry-run operation
59 use_whitelist - a boolean to control whether the whitelist data is
60 used
61+ reimport - a boolean to indicate source packages should be reimported
62
63 use_whitelist exists because during the rampup of imports, we want
64 to import the whitelist packages and the phased packages. But after
65@@ -189,6 +193,7 @@ def main(
66 phasing_main,
67 phasing_universe,
68 dry_run,
69+ reimport,
70 )
71 print(
72 "Imported %d source packages:\n%s" % (
73@@ -220,7 +225,7 @@ def cli_main():
74 action='store_false',
75 dest='use_whitelist',
76 help="Do not process packages in the whitelist",
77- default=not scriptutils.DEFAULTS.use_whitelist,
78+ default=scriptutils.DEFAULTS.use_whitelist,
79 )
80 parser.add_argument(
81 '--whitelist',
82@@ -252,6 +257,12 @@ def cli_main():
83 help="Simulate operation but do not actually do anything",
84 default=scriptutils.DEFAULTS.dry_run,
85 )
86+ parser.add_argument(
87+ '--reimport',
88+ action='store_true',
89+ help="Reimport source packages",
90+ default=scriptutils.DEFAULTS.reimport,
91+ )
92
93 args = parser.parse_args()
94
95@@ -263,6 +274,7 @@ def cli_main():
96 phasing_universe=args.phasing_universe,
97 dry_run=args.dry_run,
98 use_whitelist=args.use_whitelist,
99+ reimport=args.reimport,
100 )
101
102 if __name__ == '__main__':
103diff --git a/gitubuntu/scriptutils.py b/gitubuntu/scriptutils.py
104index 58843a2..6806bbf 100644
105--- a/gitubuntu/scriptutils.py
106+++ b/gitubuntu/scriptutils.py
107@@ -35,6 +35,7 @@ Defaults = namedtuple(
108 'phasing_main',
109 'dry_run',
110 'use_whitelist',
111+ 'reimport',
112 ],
113 )
114
115@@ -52,6 +53,7 @@ DEFAULTS = Defaults(
116 phasing_main=1,
117 dry_run=False,
118 use_whitelist=True,
119+ reimport=False,
120 )
121
122
123@@ -101,12 +103,13 @@ def should_import_srcpkg(
124 return False
125
126
127-def import_srcpkg(pkgname, dry_run):
128+def import_srcpkg(pkgname, dry_run, reimport):
129 """Invoke git ubuntu import on @pkgname
130
131 Arguments:
132 pkgname - string name of a source package
133 dry_run - a boolean to indicate a dry-run operation
134+ reimport - a boolean to indicate a reimport operation
135
136 Returns:
137 A tuple of a string and a boolean, where the boolean is the success
138@@ -123,8 +126,10 @@ def import_srcpkg(pkgname, dry_run):
139 'import',
140 '-l',
141 'usd-importer-bot',
142- pkgname,
143 ]
144+ if reimport:
145+ cmd.append('--reimport')
146+ cmd.append(pkgname)
147 try:
148 print(' '.join(cmd))
149 if not dry_run:
150@@ -163,6 +168,7 @@ def setup_git_config(
151 def pool_map_import_srcpkg(
152 num_workers,
153 dry_run,
154+ reimport,
155 pkgnames,
156 ):
157 """Use a multiprocessing.Pool to parallel import source packages
158@@ -170,12 +176,14 @@ def pool_map_import_srcpkg(
159 Arguments:
160 num_workers - integer number of worker processes to use
161 dry_run - a boolean to indicate a dry-run operation
162+ reimport- a boolean to indicate a reimport operation
163 pkgnames - a list of string names of source packages
164 """
165 map_args = [
166 functools.partial(
167 import_srcpkg,
168 dry_run=dry_run,
169+ reimport=reimport,
170 ),
171 pkgnames,
172 ]
173diff --git a/gitubuntu/scriptutils_test.py b/gitubuntu/scriptutils_test.py
174new file mode 100755
175index 0000000..63d72ff
176--- /dev/null
177+++ b/gitubuntu/scriptutils_test.py
178@@ -0,0 +1,31 @@
179+#!/usr/bin/env python3
180+
181+import pytest
182+
183+import gitubuntu.scriptutils as target
184+
185+@pytest.mark.parametrize('pkgname, component, whitelist, blacklist, phasing_main, phasing_universe, expected', [
186+ ('jimtcl', 'universe', [], [], 1, 0, False),
187+ ('jimtcl', 'universe', [], [], 1, 100, True),
188+ ('jimtcl', 'universe', ['jimtcl',], [], 1, 0, True),
189+ ('linux', 'main', [], ['linux',], 100, 0, False),
190+ ('jimtcl', 'main', ['php7.2', 'apache2', 'bind9'], [], 0, 0, False),
191+ ('php7.2', 'main', ['php7.2', 'apache2', 'bind9'], [], 0, 0, True),
192+])
193+def test_should_import_srcpkg(
194+ pkgname,
195+ component,
196+ whitelist,
197+ blacklist,
198+ phasing_main,
199+ phasing_universe,
200+ expected,
201+):
202+ assert target.should_import_srcpkg(
203+ pkgname=pkgname,
204+ component=component,
205+ whitelist=whitelist,
206+ blacklist=blacklist,
207+ phasing_main=phasing_main,
208+ phasing_universe=phasing_universe,
209+ ) == expected
210diff --git a/snap/wrappers/git-ubuntu-self-test b/snap/wrappers/git-ubuntu-self-test
211index 04789b4..f57cde7 100755
212--- a/snap/wrappers/git-ubuntu-self-test
213+++ b/snap/wrappers/git-ubuntu-self-test
214@@ -8,7 +8,7 @@ if [ $PYLINT_RC == 0 ]; then
215 fi
216
217 TMPFILE=$(mktemp)
218-COVERAGE_FILE=$TMPFILE python3 -m pytest -p no:cacheprovider --cov=gitubuntu $SNAP/lib/python3.6/site-packages/gitubuntu/*
219+COVERAGE_FILE=$TMPFILE python3 -m pytest -p no:cacheprovider --cov=$SNAP/lib/python3.6/site-packages/gitubuntu $SNAP/lib/python3.6/site-packages/gitubuntu/*
220 PYTEST_RC=$?
221 unlink $TMPFILE
222

Subscribers

People subscribed via source and target branches