-
Notifications
You must be signed in to change notification settings - Fork 41
195 lines (182 loc) · 7.32 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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 * * *'
# Allow tests to be run manually
workflow_dispatch:
# 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: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
# These steps run if not using a fork
- name: Login to Docker Hub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
if: ${{ !github.event.pull_request.head.repo.fork }}
- name: Build Docker image (with cache)
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
if: ${{ !github.event.pull_request.head.repo.fork }}
- name: Run tests (from pushed image)
run: |
docker run \
-w /opt/pyrobosim \
--volume ./test/results:/opt/pyrobosim/test/results:rw \
${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:base \
/bin/bash -c 'PYTHONPATH=/opt/pyrobosim/dependencies/pddlstream:${PYTHONPATH} ./test/run_tests.bash'
if: ${{ !github.event.pull_request.head.repo.fork }}
- 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 }}
# These steps run from a fork
- name: Build Docker image (no push)
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
target: pyrobosim
context: .
tags: pyrobosim:base
push: false
cache-from: |
type=registry,ref=iridiumxi/pyrobosim:buildcache-base
outputs: type=docker,dest=./pyrobosim_base.tar
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Run tests (from loaded image)
run: |
docker load --input ./pyrobosim_base.tar
docker run \
-w /opt/pyrobosim \
--volume ./test/results:/opt/pyrobosim/test/results:rw \
pyrobosim:base \
/bin/bash -c 'PYTHONPATH=./dependencies/pddlstream:${PYTHONPATH} ./test/run_tests.bash'
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, jazzy, rolling]
name: ros-${{ matrix.ros_distro }}-test
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
# These steps run if not using a fork
- name: Login to Docker Hub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
if: ${{ !github.event.pull_request.head.repo.fork }}
- name: Build Docker image (with cache)
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
if: ${{ !github.event.pull_request.head.repo.fork }}
- name: Run tests (from pushed image)
run: |
docker run \
--volume ./test/:/pyrobosim_ws/src/test/:rw \
--volume ./pytest.ini:/pyrobosim_ws/pytest.ini:rw \
${{ secrets.DOCKERHUB_USERNAME }}/pyrobosim:${{ matrix.ros_distro }} \
/bin/bash -c './src/test/run_tests.bash ${{ matrix.ros_distro }}'
if: ${{ !github.event.pull_request.head.repo.fork }}
# These steps run from a fork
- name: Build Docker image (no push)
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
target: pyrobosim_ros
context: .
build-args: |
ROS_DISTRO=${{ matrix.ros_distro }}
tags: pyrobosim:${{ matrix.ros_distro }}
push: false
cache-from: |
type=registry,ref=iridiumxi/pyrobosim:buildcache-${{ matrix.ros_distro }}
outputs: type=docker,dest=./pyrobosim_${{ matrix.ros_distro }}.tar
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Run tests (from loaded image)
run: |
docker load --input ./pyrobosim_${{ matrix.ros_distro }}.tar
docker run \
--volume ./test/:/pyrobosim_ws/test/:rw \
--volume ./pytest.ini:/pyrobosim_ws/pytest.ini:rw \
pyrobosim:${{ matrix.ros_distro }} \
/bin/bash -c './src/test/run_tests.bash ${{ matrix.ros_distro }}'
if: ${{ github.event.pull_request.head.repo.fork }}
- 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() }}