From 40708da7decb86bffc78318ce76af12b1a8dcb89 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Sat, 14 Nov 2020 10:45:42 +0530 Subject: [PATCH 01/11] Add initial support for moving tests to GitHub --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000000..b61bbadbf569 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +on: + pull_request: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - 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 From b03a763549c6f79f2b419bdd68f9e117d96e8c1b Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Sat, 14 Nov 2020 11:00:49 +0530 Subject: [PATCH 02/11] Add setup Python step in the workflow --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b61bbadbf569..720cec042660 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 - uses: actions/cache@v2 with: path: ~/.cache/pip From 94fe1c59ca71fcf52ddfcebd31ad5ee6fb971f9e Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 16:31:34 +0530 Subject: [PATCH 03/11] Remove Travis CI config file --- .travis.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c74669ebcb51..000000000000 --- a/.travis.yml +++ /dev/null @@ -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 From 9a745d8d256218130607e97fed0543d369e44acc Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 16:34:09 +0530 Subject: [PATCH 04/11] Fix GitHub action file for build to trigger on PR --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 720cec042660..fd41338ac440 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,4 @@ -on: - pull_request: - - master +on: [pull_request] jobs: build: From 4374238f03324d312df09322340a2826b1895125 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 16:44:41 +0530 Subject: [PATCH 05/11] Use Python 3.8 as tensorflow is not yet supported --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd41338ac440..e34639959933 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,5 @@ +name: "build" + on: [pull_request] jobs: @@ -6,6 +8,8 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 + with: + python-version: "3.8" - uses: actions/cache@v2 with: path: ~/.cache/pip From 3a1b62820b248d6e30c46d29ba2da418a0201cce Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 16:51:06 +0530 Subject: [PATCH 06/11] Fix ciphers.hill_cipher doctest error --- ciphers/hill_cipher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciphers/hill_cipher.py b/ciphers/hill_cipher.py index 3dabcd3fceab..8237abf6aa5d 100644 --- a/ciphers/hill_cipher.py +++ b/ciphers/hill_cipher.py @@ -155,8 +155,8 @@ def make_decrypt_key(self): """ >>> hill_cipher = HillCipher(numpy.array([[2, 5], [1, 6]])) >>> hill_cipher.make_decrypt_key() - array([[ 6., 25.], - [ 5., 26.]]) + array([[ 6, 25], + [ 5, 26]]) """ det = round(numpy.linalg.det(self.encrypt_key)) From 6f4809f6f4d72a4c6465c08e2793ea05662d8c96 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 17:05:05 +0530 Subject: [PATCH 07/11] Fix: instagram crawler tests failing on GitHub actions --- web_programming/instagram_crawler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web_programming/instagram_crawler.py b/web_programming/instagram_crawler.py index c81635bd3593..7b4358269033 100644 --- a/web_programming/instagram_crawler.py +++ b/web_programming/instagram_crawler.py @@ -23,7 +23,7 @@ class InstagramUser: """ Class Instagram crawl instagram user information - Usage: (doctest failing on Travis CI) + Usage: (doctest failing on GitHub actions) # >>> instagram_user = InstagramUser("github") # >>> instagram_user.is_verified True @@ -102,10 +102,10 @@ def test_instagram_user(username: str = "github") -> None: A self running doctest >>> test_instagram_user() """ - from os import getenv + import os - if getenv("CONTINUOUS_INTEGRATION"): - return # test failing on Travis CI + if os.environ.get("GITHUB_ACTIONS"): + return None # test failing on GitHub actions instagram_user = InstagramUser(username) assert instagram_user.user_data assert isinstance(instagram_user.user_data, dict) From 7b2f199466f87453d9448b13f51bac18a47e1bb1 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 17:18:09 +0530 Subject: [PATCH 08/11] Fix floating point errors in doctest --- machine_learning/forecasting/run.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/machine_learning/forecasting/run.py b/machine_learning/forecasting/run.py index 467371e8d2ff..0e11f958825f 100644 --- a/machine_learning/forecasting/run.py +++ b/machine_learning/forecasting/run.py @@ -25,8 +25,9 @@ def linear_regression_prediction( First method: linear regression input : training data (date, total_user, total_event) in list of 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]) - 5.000000000000003 + >>> n = linear_regression_prediction([2,3,4,5], [5,3,4,6], [3,1,2,4], [2,1], [2,2]) + >>> 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 = np.array(x) From 12d40c423828acad3a2e26d36ae930d9fcf36900 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 17:23:30 +0530 Subject: [PATCH 09/11] Small change to test cache --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e34639959933..015670558432 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: "build" -on: [pull_request] +on: + pull_request jobs: build: From 2bcfbd876e26e7fa1b0d8af1a2f1f58c66019f6d Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 17:36:21 +0530 Subject: [PATCH 10/11] Apply suggestions from code review Co-authored-by: Christian Clauss --- web_programming/instagram_crawler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_programming/instagram_crawler.py b/web_programming/instagram_crawler.py index 7b4358269033..69755f425d27 100644 --- a/web_programming/instagram_crawler.py +++ b/web_programming/instagram_crawler.py @@ -23,7 +23,7 @@ class InstagramUser: """ Class Instagram crawl instagram user information - Usage: (doctest failing on GitHub actions) + Usage: (doctest failing on GitHub Actions) # >>> instagram_user = InstagramUser("github") # >>> instagram_user.is_verified True @@ -105,7 +105,7 @@ def test_instagram_user(username: str = "github") -> None: import os if os.environ.get("GITHUB_ACTIONS"): - return None # test failing on GitHub actions + return None # test failing on GitHub Actions instagram_user = InstagramUser(username) assert instagram_user.user_data assert isinstance(instagram_user.user_data, dict) From d2fe6c01d1a763d728b459679d80b48f16373921 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 19 Nov 2020 21:57:34 +0530 Subject: [PATCH 11/11] Update instagram_crawler.py --- web_programming/instagram_crawler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/instagram_crawler.py b/web_programming/instagram_crawler.py index 69755f425d27..4536257a984e 100644 --- a/web_programming/instagram_crawler.py +++ b/web_programming/instagram_crawler.py @@ -104,7 +104,7 @@ def test_instagram_user(username: str = "github") -> None: """ import os - if os.environ.get("GITHUB_ACTIONS"): + if os.environ.get("CI"): return None # test failing on GitHub Actions instagram_user = InstagramUser(username) assert instagram_user.user_data