-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (135 loc) · 5.06 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
name: Scenario Test
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/workflows/build_docker_image.yaml'
workflow_dispatch:
permissions:
pull-requests: write # For uploading PR comments
# For uploading docker image
contents: read
packages: write
env:
PYTHON_VERSION: '3.10'
CONSAI_TAG: humble-light-sha-${{ github.sha }}
jobs:
create_docker_image:
uses: ./.github/workflows/build_docker_image_for_ci.yaml
setup_python_lib:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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_docker_image, setup_python_lib]
strategy:
fail-fast: false
matrix:
env:
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_ball_placement.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_force_start.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_free_kick.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_halt.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_kickoff.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_obstacle_avoidance.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_penalty.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_stop.py"}
- {CONSAI_YELLOW: "false", CONSAI_INVERT: "false", TEST_NAME: "test_scenario_timeout.py"}
- {CONSAI_YELLOW: "true", CONSAI_INVERT: "true", TEST_NAME: "yellow_invert/test_scenario_yellow_invert_kickoff.py"}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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/consai-grsim-compose.yml up -d
env:
CONSAI_TAG: ${{ env.CONSAI_TAG }}
CONSAI_YELLOW: ${{ matrix.env.CONSAI_YELLOW }}
CONSAI_INVERT: ${{ matrix.env.CONSAI_INVERT }}
- name: Wait for game.py to start
timeout-minutes: 5
run: |
CHECK_INTERVAL=5
until docker top consai 2>/dev/null | grep -q game.py
do
echo "Waiting for game.py to start..."
sleep $CHECK_INTERVAL
done
echo "game.py started!"
- name: Download logger
run: |
cd tests
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
run: |
source env/bin/activate
cd tests
pytest ${{ matrix.env.TEST_NAME }} --vision_port=10020 --logging --log_recorder=./ssl-log-recorder
- name: Check for log files
if: ${{ failure() }}
run: |
if ls tests/*.log.gz 1> /dev/null 2>&1; then
echo "LOG_EXISTS=true" >> $GITHUB_ENV
else
echo "LOG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Get and print logs
if: ${{ failure() || success() }}
run: docker compose -f .docker/consai-grsim-compose.yml logs --tail 100
- name: Clean up Docker Compose services
if: ${{ failure() || success() }}
run: docker compose -f .docker/consai-grsim-compose.yml down
- name: Upload artifacts
id: upload-artifact
if: ${{ failure() && env.LOG_EXISTS == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.env.TEST_NAME}}-failure-logs
path: 'tests/*.log.gz'
- name: Comment PR with Artifact URL
if: ${{ failure() && env.LOG_EXISTS == 'true' }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
${{ matrix.env.TEST_NAME }} failed. Failure logs: ${{ steps.upload-artifact.outputs.artifact-url }}