Skip to content

Commit 862e868

Browse files
committed
add ci
1 parent 478eb09 commit 862e868

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install Poetry
23+
run: |
24+
curl -sSL https://install.python-poetry.org | python3 -
25+
echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
27+
- name: Install dependencies
28+
run: poetry install
29+
30+
- name: Run tests
31+
run: poetry run pytest

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ dependencies = [
1919
"scipy (>=1.15.2,<2.0.0)"
2020
]
2121

22+
[tool.pytest.ini_options]
23+
testpaths = ["tests"]
2224

2325
[build-system]
2426
requires = ["poetry-core>=2.0.0,<3.0.0"]

tests/test_model.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
from robot_nav.models.RCPG.RCPG import RCPG
24
from robot_nav.models.TD3.TD3 import TD3
35
from robot_nav.models.CNNTD3.CNNTD3 import CNNTD3
@@ -7,6 +9,7 @@
79
from robot_nav.sim import SIM_ENV
810
import pytest
911

12+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
1013

1114
@pytest.mark.parametrize(
1215
"model, state_dim",
@@ -39,7 +42,7 @@ def test_models(model, state_dim):
3942
training_iterations=0,
4043
batch_size=0,
4144
buffer_size=100,
42-
file_names=["test_data.yml"],
45+
file_names=[PROJECT_ROOT.joinpath("tests/test_data.yml")],
4346
)
4447

4548
test_model.train(
@@ -79,7 +82,7 @@ def test_max_bound_models(model, state_dim):
7982
training_iterations=0,
8083
batch_size=0,
8184
buffer_size=100,
82-
file_names=["test_data.yml"],
85+
file_names=[PROJECT_ROOT.joinpath("tests/test_data.yml")],
8386
)
8487

8588
test_model.train(

tests/test_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from pathlib import Path
2+
13
from robot_nav.models.SAC.SAC import SAC
24
from robot_nav.models.PPO.PPO import PPO, RolloutBuffer
35
from robot_nav.models.RCPG.RCPG import RCPG
46
from robot_nav.utils import get_buffer, RolloutReplayBuffer, ReplayBuffer
57
from robot_nav.sim import SIM_ENV
68

9+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
710

811
def test_buffer():
912
model = SAC(
@@ -39,7 +42,7 @@ def test_buffer():
3942
training_iterations=0,
4043
batch_size=0,
4144
buffer_size=100,
42-
file_names=["test_data.yml"],
45+
file_names=[PROJECT_ROOT.joinpath("tests/test_data.yml")],
4346
)
4447
assert prefilled_buffer.count == 100
4548

@@ -78,7 +81,7 @@ def test_rollout_buffer():
7881
training_iterations=0,
7982
batch_size=0,
8083
buffer_size=100,
81-
file_names=["test_data.yml"],
84+
file_names=[PROJECT_ROOT.joinpath("tests/test_data.yml")],
8285
)
8386
assert prefilled_buffer.count == 6
8487

0 commit comments

Comments
 (0)