Skip to content

Commit

Permalink
Add basic testing and CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Apr 4, 2024
1 parent 538f4e0 commit 9bceaed
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: tests

on:
# Run action on certain pull request events
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

# Nightly job on default (main) branch
schedule:
- cron: '0 0 * * *'

# Ensures that only one workflow runs at a time for this branch
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -e .
pip3 install -r test/test_requirements.txt
- name: Run unit tests
run: test/run_tests.bash
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: test/results/
# Always publish test results even when there are failures.
if: ${{ always() }}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# PyRoboPlan
WORK IN PROGRESS: Educational Python library for manipulator motion planning.

[![PyRoboPlan Tests](https://github.com/sea-bass/pyroboplan/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/sea-bass/pyroboplan/actions/workflows/tests.yml)
[![Documentation Status](https://readthedocs.org/projects/pyroboplan/badge/?version=latest)](https://pyrobosim.readthedocs.io/en/latest/?badge=latest)

Educational Python library for manipulator motion planning.

This library extensively uses the [Pinocchio](https://github.com/stack-of-tasks/pinocchio) Python bindings for modeling robot kinematics and dynamics.

For more information, refer to the [full documentation](https://pyroboplan.readthedocs.io/en/latest/).

By Sebastian Castro, 2024

## Setup

(Optional) Set up a virtual enviroment and install dependencies.
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pyroboplan/planning/rrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def plan(self, q_start, q_goal, options=RRTPlannerOptions()):
# Add the node only if it is collision free.
if check_collisions_at_state(self.model, self.collision_model, q_sample):
continue

path_to_node = discretize_joint_space_path(
nearest_node.q, q_sample, self.options.max_angle_step
)
Expand Down
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/
Empty file removed test/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions test/core/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import numpy as np
import pytest

from pyroboplan.core.utils import configuration_distance


def test_configuration_distance():
q_start = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
q_end = np.array([0.3, 0.0, -0.4, 0.0, 0.0])
assert configuration_distance(q_start, q_end) == pytest.approx(0.5)
15 changes: 15 additions & 0 deletions test/run_tests.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Runs all unit tests

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TEST_RESULTS_DIR="${SCRIPT_DIR}/results"

echo "Running unit tests..."
python3 -m pytest "$SCRIPT_DIR" \
--cov="$SCRIPT_DIR" --cov-branch --cov-report term \
--cov-report html:"$TEST_RESULTS_DIR/test_results_coverage_html" \
--cov-report xml:"$TEST_RESULTS_DIR/test_results_coverage.xml" \
--junitxml="$TEST_RESULTS_DIR/test_results.xml" \
--html="$TEST_RESULTS_DIR/test_results.html" \
--self-contained-html
4 changes: 4 additions & 0 deletions test/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest
pytest-cov
pytest-dependency
pytest-html

0 comments on commit 9bceaed

Please sign in to comment.