[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/main] Run the tests on gitlab CI



commit 3b48aab9ab61923f303813be7fd94edf673664d1
Author: meskio <meskio@xxxxxxxxxxxxxx>
Date:   Tue May 4 17:20:28 2021 +0200

    Run the tests on gitlab CI
    
    I had to skip GimpCaptchaTests as the tests do run as root and this test
    was checking that it didn't have permitions to read the file.
    
    Fixes #40012
---
 .gitlab-ci.yml                        | 27 +++++++++++++++++++++++++++
 .test.requirements.txt                |  2 +-
 Makefile                              |  6 ++++--
 bridgedb/test/test_bridgedb_script.py |  2 +-
 bridgedb/test/test_captcha.py         |  3 +++
 scripts/install-dependencies          |  4 ++++
 6 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..2578d21
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,27 @@
+cache:
+  paths:
+    - .cache/pip
+    - /var/cache/apt
+
+image:  python:3.8
+
+.install-bridgedb-template: &install-bridgedb-template
+  before_script:
+    - apt-get update
+    - ./scripts/install-dependencies
+    - make install
+    - pip install -r .test.requirements.txt
+    - ./scripts/setup-tests
+    - bridgedb -r run &
+
+test:
+  <<: *install-bridgedb-template
+  script:
+    - make coverage-test
+
+pycodestyle:
+  allow_failure: true
+  before_script:
+    - pip install pycodestyle
+  script:
+    - make pycodestyle
diff --git a/.test.requirements.txt b/.test.requirements.txt
index e72ed31..3662df5 100644
--- a/.test.requirements.txt
+++ b/.test.requirements.txt
@@ -7,6 +7,6 @@
 #
 coverage==5.1
 mechanize==0.4.5
-pep8==1.7.1
+pycodestyle==2.7.0
 pylint==2.5.2
 sure==1.4.11
diff --git a/Makefile b/Makefile
index 08c2fbd..b3c4d05 100644
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,10 @@ all: uninstall clean install coverage-test
 test:
 	python setup.py test
 
-pep8:
-	find bridgedb/*.py | xargs pep8
+pep8: pycodestyle
+
+pycodestyle:
+	pycodestyle bridgedb
 
 pylint:
 	pylint --rcfile=./.pylintrc ./bridgedb/
diff --git a/bridgedb/test/test_bridgedb_script.py b/bridgedb/test/test_bridgedb_script.py
index b58e016..5bf9e4e 100644
--- a/bridgedb/test/test_bridgedb_script.py
+++ b/bridgedb/test/test_bridgedb_script.py
@@ -43,7 +43,7 @@ class BridgeDBCliTest(unittest.TestCase):
         during other tests, so we can safely decrease the sleep time on CI
         machines.
         """
-        if os.environ.get("TRAVIS"):
+        if os.environ.get("CI"):
             time.sleep(10)
         else:
             time.sleep(20)
diff --git a/bridgedb/test/test_captcha.py b/bridgedb/test/test_captcha.py
index b87251e..5515228 100644
--- a/bridgedb/test/test_captcha.py
+++ b/bridgedb/test/test_captcha.py
@@ -202,6 +202,9 @@ class GimpCaptchaTests(unittest.TestCase):
 
     def test_get_unreadableCaptchaFile(self):
         """An unreadable CAPTCHA file should raise GimpCaptchaError."""
+        if os.geteuid() == 0:
+            raise unittest.SkipTest("Being root I do have permissions to read any file, this test will fail")
+
         os.makedirs(self.badCacheDir)
         badFile = os.path.join(self.badCacheDir, 'uNr34dA81e.jpg')
         with open(badFile, 'w') as fh:
diff --git a/scripts/install-dependencies b/scripts/install-dependencies
index 923b51e..67dfde5 100755
--- a/scripts/install-dependencies
+++ b/scripts/install-dependencies
@@ -21,6 +21,10 @@ if [ "$TRAVIS" == "true" ] ; then
 else
     DEPENDS="${DEPENDS} python-pip flog"
 fi
+
+if [ "$CI" == "true" ] ; then
+    APT_FLAGS="-y ${APT_FLAGS}"
+fi
     
 MISSING=""
 for dep in $DEPENDS ; do

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits