From e3a9087a038f0e2302d7351c98a937a929271a28 Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@alumni.cmu.edu> Date: Sat, 22 Jan 2022 21:46:32 -0500 Subject: [PATCH 1/6] Adding github actions --- .github/workflows/actions.yml | 28 ++++++++++++++++++++++++++++ tests/test_bashhub_setup.py | 6 ++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/actions.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..cdcba86 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,28 @@ +name: Bashhub Client + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "2.7"] + + env: + functional_test: true + CI_INCOMPATIBLE: true + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install . + pip install pytest + - name: Test with pytest + run: | + pytest diff --git a/tests/test_bashhub_setup.py b/tests/test_bashhub_setup.py index d58e826..d5fda37 100644 --- a/tests/test_bashhub_setup.py +++ b/tests/test_bashhub_setup.py @@ -4,6 +4,7 @@ import socket from bashhub.bashhub_setup import handle_system_information from bashhub import bashhub_setup import unittest +import os try: from unittest.mock import patch, MagicMock @@ -20,8 +21,9 @@ class BashhubSetupTest(unittest.TestCase): def test_get_mac_addresss(self): # Assuming uuid works - test_mac = bashhub_setup.get_mac_address() - assert str(uuid.getnode()) == test_mac + if not os.getenv('CI_INCOMPATIBLE', False): + test_mac = bashhub_setup.get_mac_address() + assert str(uuid.getnode()) == test_mac # with uuid returning random uuid.getnode = randomnode -- GitLab From ba00f2eb334de16e81af768eac59c0e37e27e2ea Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@alumni.cmu.edu> Date: Sun, 23 Jan 2022 00:52:45 -0500 Subject: [PATCH 2/6] Add bats tests --- .github/workflows/actions.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index cdcba86..e953707 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -19,10 +19,17 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install python dependencies and bats run: | pip install . pip install pytest + sudo apt-get update + sudo apt-get install -y bats + - name: Test with pytest run: | pytest + + - name: Test with bats + run: | + bats tests/shell -- GitLab From d976b01fbc735591af16d729b97b0da98b599d8e Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@alumni.cmu.edu> Date: Sun, 23 Jan 2022 01:23:08 -0500 Subject: [PATCH 3/6] Fixing python version tests --- tests/shell/install-bashhub.bats | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/shell/install-bashhub.bats b/tests/shell/install-bashhub.bats index 2815046..d8ca789 100644 --- a/tests/shell/install-bashhub.bats +++ b/tests/shell/install-bashhub.bats @@ -29,33 +29,21 @@ setup() { [[ $status == 0 ]] } -@test "get_and_check_python_version should find python3 first" { +@test "get_and_check_python_version should find python3.9 first" { # Mock up some fake responses here. - python3.10() { return 1; } - python3.9() { return 1; } - python3.8() { return 1; } - python3.7() { return 1; } - python3.6() { return 1; } - python3.5() { return 1; } - python3() { return 0; } - python() { return 1; } - - run 'get_and_check_python_version' - [[ $status == 0 ]] - [[ "$output" == "python3" ]] + /usr/bin/python3() { return 1; } + python3() { return 1; } + python3.9() { return 0; } - # Should find 3.5 - python3.5() { return 0; } run 'get_and_check_python_version' [[ $status == 0 ]] - [[ "$output" == "python3.5" ]] + [[ "$output" == "python3.9" ]] } @test "get_and_check_python_version should find different python versions" { # Mock up some fake responses here. - + /usr/bin/python3() { return 1; } python3() { return 1; } - python3.10() { return 1; } python3.9() { return 1; } python3.8() { return 1; } python3.7() { return 1; } -- GitLab From b17915f2230f3e9391f53b28fcd66f1b620eca33 Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@alumni.cmu.edu> Date: Sun, 23 Jan 2022 12:45:25 -0500 Subject: [PATCH 4/6] Update test cases. Remove .travis.yml --- .github/workflows/actions.yml | 2 +- .travis.yml | 26 -------------------------- tests/test_bashhub_setup.py | 9 ++++++--- 3 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index e953707..ba43e20 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -11,7 +11,7 @@ jobs: env: functional_test: true - CI_INCOMPATIBLE: true + CI_UNSUPPORTED: true steps: - uses: actions/checkout@v2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 49d9268..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: python -python: - - "3.8" - - "2.7" -before_install: - # To install bats and test our shell/bash functions - - sudo add-apt-repository ppa:duggan/bats --yes - - sudo apt-get update -qq - - sudo apt-get install -qq bats - - sudo apt-get install -qq zsh - -# For bats functional tests -env: - - functional_test="true" - -# command to install dependencies -install: "pip install ." - -# command to run tests -script: - - bats tests/shell - - py.test - -notifications: - email: - on_success: never diff --git a/tests/test_bashhub_setup.py b/tests/test_bashhub_setup.py index d5fda37..a2b1a6f 100644 --- a/tests/test_bashhub_setup.py +++ b/tests/test_bashhub_setup.py @@ -5,6 +5,7 @@ from bashhub.bashhub_setup import handle_system_information from bashhub import bashhub_setup import unittest import os +import pytest try: from unittest.mock import patch, MagicMock @@ -16,15 +17,17 @@ def randomnode(): def getnode(): return 1 +CI_UNSUPPORTED = os.getenv('CI_UNSUPPORTED', 'false').lower() == 'true' class BashhubSetupTest(unittest.TestCase): + @pytest.mark.skipif(CI_UNSUPPORTED, reason='uuid for mac address not supported on github actions') def test_get_mac_addresss(self): # Assuming uuid works - if not os.getenv('CI_INCOMPATIBLE', False): - test_mac = bashhub_setup.get_mac_address() - assert str(uuid.getnode()) == test_mac + test_mac = bashhub_setup.get_mac_address() + assert str(uuid.getnode()) == test_mac + def test_get_mac_addresss_where_uuid_is_random(self): # with uuid returning random uuid.getnode = randomnode hostname_mac = bashhub_setup.get_mac_address() -- GitLab From b3c86706532b2314e77f8c95eea327f3613258c1 Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@alumni.cmu.edu> Date: Sun, 23 Jan 2022 13:04:57 -0500 Subject: [PATCH 5/6] Updating Readme badge --- .github/workflows/{actions.yml => main.yml} | 0 README.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{actions.yml => main.yml} (100%) diff --git a/.github/workflows/actions.yml b/.github/workflows/main.yml similarity index 100% rename from .github/workflows/actions.yml rename to .github/workflows/main.yml diff --git a/README.md b/README.md index fa3faa4..9f7d3a9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Bashhub saves every terminal command entered across all sessions and systems and provides powerful querying across all commands. -[](https://travis-ci.org/rcaloras/bashhub-client) + [](https://badge.fury.io/gh/rcaloras%2Fbashhub-client) ### Features -- GitLab From 8137f35e1fb2467b8cf4980814258471f009a26d Mon Sep 17 00:00:00 2001 From: Ryan Caloras <rcaloras@gmail.com> Date: Sun, 23 Jan 2022 13:10:41 -0500 Subject: [PATCH 6/6] Update README.md Link badge to actions page --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f7d3a9..e6dd39c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Bashhub saves every terminal command entered across all sessions and systems and provides powerful querying across all commands. - +[](https://github.com/rcaloras/bashhub-client/actions/) [](https://badge.fury.io/gh/rcaloras%2Fbashhub-client) ### Features -- GitLab