-
Notifications
You must be signed in to change notification settings - Fork 1
180 lines (154 loc) · 5.48 KB
/
scenario_test.yaml
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
name: scenario test
on:
workflow_dispatch:
pull_request:
merge_group:
env:
PYTHON_VERSION: '3.10'
jobs:
create_scenario_test_image:
name: build image for scenario test
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
strategy:
fail-fast: false
matrix:
rosdistro: [humble]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
file: docker/scenario/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:scenario-${{ github.sha }}
cache-from: type=gha
setup_scenario_test_library:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup virtual environment
run: |
python -m venv env
source env/bin/activate
- name: Cache virtual environment
uses: actions/cache@v4
with:
path: env
key: ${{ runner.os }}-env-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-env-
- name: Install robocup_scenario_test library
run: |
source env/bin/activate
python -m pip install --upgrade pip
sudo apt update
sudo apt install -y protobuf-compiler
pip install -v git+https://github.com/SSL-Roots/robocup_scenario_test
pip install pytest
scenario_test:
needs: [create_scenario_test_image, setup_scenario_test_library]
strategy:
fail-fast: false
matrix:
env:
# - TEST: STOP_AVOID_BALL
- TEST: STOP_ROBOT_SPEED
- TEST: emit_from_penalty_01
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache virtual environment
uses: actions/cache@v4
with:
path: env
key: ${{ runner.os }}-env-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-env-
- name: Setup virtual environment
run: |
python -m venv env
source env/bin/activate
python -m pip list
- name: Start Docker Compose services
run: |
docker compose -f docker/scenario/docker-compose.yaml up -d
env:
CRANE_TAG: scenario-${{ github.sha }}
- name: Wait for crane to start
timeout-minutes: 5
run: |
sleep 5
- name: Download logger
run: |
curl -L https://github.com/RoboCup-SSL/ssl-go-tools/releases/download/v1.5.2/ssl-log-recorder_v1.5.2_linux_amd64 -o ssl-log-recorder
chmod +x ssl-log-recorder
- name: Run pytest
id: pytest
run: |
source env/bin/activate
pytest scenario_test/${{ matrix.env.TEST }}.py --vision_port=10020 --logging --log_recorder=./ssl-log-recorder
echo "LOG_EXISTS=$(ls *.log.gz 2> /dev/null)" >> $GITHUB_ENV
- name: Get and print logs
if: always()
run: docker compose -f docker/scenario/docker-compose.yaml logs
- name: Clean up Docker Compose services
if: always()
run: docker compose -f docker/scenario/docker-compose.yaml down
- name: setup ssl-log-video
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
run: |
export PATH=$PATH:/usr/local/go/bin && \
git clone https://github.com/ibis-ssl/ssl-go-tools.git -b video && \
cd ssl-go-tools/cmd/ssl-log-video && \
go mod tidy && \
go build -o ssl-log-video ssl-log-video.go && \
chmod +x ssl-log-video
- name: make log video
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
run: |
export PATH=$PATH:/usr/local/go/bin
sudo apt update
sudo apt install -y ffmpeg
find . -name "*.log.gz" -exec sh -c 'gunzip -c "$1" > "${1%.gz}" && ./ssl-go-tools/cmd/ssl-log-video/ssl-log-video -file "${1%.gz}" -output "${1%.gz}.avi" && ffmpeg -i "${1%.gz}.avi" -vcodec libx264 -acodec aac ${1%.gz}.mp4' _ {} \;
- name: Upload artifacts
id: upload-artifact
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'シナリオテスト動画出力') }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.env.TEST}}-failure-log-video
path: '*.mp4'
- name: Comment PR with Artifact URL
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Failure logs: ${{ steps.upload-artifact.outputs.artifact-url }}