Skip to content

Commit

Permalink
Updating to use Github Actions (#107)
Browse files Browse the repository at this point in the history
* Adding github actions

* Add bats tests

* Fixing python version tests

* Update test cases. Remove .travis.yml

* Updating Readme badge

* Update README.md

Link badge to actions page
  • Loading branch information
rcaloras authored Jan 23, 2022
1 parent 2e1111d commit ca69322
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 45 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Bashhub Client

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "2.7"]

env:
functional_test: true
CI_UNSUPPORTED: 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 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
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Bashhub saves every terminal command entered across all sessions and systems and provides powerful querying across all commands.

[![Build Status](https://api.travis-ci.org/rcaloras/bashhub-client.svg?branch=master)](https://travis-ci.org/rcaloras/bashhub-client)
[![Build Status](https://github.com/rcaloras/bashhub-client/actions/workflows/main.yml/badge.svg)](https://github.com/rcaloras/bashhub-client/actions/)
[![GitHub version](https://badge.fury.io/gh/rcaloras%2Fbashhub-client.svg)](https://badge.fury.io/gh/rcaloras%2Fbashhub-client)

### Features
Expand Down
24 changes: 6 additions & 18 deletions tests/shell/install-bashhub.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions tests/test_bashhub_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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
Expand All @@ -15,14 +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
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()
Expand Down

0 comments on commit ca69322

Please sign in to comment.