diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e0277125cd217e6a0186972952946ff48f7c933a_LmdpdGxhYi1jaS55bWw=..7b7317f37307e8f7776f2e1077705b0109c7c558_LmdpdGxhYi1jaS55bWw= 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -89,7 +89,9 @@
         apt-get -qq install --no-install-recommends
         gnupg gnupg-agent git unzip ssh
         mercurial python3-dulwich python3-setuptools pyflakes3
-      - python3 tests/run-tests.py -v --xunit $PWD/tests-ubuntu.xml --color=always
+      - >
+        python3 tests/run-tests.py -v
+        --xunit $PWD/tests-ubuntu.xml --color=always --timeout 300
     artifacts:
       reports:
         junit: tests-ubuntu.xml
diff --git a/contrib/ci.sh b/contrib/ci.sh
index e0277125cd217e6a0186972952946ff48f7c933a_Y29udHJpYi9jaS5zaA==..7b7317f37307e8f7776f2e1077705b0109c7c558_Y29udHJpYi9jaS5zaA== 100755
--- a/contrib/ci.sh
+++ b/contrib/ci.sh
@@ -3,5 +3,5 @@
 set -x
 
 exec python$PYTHON tests/run-tests.py \
-     --verbose --color=always \
+     --verbose --color=always --timeout 300 \
      --xunit $PWD/tests-$PYTHON-$HG.xml