Commits

Gustavo Picon committed ab4af20

adding jenkins scripts to version control

Comments (0)

Files changed (3)

test/jenkins/quality.sh

+#!/bin/sh
+
+# Script that takes source code quality measurements.
+# In shell because it will run in a *NIX node.
+
+pip install pylint pep8 pytest coverage
+coverage erase
+
+# Combining the coverage data of all the test runs
+# in the different OS/Python combinations.
+find $WORKSPACE -mindepth 1 -maxdepth 2 -name '.coverage.*' -exec cp -v \{\} . \;
+coverage combine
+coverage report
+coverage xml
+coverage erase
+
+SRCFILES=numconv.py
+PYFILES="*.py test/*.py"
+ALLFILES="* test/*"
+sloccount --duplicates --wide --details $ALLFILES > sloccount.sc 2>&1
+pep8 $PYFILES > violations-pep8.txt 2>&1
+pylint -f parseable $SRCFILES > violations-pylint.txt 2>&1

test/jenkins/rm_workspace_coverage.py

+#!/usr/bin/env python
+"""Remove `.coverage.$HOST.$ID` files from previous runs.
+
+In Python because of portability with Windows.
+"""
+
+import os
+import sys
+
+def main():
+    workspace = os.environ['WORKSPACE']
+    for filename in os.listdir(workspace):
+        if filename.startswith('.coverage.'):
+            file_full_name = os.path.join(workspace, filename)
+            sys.stdout.write('* Removing old .coverage file: `%s`\n' % file_full_name)
+            os.unlink(file_full_name)
+    sys.stdout.flush()
+
+if __name__ == '__main__':
+    main()

test/jenkins/toxhelper.py

+#!/usr/bin/env python
+""" toxhelper is a simple wrapper of pytest and coverage to be used with tox.
+
+It is specially useful to avoid path and interpreter problems while running
+tests with jenkins in OS X, Linux and Windows using the same configuration.
+
+See https://tabo.pe/jenkins/ for the results.
+"""
+
+import sys
+
+from coverage import coverage
+import pytest
+
+
+def run_the_tests():
+    cov = coverage()
+    cov.start()
+    test_result = pytest.main(sys.argv[1:])
+    cov.stop()
+    cov.save()
+    return test_result
+
+if __name__ == '__main__':
+    sys.exit(run_the_tests())