Merge ~cjwatson/git-build-recipe:pre-commit into git-build-recipe:master

Proposed by Colin Watson
Status: Merged
Merged at revision: 9b8016a2b1e75fda42fe7b7bf37475a8c64dc6b2
Proposed branch: ~cjwatson/git-build-recipe:pre-commit
Merge into: git-build-recipe:master
Prerequisite: ~cjwatson/git-build-recipe:tox
Diff against target: 555 lines (+307/-62)
13 files modified
.pre-commit-config.yaml (+14/-0)
.woke.yaml (+221/-0)
bin/git-build-recipe (+6/-6)
gitbuildrecipe/deb_util.py (+6/-6)
gitbuildrecipe/deb_version.py (+6/-6)
gitbuildrecipe/main.py (+6/-6)
gitbuildrecipe/recipe.py (+7/-7)
gitbuildrecipe/tests/__init__.py (+6/-6)
gitbuildrecipe/tests/test_deb_version.py (+6/-6)
gitbuildrecipe/tests/test_functional.py (+7/-7)
gitbuildrecipe/tests/test_recipe.py (+6/-6)
setup.py (+6/-6)
tox.ini (+10/-0)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+415685@code.launchpad.net

Commit message

Add pre-commit and woke configuration

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
2new file mode 100644
3index 0000000..4737b06
4--- /dev/null
5+++ b/.pre-commit-config.yaml
6@@ -0,0 +1,14 @@
7+# See https://pre-commit.com for more information
8+# See https://pre-commit.com/hooks.html for more hooks
9+repos:
10+- repo: https://github.com/pre-commit/pre-commit-hooks
11+ rev: v4.1.0
12+ hooks:
13+ - id: trailing-whitespace
14+ - id: end-of-file-fixer
15+ - id: check-yaml
16+ - id: check-added-large-files
17+- repo: https://github.com/get-woke/woke
18+ rev: v0.17.1
19+ hooks:
20+ - id: woke-from-source
21diff --git a/.woke.yaml b/.woke.yaml
22new file mode 100644
23index 0000000..010ccff
24--- /dev/null
25+++ b/.woke.yaml
26@@ -0,0 +1,221 @@
27+
28+# Based on Canonical's Guidelines
29+# https://docs.google.com/document/d/1mJUa1VJHOMWa723dmKmNjSKGW-nlBv9xktzGZZwacVo/edit#heading=h.5efudb237qdb
30+rules:
31+ - name: whitelist
32+ terms:
33+ - whitelist
34+ - white-list
35+ - whitelisted
36+ - white-listed
37+ alternatives:
38+ - allowlist
39+ - inclusion list
40+ severity: warning
41+ note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day."
42+
43+ - name: blacklist
44+ terms:
45+ - blacklist
46+ - black-list
47+ - blacklisted
48+ - black-listed
49+ alternatives:
50+ - denylist
51+ - blocklist
52+ - exclusion list
53+ severity: warning
54+ note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day."
55+
56+ - name: master-slave
57+ terms:
58+ - master-slave
59+ - master/slave
60+ alternatives:
61+ - leader/follower
62+ - main/replica
63+ - primary/replica
64+ - primary/standby
65+ - primary/secondary
66+
67+ - name: slave
68+ terms:
69+ - slave
70+ alternatives:
71+ - follower
72+ - replica
73+ - standby
74+
75+ - name: grandfathered
76+ terms:
77+ - grandfathered
78+ alternatives:
79+ - legacy status
80+ - legacied
81+ - exempted
82+ - carried
83+ - brought forward
84+ - rolled over
85+
86+ - name: man-hours
87+ terms:
88+ - man hours
89+ - man-hours
90+ alternatives:
91+ - person hours
92+ - engineer hours
93+
94+ - name: sanity
95+ terms:
96+ - sanity
97+ alternatives:
98+ - confidence
99+ - quick check
100+ - coherence check
101+
102+ - name: dummy
103+ terms:
104+ - dummy
105+ alternatives:
106+ - placeholder
107+ - sample
108+
109+ - name: guys
110+ terms:
111+ - guys
112+ alternatives:
113+ - folks
114+ - people
115+ - you all
116+ - y'all
117+ - yinz
118+
119+ - name: whitebox
120+ terms:
121+ - white-box
122+ - whitebox
123+ - white box
124+ alternatives:
125+ - open-box
126+
127+ - name: blackbox
128+ terms:
129+ - black-box
130+ - blackbox
131+ - black box
132+ alternatives:
133+ - closed-box
134+
135+ - name: blackhat
136+ terms:
137+ - blackhat
138+ - black-hat
139+ - black hat
140+ alternatives:
141+ - attacker
142+ - malicious actor
143+
144+ - name: whitehat
145+ terms:
146+ - whitehat
147+ - white-hat
148+ - white hat
149+ alternatives:
150+ - researcher
151+ - security specialist
152+
153+ - name: illegal characters
154+ terms:
155+ - illegal characters
156+ alternatives:
157+ - invalid characters
158+ - unsupported characters
159+ - special characters
160+
161+ - name: native feature
162+ terms:
163+ - native feature
164+ alternatives:
165+ - core feature
166+ - built-in feature
167+
168+ - name: chairman/foreman
169+ terms:
170+ - chairman
171+ - foreman
172+ alternatives:
173+ - chair
174+ - foreperson
175+
176+ - name: man in the middle
177+ terms:
178+ - man in the middle
179+ - man-in-the-middle
180+ alternatives:
181+ - machine-in-the-middle
182+ - person-in-the-middle
183+ - system-in-the-middle
184+ - intermediary attack
185+
186+ - name: middleman
187+ terms:
188+ - middleman
189+ alternatives:
190+ - middleperson
191+ - intermediary
192+
193+ - name: manned
194+ terms:
195+ - manned
196+ alternatives:
197+ - crewed
198+ - staffed
199+ - monitored
200+ - human operated
201+
202+ - name: mom test / girlfriend test
203+ terms:
204+ - mom test
205+ - girlfriend test
206+ alternatives:
207+ - user test
208+ - user friendly
209+
210+ - name: crazy
211+ terms:
212+ - crazy
213+ alternatives:
214+ - baffling
215+ - unexplained
216+ - errant
217+
218+ - name: cripples
219+ terms:
220+ - cripples
221+ alternatives:
222+ - slows down
223+ - hinders
224+ - obstructs
225+
226+ - name: crippling
227+ terms:
228+ - crippling
229+ alternatives:
230+ - attenuating
231+ - incapacitating
232+
233+ - name: stonith/stomith
234+ terms:
235+ - stonith
236+ - stomith
237+ alternatives:
238+ - fence failed nodes
239+ - machines
240+
241+ - name: demilitarized zone
242+ terms:
243+ - demilitarized zone
244+ - dmz
245+ alternatives:
246+ - perimeter network
247+ - passthrough network
248diff --git a/bin/git-build-recipe b/bin/git-build-recipe
249index 3f4bd34..2e34b58 100755
250--- a/bin/git-build-recipe
251+++ b/bin/git-build-recipe
252@@ -2,16 +2,16 @@
253
254 # Copyright 2015 Canonical Ltd.
255 #
256-# This program is free software: you can redistribute it and/or modify it
257-# under the terms of the GNU General Public License version 3, as published
258+# This program is free software: you can redistribute it and/or modify it
259+# under the terms of the GNU General Public License version 3, as published
260 # by the Free Software Foundation.
261 #
262-# This program is distributed in the hope that it will be useful, but
263-# WITHOUT ANY WARRANTY; without even the implied warranties of
264-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
265+# This program is distributed in the hope that it will be useful, but
266+# WITHOUT ANY WARRANTY; without even the implied warranties of
267+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
268 # PURPOSE. See the GNU General Public License for more details.
269 #
270-# You should have received a copy of the GNU General Public License along
271+# You should have received a copy of the GNU General Public License along
272 # with this program. If not, see <http://www.gnu.org/licenses/>.
273
274 """A Git command to construct trees based on recipes."""
275diff --git a/gitbuildrecipe/deb_util.py b/gitbuildrecipe/deb_util.py
276index 56778e5..d0a6666 100644
277--- a/gitbuildrecipe/deb_util.py
278+++ b/gitbuildrecipe/deb_util.py
279@@ -1,15 +1,15 @@
280 # Copyright 2015 Canonical Ltd.
281 #
282-# This program is free software: you can redistribute it and/or modify it
283-# under the terms of the GNU General Public License version 3, as published
284+# This program is free software: you can redistribute it and/or modify it
285+# under the terms of the GNU General Public License version 3, as published
286 # by the Free Software Foundation.
287 #
288-# This program is distributed in the hope that it will be useful, but
289-# WITHOUT ANY WARRANTY; without even the implied warranties of
290-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
291+# This program is distributed in the hope that it will be useful, but
292+# WITHOUT ANY WARRANTY; without even the implied warranties of
293+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
294 # PURPOSE. See the GNU General Public License for more details.
295 #
296-# You should have received a copy of the GNU General Public License along
297+# You should have received a copy of the GNU General Public License along
298 # with this program. If not, see <http://www.gnu.org/licenses/>.
299
300 import email.utils
301diff --git a/gitbuildrecipe/deb_version.py b/gitbuildrecipe/deb_version.py
302index 2576357..f70bc49 100644
303--- a/gitbuildrecipe/deb_version.py
304+++ b/gitbuildrecipe/deb_version.py
305@@ -1,15 +1,15 @@
306 # Copyright 2015 Canonical Ltd.
307 #
308-# This program is free software: you can redistribute it and/or modify it
309-# under the terms of the GNU General Public License version 3, as published
310+# This program is free software: you can redistribute it and/or modify it
311+# under the terms of the GNU General Public License version 3, as published
312 # by the Free Software Foundation.
313 #
314-# This program is distributed in the hope that it will be useful, but
315-# WITHOUT ANY WARRANTY; without even the implied warranties of
316-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
317+# This program is distributed in the hope that it will be useful, but
318+# WITHOUT ANY WARRANTY; without even the implied warranties of
319+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
320 # PURPOSE. See the GNU General Public License for more details.
321 #
322-# You should have received a copy of the GNU General Public License along
323+# You should have received a copy of the GNU General Public License along
324 # with this program. If not, see <http://www.gnu.org/licenses/>.
325
326 """Handle deb-version and related substitutions."""
327diff --git a/gitbuildrecipe/main.py b/gitbuildrecipe/main.py
328index 6294852..30e6bec 100644
329--- a/gitbuildrecipe/main.py
330+++ b/gitbuildrecipe/main.py
331@@ -2,16 +2,16 @@
332
333 # Copyright 2015 Canonical Ltd.
334 #
335-# This program is free software: you can redistribute it and/or modify it
336-# under the terms of the GNU General Public License version 3, as published
337+# This program is free software: you can redistribute it and/or modify it
338+# under the terms of the GNU General Public License version 3, as published
339 # by the Free Software Foundation.
340 #
341-# This program is distributed in the hope that it will be useful, but
342-# WITHOUT ANY WARRANTY; without even the implied warranties of
343-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
344+# This program is distributed in the hope that it will be useful, but
345+# WITHOUT ANY WARRANTY; without even the implied warranties of
346+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
347 # PURPOSE. See the GNU General Public License for more details.
348 #
349-# You should have received a copy of the GNU General Public License along
350+# You should have received a copy of the GNU General Public License along
351 # with this program. If not, see <http://www.gnu.org/licenses/>.
352
353 """A Git command to construct trees based on recipes."""
354diff --git a/gitbuildrecipe/recipe.py b/gitbuildrecipe/recipe.py
355index 0ff215f..f932ca7 100644
356--- a/gitbuildrecipe/recipe.py
357+++ b/gitbuildrecipe/recipe.py
358@@ -1,15 +1,15 @@
359 # Copyright 2015 Canonical Ltd.
360 #
361-# This program is free software: you can redistribute it and/or modify it
362-# under the terms of the GNU General Public License version 3, as published
363+# This program is free software: you can redistribute it and/or modify it
364+# under the terms of the GNU General Public License version 3, as published
365 # by the Free Software Foundation.
366 #
367-# This program is distributed in the hope that it will be useful, but
368-# WITHOUT ANY WARRANTY; without even the implied warranties of
369-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
370+# This program is distributed in the hope that it will be useful, but
371+# WITHOUT ANY WARRANTY; without even the implied warranties of
372+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
373 # PURPOSE. See the GNU General Public License for more details.
374 #
375-# You should have received a copy of the GNU General Public License along
376+# You should have received a copy of the GNU General Public License along
377 # with this program. If not, see <http://www.gnu.org/licenses/>.
378
379 """Handle recipe parsing and substitution variables."""
380@@ -845,7 +845,7 @@ class BaseRecipeBranch(RecipeBranch):
381 manifest += self._add_child_branches_to_manifest(
382 self.child_branches, 0)
383 if validate:
384- # Sanity check.
385+ # Ensure that the recipe can be parsed.
386 # TODO: write a function that compares the result of this parse
387 # with the branch that we built it from.
388 RecipeParser(manifest).parse()
389diff --git a/gitbuildrecipe/tests/__init__.py b/gitbuildrecipe/tests/__init__.py
390index 6b41396..d968f5b 100644
391--- a/gitbuildrecipe/tests/__init__.py
392+++ b/gitbuildrecipe/tests/__init__.py
393@@ -1,15 +1,15 @@
394 # Copyright 2015 Canonical Ltd.
395 #
396-# This program is free software: you can redistribute it and/or modify it
397-# under the terms of the GNU General Public License version 3, as published
398+# This program is free software: you can redistribute it and/or modify it
399+# under the terms of the GNU General Public License version 3, as published
400 # by the Free Software Foundation.
401 #
402-# This program is distributed in the hope that it will be useful, but
403-# WITHOUT ANY WARRANTY; without even the implied warranties of
404-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
405+# This program is distributed in the hope that it will be useful, but
406+# WITHOUT ANY WARRANTY; without even the implied warranties of
407+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
408 # PURPOSE. See the GNU General Public License for more details.
409 #
410-# You should have received a copy of the GNU General Public License along
411+# You should have received a copy of the GNU General Public License along
412 # with this program. If not, see <http://www.gnu.org/licenses/>.
413
414 import os.path
415diff --git a/gitbuildrecipe/tests/test_deb_version.py b/gitbuildrecipe/tests/test_deb_version.py
416index f58f56f..662e811 100644
417--- a/gitbuildrecipe/tests/test_deb_version.py
418+++ b/gitbuildrecipe/tests/test_deb_version.py
419@@ -1,15 +1,15 @@
420 # Copyright 2015 Canonical Ltd.
421 #
422-# This program is free software: you can redistribute it and/or modify it
423-# under the terms of the GNU General Public License version 3, as published
424+# This program is free software: you can redistribute it and/or modify it
425+# under the terms of the GNU General Public License version 3, as published
426 # by the Free Software Foundation.
427 #
428-# This program is distributed in the hope that it will be useful, but
429-# WITHOUT ANY WARRANTY; without even the implied warranties of
430-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
431+# This program is distributed in the hope that it will be useful, but
432+# WITHOUT ANY WARRANTY; without even the implied warranties of
433+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
434 # PURPOSE. See the GNU General Public License for more details.
435 #
436-# You should have received a copy of the GNU General Public License along
437+# You should have received a copy of the GNU General Public License along
438 # with this program. If not, see <http://www.gnu.org/licenses/>.
439
440 import datetime
441diff --git a/gitbuildrecipe/tests/test_blackbox.py b/gitbuildrecipe/tests/test_functional.py
442similarity index 98%
443rename from gitbuildrecipe/tests/test_blackbox.py
444rename to gitbuildrecipe/tests/test_functional.py
445index c951a19..56fd216 100644
446--- a/gitbuildrecipe/tests/test_blackbox.py
447+++ b/gitbuildrecipe/tests/test_functional.py
448@@ -1,15 +1,15 @@
449 # Copyright 2015 Canonical Ltd.
450
451-# This program is free software: you can redistribute it and/or modify it
452-# under the terms of the GNU General Public License version 3, as published
453+# This program is free software: you can redistribute it and/or modify it
454+# under the terms of the GNU General Public License version 3, as published
455 # by the Free Software Foundation.
456
457-# This program is distributed in the hope that it will be useful, but
458-# WITHOUT ANY WARRANTY; without even the implied warranties of
459-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
460+# This program is distributed in the hope that it will be useful, but
461+# WITHOUT ANY WARRANTY; without even the implied warranties of
462+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
463 # PURPOSE. See the GNU General Public License for more details.
464
465-# You should have received a copy of the GNU General Public License along
466+# You should have received a copy of the GNU General Public License along
467 # with this program. If not, see <http://www.gnu.org/licenses/>.
468
469 import hashlib
470@@ -87,7 +87,7 @@ def make_pristine_tar_delta(dest, tarball_path):
471 return stdout
472
473
474-class BlackboxBuilderTests(GitTestCase):
475+class FunctionalBuilderTests(GitTestCase):
476
477 def setUp(self):
478 super().setUp()
479diff --git a/gitbuildrecipe/tests/test_recipe.py b/gitbuildrecipe/tests/test_recipe.py
480index 7628a45..bfc6452 100644
481--- a/gitbuildrecipe/tests/test_recipe.py
482+++ b/gitbuildrecipe/tests/test_recipe.py
483@@ -1,15 +1,15 @@
484 # Copyright 2015 Canonical Ltd.
485 #
486-# This program is free software: you can redistribute it and/or modify it
487-# under the terms of the GNU General Public License version 3, as published
488+# This program is free software: you can redistribute it and/or modify it
489+# under the terms of the GNU General Public License version 3, as published
490 # by the Free Software Foundation.
491 #
492-# This program is distributed in the hope that it will be useful, but
493-# WITHOUT ANY WARRANTY; without even the implied warranties of
494-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
495+# This program is distributed in the hope that it will be useful, but
496+# WITHOUT ANY WARRANTY; without even the implied warranties of
497+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
498 # PURPOSE. See the GNU General Public License for more details.
499 #
500-# You should have received a copy of the GNU General Public License along
501+# You should have received a copy of the GNU General Public License along
502 # with this program. If not, see <http://www.gnu.org/licenses/>.
503
504 import os
505diff --git a/setup.py b/setup.py
506index a9e781a..930bde2 100755
507--- a/setup.py
508+++ b/setup.py
509@@ -2,16 +2,16 @@
510
511 # Copyright 2015 Canonical Ltd.
512 #
513-# This program is free software: you can redistribute it and/or modify it
514-# under the terms of the GNU General Public License version 3, as published
515+# This program is free software: you can redistribute it and/or modify it
516+# under the terms of the GNU General Public License version 3, as published
517 # by the Free Software Foundation.
518 #
519-# This program is distributed in the hope that it will be useful, but
520-# WITHOUT ANY WARRANTY; without even the implied warranties of
521-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
522+# This program is distributed in the hope that it will be useful, but
523+# WITHOUT ANY WARRANTY; without even the implied warranties of
524+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
525 # PURPOSE. See the GNU General Public License for more details.
526 #
527-# You should have received a copy of the GNU General Public License along
528+# You should have received a copy of the GNU General Public License along
529 # with this program. If not, see <http://www.gnu.org/licenses/>.
530
531 from setuptools import setup
532diff --git a/tox.ini b/tox.ini
533index f990d65..c36a664 100644
534--- a/tox.ini
535+++ b/tox.ini
536@@ -1,5 +1,6 @@
537 [tox]
538 envlist =
539+ lint
540 py36
541 py37
542 py38
543@@ -14,3 +15,12 @@ deps =
544 pytest
545 commands =
546 pytest {posargs}
547+
548+[testenv:lint]
549+basepython =
550+ python3.10
551+deps =
552+ pre-commit
553+skip_install = true
554+commands =
555+ pre-commit run -a

Subscribers

People subscribed via source and target branches