Skip to content

Commit

Permalink
Run tests as continuous integration with GitHub Action (#110)
Browse files Browse the repository at this point in the history
* fix approaching first row when outside of field

* more robust approach to first row

* run tests on every push

* try updating pythonpath

* more analysis

* fix syntax error

* more robust comparision

* cleanup

* formatting
  • Loading branch information
rodja authored Jul 10, 2024
1 parent a7f4c57 commit 25ee98f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run Tests

on: [push]

jobs:
pytest:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.2.2"
- name: install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio
- name: run pytests
env:
PYTHONPATH: ${{ github.workspace }}
run: pytest
10 changes: 9 additions & 1 deletion field_friend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from . import automations, hardware, interface, localization, log_configuration, vision
from .system import System

__all__ = ['automations', 'hardware', 'interface', 'localization', 'vision', 'log_configuration', 'System']
__all__ = [
'automations',
'hardware',
'interface',
'localization',
'vision',
'log_configuration',
'System',
]
7 changes: 3 additions & 4 deletions tests/test_gnss.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import pytest
from copy import deepcopy


import pytest
import rosys
from conftest import ROBOT_GEO_START_POSITION
from rosys.testing import assert_point, forward
Expand All @@ -21,8 +20,8 @@ def test_shifted_calculation():
point = GeoPoint(lat=51.983159, long=7.434212)
shifted = point.shifted(rosys.geometry.Point(x=6, y=6))
# coordinates should be x pointing north, y pointing west (verified with https://www.meridianoutpost.com/resources/etools/calculators/calculator-latitude-longitude-distance.php?)
assert shifted.lat == 51.98321292429539
assert shifted.long == 7.43412466846196
assert shifted.lat == pytest.approx(51.983212924295)
assert shifted.long == pytest.approx(7.434124668461)
assert_point(shifted.cartesian(point), rosys.geometry.Point(x=6, y=6))


Expand Down
7 changes: 4 additions & 3 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ async def test_approaching_first_row(system: System, field: Field):
assert system.field_navigation.automation_watcher.field_watch_active


async def test_not_approaching_first_row_when_outside_field(system: System, field: Field):
async def test_approaching_first_row_when_outside_of_field(system: System, field: Field):
async def drive_away():
await system.driver.drive_to(rosys.geometry.Point(x=-5, y=0))
system.automator.start(drive_away())
await forward(22)
await forward(50)
assert not system.automator.is_running

system.field_navigation.field = field
Expand All @@ -78,8 +78,9 @@ async def test_resuming_field_navigation_after_automation_stop(system: System, f
system.automator.start()
assert field.reference
await forward(1) # update gnss reference to use the fields reference
point = rosys.geometry.Point(x=1.50, y=-6.1)
point = rosys.geometry.Point(x=1.54, y=-6.1)
await forward(x=point.x, y=point.y, tolerance=0.01) # drive until we are on first row
await forward(2)
assert system.field_navigation.state == system.field_navigation.State.FOLLOWING_ROW
system.automator.stop(because='test')
await forward(2)
Expand Down

0 comments on commit 25ee98f

Please sign in to comment.