Skip to content

Improve setup script experience #981

Improve setup script experience

Improve setup script experience #981

Workflow file for this run

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:
# Build and test the base, non-ROS image
python-test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Login to Docker Hub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Build Docker image
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
target: pyrobosim
context: .
tags: ${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:base
push: true
cache-from: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-base
cache-to: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-base,mode=max
- name: Run tests
run: |
docker run \
-w /opt/pyrobosim \
--volume ./test/results:/opt/pyrobosim/test/results:rw \
${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:base \
/bin/bash -c 'PYTHONPATH=./dependencies/pddlstream:$PYTHONPATH ./test/run_tests.bash'
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./test/results/pytest-coverage.txt
junitxml-path: ./test/results/test_results.xml
pytest-xml-coverage-path: ./test/results/test_results_coverage.xml
coverage-path-prefix: pyrobosim/pyrobosim/
# This will break on PRs from forks
if: ${{ !github.event.pull_request.head.repo.fork }}
- name: Create coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.COVERAGE_GIST_SECRET }}
# This comes from https://gist.github.com/sea-bass/3761a8aa05af7b0e8c84210b9d103df8#file-pyrobosim-test-coverage-json
gistID: 3761a8aa05af7b0e8c84210b9d103df8
filename: pyrobosim-test-coverage.json
label: coverage
message: ${{ steps.coverageComment.outputs.coverage }}
color: ${{ steps.coverageComment.outputs.color }}
namedLogo: python
# Only update this badge on main
if: github.ref == 'refs/heads/main'
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: test/results/
# Always publish test results even when there are failures.
if: ${{ always() }}
# Build and test with ROS 2
ros2-test:
strategy:
matrix:
ros_distro: [humble, iron, jazzy, rolling]
name: ros-${{ matrix.ros_distro }}-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Login to Docker Hub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Build Docker image
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
target: pyrobosim_ros
context: .
build-args: |
ROS_DISTRO=${{ matrix.ros_distro }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:${{ matrix.ros_distro }}
push: true
cache-from: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-${{ matrix.ros_distro }}
cache-to: |
type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:buildcache-${{ matrix.ros_distro }},mode=max
- name: Run tests
run: |
docker run \
--volume ./test/:/pyrobosim_ws/test/:rw \
--volume ./pytest.ini:/pyrobosim_ws/pytest.ini:rw \
${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:${{ matrix.ros_distro }} \
/bin/bash -c './test/run_tests.bash'
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.ros_distro }}
path: test/results/
# Always publish test results even when there are failures.
if: ${{ always() }}