Skip to content

Commit

Permalink
Add workflows for testing and lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
josiah-tesfu committed Sep 15, 2023
1 parent 01a6b1e commit 6d318ac
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 21 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/python-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Python Integration Test

on:
push:
branches:
- dev
- staging
- main
paths-ignore:
- version
pull_request:
branches:
- dev
- staging
- main
paths-ignore:
- version

jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]

steps:
- name: Checkout
if: ${{ github.event_name == 'pull_request'}}
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Checkout
if: ${{ github.event_name == 'push'}}
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m venv venv_test
source venv_test/bin/activate
python -m pip install -r requirements_test.txt
- name: Test with pytest
run: |
source venv_test/bin/activate
pytest ./tests/integration -vvs
47 changes: 47 additions & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will lint all files in repo using pylint

name: pylint

on:
push:
branches:
- dev
- staging
- main
paths-ignore:
- version
pull_request:
branches:
- dev
- staging
- main
paths-ignore:
- version

jobs:
lint:
name: Linter
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
git config --global url."https://${{ secrets.BOT_OSENSA_TOKEN }}@github".insteadOf ssh://git@github
python -m pip install --upgrade pip
python -m venv venv_test
source venv_test/bin/activate
python -m pip install -r requirements_test.txt
- name: Analysing the code with pylint
run: |
source venv_test/bin/activate
pylint $(git ls-files '*.py')
45 changes: 45 additions & 0 deletions .github/workflows/python-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: PyTest Unit Test

on:
push:
branches:
- dev
- staging
- main
paths-ignore:
- version
pull_request:
branches:
- dev
- staging
- main
paths-ignore:
- version

jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
git config --global url."https://${{ secrets.BOT_OSENSA_TOKEN }}@github".insteadOf ssh://git@github
python -m pip install --upgrade pip
python -m venv venv_test
source venv_test/bin/activate
python -m pip install -r requirements_test.txt
- name: Test with pytest
run: |
source venv_test/bin/activate
pytest ./tests/unit -vvs
1 change: 0 additions & 1 deletion client_rpc_channel/client_rpc_channel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Client to use for integration tests"""
import logging
from google.protobuf import service
import zmq
Expand Down
6 changes: 3 additions & 3 deletions client_services/adc/client_adc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"""
import logging
from edgepirpc.protos import adc_pb2 as adc_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.util.helpers import (
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from util.helpers import (
filter_arg_values, create_config_request_from_args, get_server_response
)
from client.client_services.adc.adc_pb_enums import (
from client_services.adc.adc_pb_enums import (
AnalogIn, ConvMode, ADC1DataRate, ADC2DataRate, FilterMode, ADCNum, DiffMode
)

Expand Down
6 changes: 3 additions & 3 deletions client_services/dac/client_dac_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
serialize/deserialize messages
"""
from edgepirpc.protos import dac_pb2 as dac_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.client_services.dac.dac_pb_enums import DACChannel
from client.util.helpers import get_server_response
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client_services.dac.dac_pb_enums import DACChannel
from util.helpers import get_server_response

# pylint: disable=no-member
class ClientDacService():
Expand Down
6 changes: 3 additions & 3 deletions client_services/din/client_din_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
serialize/deserialize messages
"""
from edgepirpc.protos import din_pb2 as din_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.client_services.din.din_pb_enums import DinPins
from client.util.helpers import get_server_response
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client_services.din.din_pb_enums import DinPins
from util.helpers import get_server_response

# pylint: disable=no-member
# pylint: disable=too-few-public-methods
Expand Down
6 changes: 3 additions & 3 deletions client_services/dout/client_dout_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
serialize/deserialize messages
"""
from edgepirpc.protos import dout_pb2 as dout_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.client_services.dout.dout_pb_enums import DoutPins, DoutTriState
from client.util.helpers import get_server_response
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client_services.dout.dout_pb_enums import DoutPins, DoutTriState
from util.helpers import get_server_response

# pylint: disable=no-member, too-few-public-methods
class ClientDoutService():
Expand Down
6 changes: 3 additions & 3 deletions client_services/led/client_led_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
serialize/deserialize messages
"""
from edgepirpc.protos import led_pb2 as led_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.client_services.led.led_pb_enums import LEDPins
from client.util.helpers import get_server_response
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client_services.led.led_pb_enums import LEDPins
from util.helpers import get_server_response

# pylint: disable=no-member
class ClientLEDService():
Expand Down
4 changes: 2 additions & 2 deletions client_services/relay/client_relay_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Client for Relay Service
"""
from edgepirpc.protos import relay_pb2 as relay_pb
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.util.helpers import get_server_response
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from util.helpers import get_server_response


# pylint: disable=no-member
Expand Down
6 changes: 3 additions & 3 deletions client_services/tc/client_tc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"""
import logging
from edgepirpc.protos import tc_pb2 as tc_pb
from client.util.helpers import (
from util.helpers import (
create_config_request_from_args, filter_arg_values, get_server_response
)
from client.client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client.client_services.tc.tc_pb_enums import (
from client_rpc_channel.client_rpc_channel import ClientRpcChannel
from client_services.tc.tc_pb_enums import (
AvgMode,
CJHighMask,
CJLowMask,
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
protobuf==3.20.3
python-periphery==2.4.1
pyzmq==25.1.0
edgepi-python-sdk==1.2.6
edgepi-rpc-protobuf==1.0.15
3 changes: 3 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
pylint==2.17.4
pytest==7.3.1
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ packages = find:
install_requires =
protobuf==3.20.3
edgepi-rpc-protobuf==1.0.15
python-periphery==2.4.1
pyzmq==25.1.0
edgepi-python-sdk==1.2.6

0 comments on commit 6d318ac

Please sign in to comment.