Skip to content

Commit

Permalink
Add GitHub Actions for Python unit tests (#1677)
Browse files Browse the repository at this point in the history
* Add GitHub Actions for Python unit tests

* Add PythonPath

* Add health

* Add pwd

* Mock kube config

* Add Rest PATH
  • Loading branch information
andreyvelich authored Sep 28, 2021
1 parent 42e3cb2 commit 0a5e418
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 40 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test-python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Python Test

on:
- push
- pull_request

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install Packages
run: |
pip install grpcio-testing==1.40.0
pip install pytest==5.1.2
pip install -r cmd/suggestion/chocolate/v1beta1/requirements.txt
pip install -r cmd/suggestion/hyperopt/v1beta1/requirements.txt
pip install -r cmd/suggestion/skopt/v1beta1/requirements.txt
pip install -r cmd/suggestion/optuna/v1beta1/requirements.txt
pip install -r cmd/suggestion/nas/enas/v1beta1/requirements.txt
pip install -r cmd/suggestion/hyperband/v1beta1/requirements.txt
pip install -r cmd/suggestion/nas/darts/v1beta1/requirements.txt
pip install -r cmd/earlystopping/medianstop/v1beta1/requirements.txt
- name: Run Python test
run: |
export PYTHONPATH=$(pwd):$(pwd)/pkg/apis/manager/v1beta1/python:$(pwd)/pkg/apis/manager/health/python
echo $PYTHONPATH
pytest ./test/unit/v1beta1/suggestion
pytest ./test/unit/v1beta1/earlystopping
37 changes: 0 additions & 37 deletions test/e2e/v1beta1/scripts/python-tests.sh

This file was deleted.

2 changes: 0 additions & 2 deletions test/suggestion/v1beta1/test_requirements.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import grpc
import grpc_testing
import unittest
from unittest.mock import patch

from pkg.apis.manager.v1beta1.python import api_pb2

Expand All @@ -23,6 +24,11 @@

class TestMedianStop(unittest.TestCase):
def setUp(self):
# Mock load Kubernetes config.
patcher = patch('pkg.earlystopping.v1beta1.medianstop.service.config.load_kube_config')
self.mock_sum = patcher.start()
self.addCleanup(patcher.stop)

servicers = {
api_pb2.DESCRIPTOR.services_by_name['EarlyStopping']: MedianStopService(
)
Expand Down Expand Up @@ -60,7 +66,7 @@ def test_get_earlystopping_rules(self):
invocation_metadata={},
request=request, timeout=1)

response, metadata, code, details = get_earlystopping_rules.termination()
_, _, code, _ = get_earlystopping_rules.termination()

self.assertEqual(code, grpc.StatusCode.OK)

Expand Down
File renamed without changes.

0 comments on commit 0a5e418

Please sign in to comment.