mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Move CI tests from Travis to GitHub (#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 <cclauss@me.com> * Update instagram_crawler.py Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
8a134e1f45
commit
b9b7fffcc2
25
.github/workflows/build.yml
vendored
Normal file
25
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
name: "build"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "3.8"
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip setuptools six
|
||||||
|
python -m pip install pytest-cov -r requirements.txt
|
||||||
|
- name: Run tests
|
||||||
|
run: pytest --doctest-modules --ignore=project_euler/ --cov-report=term-missing:skip-covered --cov=. .
|
||||||
|
- if: ${{ success() }}
|
||||||
|
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
|
17
.travis.yml
17
.travis.yml
|
@ -1,17 +0,0 @@
|
||||||
os: linux
|
|
||||||
dist: focal
|
|
||||||
language: python
|
|
||||||
python: 3.8
|
|
||||||
cache: pip
|
|
||||||
before_install: pip install --upgrade pip setuptools six
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- name: Build
|
|
||||||
install: pip install pytest-cov -r requirements.txt
|
|
||||||
script:
|
|
||||||
- pytest --doctest-modules --ignore=project_euler/ --cov-report=term-missing:skip-covered --cov=. .
|
|
||||||
after_success:
|
|
||||||
- scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
|
|
||||||
notifications:
|
|
||||||
webhooks: https://www.travisbuddy.com/
|
|
||||||
on_success: never
|
|
|
@ -155,8 +155,8 @@ class HillCipher:
|
||||||
"""
|
"""
|
||||||
>>> hill_cipher = HillCipher(numpy.array([[2, 5], [1, 6]]))
|
>>> hill_cipher = HillCipher(numpy.array([[2, 5], [1, 6]]))
|
||||||
>>> hill_cipher.make_decrypt_key()
|
>>> hill_cipher.make_decrypt_key()
|
||||||
array([[ 6., 25.],
|
array([[ 6, 25],
|
||||||
[ 5., 26.]])
|
[ 5, 26]])
|
||||||
"""
|
"""
|
||||||
det = round(numpy.linalg.det(self.encrypt_key))
|
det = round(numpy.linalg.det(self.encrypt_key))
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,9 @@ def linear_regression_prediction(
|
||||||
First method: linear regression
|
First method: linear regression
|
||||||
input : training data (date, total_user, total_event) in list of float
|
input : training data (date, total_user, total_event) in list of float
|
||||||
output : list of total user prediction in float
|
output : list of total user prediction in float
|
||||||
>>> linear_regression_prediction([2,3,4,5], [5,3,4,6], [3,1,2,4], [2,1], [2,2])
|
>>> n = linear_regression_prediction([2,3,4,5], [5,3,4,6], [3,1,2,4], [2,1], [2,2])
|
||||||
5.000000000000003
|
>>> abs(n - 5.0) < 1e-6 # Checking precision because of floating point errors
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
x = [[1, item, train_mtch[i]] for i, item in enumerate(train_dt)]
|
x = [[1, item, train_mtch[i]] for i, item in enumerate(train_dt)]
|
||||||
x = np.array(x)
|
x = np.array(x)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class InstagramUser:
|
||||||
"""
|
"""
|
||||||
Class Instagram crawl instagram user information
|
Class Instagram crawl instagram user information
|
||||||
|
|
||||||
Usage: (doctest failing on Travis CI)
|
Usage: (doctest failing on GitHub Actions)
|
||||||
# >>> instagram_user = InstagramUser("github")
|
# >>> instagram_user = InstagramUser("github")
|
||||||
# >>> instagram_user.is_verified
|
# >>> instagram_user.is_verified
|
||||||
True
|
True
|
||||||
|
@ -102,10 +102,10 @@ def test_instagram_user(username: str = "github") -> None:
|
||||||
A self running doctest
|
A self running doctest
|
||||||
>>> test_instagram_user()
|
>>> test_instagram_user()
|
||||||
"""
|
"""
|
||||||
from os import getenv
|
import os
|
||||||
|
|
||||||
if getenv("CONTINUOUS_INTEGRATION"):
|
if os.environ.get("CI"):
|
||||||
return # test failing on Travis CI
|
return None # test failing on GitHub Actions
|
||||||
instagram_user = InstagramUser(username)
|
instagram_user = InstagramUser(username)
|
||||||
assert instagram_user.user_data
|
assert instagram_user.user_data
|
||||||
assert isinstance(instagram_user.user_data, dict)
|
assert isinstance(instagram_user.user_data, dict)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user