Skip to content

Commit 2374ec1

Browse files
zeryxkennydaniel
andauthored
CI/CD Improvmenets updated gitlab_ci to test python 2.7, 3.7, 3.8, and 3.9 (#85)
* updated gitlab_ci to test python 2.7, 3.7, 3.8, and 3.9 * migrated each test to it's own stage * testing stage separation system * after successful stage separation, adding all back together * fix failing python2.7 test * to simplify, moved formatting to the payload, rather than the output * fixed double import issue * discovered python27 incompatibility with test suite; updated to make python2.7 compatible Co-authored-by: Kenny Daniel <3903376+kennydaniel@users.noreply.github.com>
1 parent 5da25ac commit 2374ec1

4 files changed

Lines changed: 77 additions & 30 deletions

File tree

.gitlab-ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
stages:
22
- test
3+
- python27
4+
- python37
5+
- python38
6+
- python39
37

48
variables:
59
PROJECT_NAME: algorithmia-python
@@ -25,3 +29,34 @@ test:pytest:36:
2529
- pip install pytest --quiet
2630
- pytest
2731

32+
python27:
33+
stage: python27
34+
image: python:2.7
35+
script:
36+
- pip install -r requirements27.txt --quiet
37+
- pip install pytest --quiet
38+
- pytest
39+
40+
python37:
41+
stage: python37
42+
image: python:3.7
43+
script:
44+
- pip install -r requirements.txt --quiet
45+
- pip install pytest --quiet
46+
- pytest
47+
48+
python38:
49+
stage: python38
50+
image: python:3.8
51+
script:
52+
- pip install -r requirements.txt --quiet
53+
- pip install pytest --quiet
54+
- pytest
55+
56+
python39:
57+
stage: python39
58+
image: python:3.9
59+
script:
60+
- pip install -r requirements.txt --quiet
61+
- pip install pytest --quiet
62+
- pytest

Test/algo_failure_test.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
import sys
2-
from multiprocessing import Process
3-
# look in ../ BEFORE trying to import Algorithmia. If you append to the
4-
# you will load the version installed on the computer.
5-
sys.path = ['../'] + sys.path
62

7-
import unittest
8-
import Algorithmia
9-
import uvicorn
10-
import time
11-
from requests import Response
12-
from Test.api import app
3+
if sys.version_info[0] >= 3:
4+
import unittest
5+
import Algorithmia
6+
import uvicorn
7+
import time
8+
from multiprocessing import Process
9+
# look in ../ BEFORE trying to import Algorithmia. If you append to the
10+
# you will load the version installed on the computer.
11+
sys.path = ['../'] + sys.path
12+
from requests import Response
13+
from Test.api import app
1314

14-
def start_webserver():
15-
uvicorn.run(app, host="127.0.0.1", port=8080, log_level="debug")
15+
def start_webserver():
16+
uvicorn.run(app, host="127.0.0.1", port=8080, log_level="debug")
1617

17-
class AlgoTest(unittest.TestCase):
18-
error_500 = Response()
19-
error_500.status_code = 500
18+
class AlgoTest(unittest.TestCase):
19+
error_500 = Response()
20+
error_500.status_code = 500
2021

21-
def setUp(self):
22-
self.client = Algorithmia.client(api_address="http://localhost:8080")
23-
self.uvi_p = Process(target=start_webserver)
24-
self.uvi_p.start()
25-
time.sleep(1)
26-
def tearDown(self):
27-
self.uvi_p.terminate()
28-
def test_throw_500_error_HTTP_response_on_algo_request(self):
29-
try:
30-
result = self.client.algo('util/Echo').pipe(bytearray('foo','utf-8'))
31-
except Exception as e:
32-
result = e
33-
pass
34-
self.assertEqual(str(self.error_500), str(result))
22+
def setUp(self):
23+
self.client = Algorithmia.client(api_address="http://localhost:8080")
24+
self.uvi_p = Process(target=start_webserver)
25+
self.uvi_p.start()
26+
time.sleep(1)
27+
def tearDown(self):
28+
self.uvi_p.terminate()
29+
def test_throw_500_error_HTTP_response_on_algo_request(self):
30+
try:
31+
result = self.client.algo('util/Echo').pipe(bytearray('foo','utf-8'))
32+
except Exception as e:
33+
result = e
34+
pass
35+
self.assertEqual(str(self.error_500), str(result))

Test/datafile_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def test_set_attributes(self):
4747
def test_putJson_getJson(self):
4848
file = '.my/empty/test.json'
4949
df = DataFile(self.client,'data://'+file)
50-
payload = {"hello":"world"}
50+
if sys.version_info[0] < 3:
51+
payload = {u"hello":u"world"}
52+
else:
53+
payload = {"hello": "world"}
5154
response = df.putJson(payload)
5255
self.assertEqual(response.path,file)
5356
result = self.client.file(file).getJson()

requirements27.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
requests
2+
six
3+
enum-compat
4+
toml
5+
argparse
6+
algorithmia-api-client>=1.3,<1.4
7+
algorithmia-adk>=1.0.2,<1.1
8+
numpy<2

0 commit comments

Comments
 (0)