Skip to content

Commit b9b7fff

Browse files
dhruvmanilacclauss
andauthored
Move CI tests from Travis to GitHub (TheAlgorithms#3889)
* Add initial support for moving tests to GitHub * Add setup Python step in the workflow * Remove Travis CI config file * Fix GitHub action file for build to trigger on PR * Use Python 3.8 as tensorflow is not yet supported * Fix ciphers.hill_cipher doctest error * Fix: instagram crawler tests failing on GitHub actions * Fix floating point errors in doctest * Small change to test cache * Apply suggestions from code review Co-authored-by: Christian Clauss <[email protected]> * Update instagram_crawler.py Co-authored-by: Christian Clauss <[email protected]>
1 parent 8a134e1 commit b9b7fff

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

.github/workflows/build.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "build"
2+
3+
on:
4+
pull_request
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-python@v2
12+
with:
13+
python-version: "3.8"
14+
- uses: actions/cache@v2
15+
with:
16+
path: ~/.cache/pip
17+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip setuptools six
21+
python -m pip install pytest-cov -r requirements.txt
22+
- name: Run tests
23+
run: pytest --doctest-modules --ignore=project_euler/ --cov-report=term-missing:skip-covered --cov=. .
24+
- if: ${{ success() }}
25+
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.travis.yml

-17
This file was deleted.

ciphers/hill_cipher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def make_decrypt_key(self):
155155
"""
156156
>>> hill_cipher = HillCipher(numpy.array([[2, 5], [1, 6]]))
157157
>>> hill_cipher.make_decrypt_key()
158-
array([[ 6., 25.],
159-
[ 5., 26.]])
158+
array([[ 6, 25],
159+
[ 5, 26]])
160160
"""
161161
det = round(numpy.linalg.det(self.encrypt_key))
162162

machine_learning/forecasting/run.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ def linear_regression_prediction(
2525
First method: linear regression
2626
input : training data (date, total_user, total_event) in list of float
2727
output : list of total user prediction in float
28-
>>> linear_regression_prediction([2,3,4,5], [5,3,4,6], [3,1,2,4], [2,1], [2,2])
29-
5.000000000000003
28+
>>> n = linear_regression_prediction([2,3,4,5], [5,3,4,6], [3,1,2,4], [2,1], [2,2])
29+
>>> abs(n - 5.0) < 1e-6 # Checking precision because of floating point errors
30+
True
3031
"""
3132
x = [[1, item, train_mtch[i]] for i, item in enumerate(train_dt)]
3233
x = np.array(x)

web_programming/instagram_crawler.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class InstagramUser:
2323
"""
2424
Class Instagram crawl instagram user information
2525
26-
Usage: (doctest failing on Travis CI)
26+
Usage: (doctest failing on GitHub Actions)
2727
# >>> instagram_user = InstagramUser("github")
2828
# >>> instagram_user.is_verified
2929
True
@@ -102,10 +102,10 @@ def test_instagram_user(username: str = "github") -> None:
102102
A self running doctest
103103
>>> test_instagram_user()
104104
"""
105-
from os import getenv
105+
import os
106106

107-
if getenv("CONTINUOUS_INTEGRATION"):
108-
return # test failing on Travis CI
107+
if os.environ.get("CI"):
108+
return None # test failing on GitHub Actions
109109
instagram_user = InstagramUser(username)
110110
assert instagram_user.user_data
111111
assert isinstance(instagram_user.user_data, dict)

0 commit comments

Comments
 (0)