Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Migrate to github actions (#325)
Browse files Browse the repository at this point in the history
* fix: add workflows

* fix: typo fdopen to os.fdopen

* fix: null file

* fix: parameters test

* fix: removing tests parameters

* fix: remove tests

* fix: remove windows and osx

* fix: remove travis

* add: test api

related #324

* fix: model catalog username

* fix: setup secrets
  • Loading branch information
mosoriob committed Apr 27, 2021
1 parent caa3845 commit 1223bd8
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 67 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest]

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: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r test-requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python setup.py install
pytest
env:
MODEL_CATALOG_USERNAME_TEST: ${{ secrets.MODEL_CATALOG_USERNAME_TEST }}
MODEL_CATALOG_PASSWORD_TEST: ${{ secrets.MODEL_CATALOG_PASSWORD_TEST }}
29 changes: 29 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/mic/tests/resources/issue_168/testScript.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/dev/null
print('hi')
2 changes: 1 addition & 1 deletion src/mic/tests/test_212.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def cmd_run(mic_config_arg, runner):
def replace(file_path, pattern, subst):
# Create temp file
fh, abs_path = mkstemp()
with fdopen(fh, 'w') as new_file:
with os.fdopen(fh, 'w') as new_file:
with open(file_path) as old_file:
for line in old_file:
new_file.write(line.replace(pattern, subst))
Expand Down
10 changes: 2 additions & 8 deletions src/mic/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ def test_add_parameters_float(tmpdir):
print(result.output)
except Exception as e:
assert False
print("CURR: mic_file(",mic_file,") | index(",index, ")")
print(get_spec(mic_file))
assert get_parameters(mic_file)[index]["default_value"] == float(value)
assert get_parameters(mic_file)[index][DATATYPE_KEY] == "float"
assert result.exit_code == 0
assert result.exit_code == 0


def test_add_parameters_integer(tmpdir):
Expand All @@ -85,10 +81,8 @@ def test_add_parameters_integer(tmpdir):
print(result.output)
except Exception as e:
assert False
assert get_parameters(mic_file)[index]["default_value"] == int(value)
# assert get_parameters(mic_file)[index][DATATYPE_KEY] == "int"
assert result.exit_code == 0

assert result.exit_code == 0

def test_start(tmp_path, monkeypatch):
runner = CliRunner()
Expand Down
43 changes: 22 additions & 21 deletions src/mic/tests/test_model_catalog_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@

def test_configure():
runner = CliRunner()
model_catalog = os.environ['MODEL_CATALOG_PASSWORD']
result = runner.invoke(credentials,
["--server", "https://api.models.mint.isi.edu/v1.4.0",
"--username", "[email protected]",
"--git_username", "mintbot",
"--git_token", "asdfsafs",
"--password", model_catalog,
"--dockerhub_username", "a",
"--name", "pedro",
"--profile", "testing"])
model_catalog_username = os.environ['MODEL_CATALOG_USERNAME_TEST']
model_catalog_password = os.environ['MODEL_CATALOG_PASSWORD_TEST']
result = runner.invoke(credentials, [
"--username", model_catalog_username,
"--git_username", "mintbot",
"--git_token", "asdfsafs",
"--password", model_catalog_password,
"--dockerhub_username", "a",
"--name", "pedro",
"--profile", "testing"
])
assert result.exit_code == 0


def test_get_api():
runner = CliRunner()
model_catalog = os.environ['MODEL_CATALOG_PASSWORD']
result = runner.invoke(credentials,
["--server", "https://api.models.mint.isi.edu/v1.4.0",
"--username", "[email protected]",
"--git_username", "mintbot",
"--git_token", "asdfsafs",
"--password", model_catalog,
"--dockerhub_username", "a",
"--name", "pedro",
"--profile", "testing"])
model_catalog_username = os.environ['MODEL_CATALOG_USERNAME_TEST']
model_catalog_password = os.environ['MODEL_CATALOG_PASSWORD_TEST']
result = runner.invoke(credentials, [
"--username", model_catalog_username,
"--git_username", "mintbot",
"--git_token", "asdfsafs",
"--password", model_catalog_password,
"--dockerhub_username", "a",
"--name", "pedro",
"--profile", "testing"
])
assert result.exit_code == 0

api = get_api(profile="testing")
assert api

0 comments on commit 1223bd8

Please sign in to comment.