From 41717c9122f22de07badadbb7b8269d25c19c08e Mon Sep 17 00:00:00 2001
From: Colm Talbot <colm.talbot@ligo.org>
Date: Mon, 1 Mar 2021 21:37:26 -0600
Subject: [PATCH] Fix ci

---
 .gitlab-ci.yml                       | 17 ++++++++++++++++-
 test/check_author_list.py            |  2 +-
 test/core/sampler/pymc3_test.py      |  3 +++
 test/integration/sampler_run_test.py |  9 +++++++--
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9b39700a9..c7933b768 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,6 +12,7 @@
 stages:
   - initial
   - test
+  - docs
   - deploy
 
 .test-python: &test-python
@@ -47,6 +48,8 @@ python-3.7:
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     # Run pyflakes
     - flake8 .
@@ -62,12 +65,14 @@ python-3.7:
       - htmlcov/
 
 docs:
-  stage: initial
+  stage: docs
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
   script:
     # Make the documentation
     - apt-get -yqq install pandoc
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
     - cd docs
     - pip install ipykernel ipython jupyter
     - cp ../examples/tutorials/*.ipynb ./
@@ -88,6 +93,8 @@ python-3.8:
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python38
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     - pytest
 
@@ -97,6 +104,8 @@ python-3.6:
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     - pytest
 
@@ -106,6 +115,8 @@ python-3.7-samplers:
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python37
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     - pytest test/integration/sampler_run_test.py --durations 10
     - pytest test/integration/sample_from_the_prior_test.py
@@ -116,6 +127,8 @@ python-3.6-samplers:
   image: quay.io/bilbydev/v2-dockerfile-test-suite-python36
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     - pytest test/integration/sampler_run_test.py
 
@@ -138,6 +151,8 @@ scheduled-python-3.7:
     - schedules
   script:
     - python -m pip install .
+    # temporary fix for broken astropy version
+    - pip install pyerfa==1.7.1.1
 
     # Run tests which are only done on schedule
     - pytest test/integration/example_test.py
diff --git a/test/check_author_list.py b/test/check_author_list.py
index 1b082e219..c43f0f003 100644
--- a/test/check_author_list.py
+++ b/test/check_author_list.py
@@ -21,7 +21,7 @@ for line in lines:
     for element in line.split()[1:]:
         element = element.lower()
         if element not in AUTHORS_list and element not in special_cases:
-            print("Failure: {} not in AUTHOR.md".format(element))
+            print(f"Failure: {element} not in AUTHOR.md")
             fail_test += True
 
 if fail_test:
diff --git a/test/core/sampler/pymc3_test.py b/test/core/sampler/pymc3_test.py
index d8a28ad48..ad1df20f4 100644
--- a/test/core/sampler/pymc3_test.py
+++ b/test/core/sampler/pymc3_test.py
@@ -1,10 +1,13 @@
 import unittest
+import pytest
+import sys
 
 from mock import MagicMock
 
 import bilby
 
 
+@pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36")
 class TestPyMC3(unittest.TestCase):
     def setUp(self):
         self.likelihood = MagicMock()
diff --git a/test/integration/sampler_run_test.py b/test/integration/sampler_run_test.py
index 3278ddc0f..d5315cd00 100644
--- a/test/integration/sampler_run_test.py
+++ b/test/integration/sampler_run_test.py
@@ -1,7 +1,10 @@
-import bilby
 import unittest
-import numpy as np
+import pytest
 import shutil
+import sys
+
+import bilby
+import numpy as np
 
 
 class TestRunningSamplers(unittest.TestCase):
@@ -103,6 +106,7 @@ class TestRunningSamplers(unittest.TestCase):
         )
 
     def test_run_pypolychord(self):
+        pytest.importorskip("pypolychord")
         _ = bilby.run_sampler(
             likelihood=self.likelihood,
             priors=self.priors,
@@ -124,6 +128,7 @@ class TestRunningSamplers(unittest.TestCase):
             save=False,
         )
 
+    @pytest.mark.skipif(sys.version_info[1] <= 6, reason="pymc3 is broken in py36")
     def test_run_pymc3(self):
         _ = bilby.run_sampler(
             likelihood=self.likelihood,
-- 
GitLab