Merlijn van Deen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/303564
Change subject: ops/puppet CI: check for non-ascii .pp files
......................................................................
ops/puppet CI: check for non-ascii .pp files
Change-Id: Ifc0c8ff234ad6c2c2328dd1e6872d73a5877cdde
---
M tox.ini
A utils/test-ascii.py
2 files changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/64/303564/1
diff --git a/tox.ini b/tox.ini
index 69d5c9d..f34cd3e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,3 +21,6 @@
[testenv:pep8]
deps = flake8==2.5.5
commands = flake8
+
+[testenv:test-ascii]
+commands = python utils/test-ascii.py
diff --git a/utils/test-ascii.py b/utils/test-ascii.py
new file mode 100755
index 0000000..b108131
--- /dev/null
+++ b/utils/test-ascii.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+"""
+test-ascii.py
+
+Read filenames from stdin, and check each of them for non-ascii characters.
+
+Returns the number of errors found (max 127).
+
+"""
+import sys
+import subprocess
+
+exitcode = 0
+
+files = subprocess.check_output(["find", "-name", "*.pp",
"-print0"]).split("\x00")
+files = files[:-1] # find returns a final empty element
+
+for fn in files:
+ try:
+ for lineno, line in enumerate(open(fn), 1):
+ line.decode('ascii')
+ except UnicodeDecodeError as e:
+ print("%s:%s: %s" % (fn, lineno, e))
+ exitcode += 1
+
+exitcode = min(exitcode, 127)
+sys.exit(exitcode)
--
To view, visit https://gerrit.wikimedia.org/r/303564
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc0c8ff234ad6c2c2328dd1e6872d73a5877cdde
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Merlijn van Deen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits