Skip to content

Commit 34dfe53

Browse files
brettleCoolSpy3omichel
authored
Run test suite on windows during CI (#6648)
* Add a test-suite job. * Upload artifact after build if test suite requested. * Setup msys2. * Update test_suite_windows.yml * Install deps. * Install VS10 and OpenJdk so test-suite can run. * Set WEBOTS_HOME. * Add WEBOTS_HOME to PATH before running tests. * Fix PATH. * Print sysinfo output when error occurs. * Print debug info when getting sysinfo. * Install software renderer for headless CI. * Launch tmate session for debugging. * Setup tmate session if the test suite fails. * Read MyBot.txt in text instead of binary mode to compensate for line ending differences. * Treat hdr files as binary so they aren't corrupted by git when checking out on Windows. * Use download artifact v4. * Override GL version to be 3.3 and force software rendering. * Skip a couple tests that don't work on windows CI. * Make test_suite.py accept world files under windows. --------- Co-authored-by: CoolSpy3 <[email protected]> Co-authored-by: Olivier Michel <[email protected]>
1 parent ebf8625 commit 34dfe53

File tree

5 files changed

+75
-8
lines changed

5 files changed

+75
-8
lines changed

.github/workflows/test_suite_windows.yml

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,75 @@ jobs:
8888
python -m pip install requests PyGithub
8989
scripts/packaging/publish_release.py --key=${{ secrets.GITHUB_TOKEN }} --repo=${{ github.repository }} --branch=${{ github.ref }} --commit=$(git log -1 --format='%H') --tag=${{ github.ref }}
9090
- uses: actions/upload-artifact@v4
91-
if: ${{ contains(github.event.pull_request.labels.*.name, 'test distribution') }}
91+
if: ${{ contains(github.event.pull_request.labels.*.name, 'test suite') || contains(github.event.pull_request.labels.*.name, 'test distribution') }}
9292
with:
9393
name: build-${{ matrix.os }}
9494
path: |
9595
distribution/*.exe
96+
test-suite:
97+
needs: build
98+
if: ${{ contains(github.event.pull_request.labels.*.name, 'test suite') }}
99+
strategy:
100+
matrix:
101+
os: [windows-2019]
102+
runs-on: ${{ matrix.os }}
103+
steps:
104+
- uses: actions/checkout@v3
105+
- name: Download Artifacts
106+
uses: actions/download-artifact@v4
107+
with:
108+
name: build-${{ matrix.os }}
109+
path: artifact
110+
- uses: msys2/setup-msys2@v2
111+
with:
112+
update: false
113+
- name: Install Visual Studio 10 and OpenJDK 18
114+
shell: powershell
115+
run: |
116+
choco install -y openjdk --version=18.0.2
117+
choco install -y visualcpp-build-tools
118+
- name: Install Webots Compilation Dependencies
119+
run: |
120+
export PYTHON_INSTALLATION_FOLDER=/C/hostedtoolcache/windows/Python
121+
export PYTHON_HOME=$PYTHON_INSTALLATION_FOLDER/3.11.`ls $PYTHON_INSTALLATION_FOLDER | grep '^3\.11\.[0-9]\+$' | cut -c6- | sort -n | tail -n1`/x64
122+
echo 'export JAVA_HOME=/C/Program\ Files/OpenJDK/`ls /C/Program\ Files/OpenJDK`' >> ~/.bash_profile
123+
echo 'export PYTHON_HOME='$PYTHON_HOME >> ~/.bash_profile
124+
echo 'export VISUAL_STUDIO_PATH="/C/Program Files (x86)/Microsoft Visual Studio/2017"' >> ~/.bash_profile
125+
echo 'export INNO_SETUP_HOME="/C/Program Files (x86)/Inno Setup 6"' >> ~/.bash_profile
126+
echo 'export PATH=$PYTHON_HOME:$PYTHON_HOME/Scripts:$GITHUB_WORKSPACE/msys64/mingw64/bin:$GITHUB_WORKSPACE/bin/node:/mingw64/bin:/usr/bin:$JAVA_HOME/bin:$PATH' >> ~/.bash_profile
127+
export WEBOTS_HOME=$GITHUB_WORKSPACE
128+
./scripts/install/msys64_installer.sh --all
129+
- name: Extract Webots
130+
run: |
131+
./artifact/webots-*.exe //SUPPRESSMSGBOXES //VERYSILENT //NOCANCEL //NORESTART //ALLUSERS
132+
- name: Set up Python 3.11
133+
uses: actions/setup-python@v4
134+
with:
135+
python-version: 3.11
136+
- name: Install Software Renderer
137+
uses: ssciwr/setup-mesa-dist-win@v2
138+
with:
139+
version: '24.2.1'
140+
build-type: 'release-mingw'
141+
- name: Test
142+
run: |
143+
export WEBOTS_DISABLE_SAVE_SCREEN_PERSPECTIVE_ON_CLOSE=true
144+
python scripts/packaging/update_urls.py $(git log -1 --format='%H')
145+
export TESTS_HOME=$PWD # required by cache group in the test suite
146+
export WEBOTS_HOME="/c/Program Files/Webots"
147+
export PATH="${WEBOTS_HOME}/msys64/mingw64/bin:$PATH"
148+
export WEBOTS_HOME_PATH=$PWD # required for tests to find Makefile.include
149+
export BRANCH_HASH=$(git log -1 --format='%H')
150+
export MESA_GL_VERSION_OVERRIDE=3.3
151+
export LIBGL_ALWAYS_SOFTWARE=true
152+
python tests/test_suite.py
153+
- name: Setup tmate session
154+
if: ${{ failure() }}
155+
uses: mxschmitt/action-tmate@v3
156+
with:
157+
detached: true
96158
delete-artifacts:
97-
needs: [build]
159+
needs: [build, test-suite]
98160
if: ${{ always() && !contains(github.event.pull_request.labels.*.name, 'test distribution') && !contains(github.event.pull_request.labels.*.name, 'test webots build') }}
99161
strategy:
100162
matrix:

projects/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.hdr binary

src/webots/gui/WbSingleTaskApplication.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ void WbSingleTaskApplication::showSysInfo() const {
231231
// An OpenGL context is required there for the OpenGL calls like `glGetString`.
232232
// The format is QSurfaceFormat::defaultFormat() => OpenGL 3.3 defined in main.cpp.
233233
QOpenGLContext *context = new QOpenGLContext();
234-
context->create();
234+
if (!context->create())
235+
assert(false);
235236
QOpenGLFunctions *gl = context->functions(); // QOpenGLFunctions_3_3_Core cannot be initialized here on some systems like
236237
// macOS High Sierra and some Ubuntu environments.
237-
238+
assert(gl);
238239
#ifdef _WIN32
239240
const quint32 vendorId = WbSysInfo::gpuVendorId(gl);
240241
const quint32 rendererId = WbSysInfo::gpuDeviceId(gl);

tests/api/controllers/supervisor_import_robot_node/supervisor_import_robot_node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
2525
wb_robot_step(2 * TIME_STEP);
2626

2727
// import robot object
28-
FILE *fd = fopen("MyBot.txt", "rb");
28+
FILE *fd = fopen("MyBot.txt", "r");
2929
char contents[4096];
3030
const int n = fread(contents, 1, sizeof(contents), fd);
3131
fclose(fd);

tests/test_suite.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def setupWebots():
116116
command = Command([webotsFullPath, '--sysinfo'])
117117
command.run()
118118
if command.returncode != 0:
119-
raise RuntimeError('Error when getting the Webots information of the system')
119+
raise RuntimeError('Error when getting the Webots information of the system: ' + command.output)
120120
webotsSysInfo = command.output.split('\n')
121121

122122
return webotsFullPath, webotsVersion, webotsSysInfo, webotsEmptyWorldPath
@@ -181,7 +181,7 @@ def generateWorldsList(groupName):
181181
# generate the list from the arguments
182182
if filesArguments:
183183
for file in filesArguments:
184-
if f'/tests/{groupName}/' in file:
184+
if (os.sep + 'tests' + os.sep + groupName + os.sep) in file:
185185
worldsList.append(file)
186186

187187
# generate the list from 'ls worlds/*.wbt'
@@ -201,13 +201,16 @@ def generateWorldsList(groupName):
201201
# speaker test not working on github action because of missing sound drivers
202202
# robot window and movie recording test not working on BETA Ubuntu 22.04 GitHub Action environment
203203
# billboard test not working in macos GitHub Action environment
204+
# billboard and robot window not working on windows GitHub Action environment.
204205
if (not filename.endswith('_temp.wbt') and
205206
not ('GITHUB_ACTIONS' in os.environ and (
206207
filename.endswith('speaker.wbt') or
207208
filename.endswith('local_proto_with_texture.wbt') or
208209
(filename.endswith('robot_window_html.wbt') and is_ubuntu_22_04) or
209210
(filename.endswith('supervisor_start_stop_movie.wbt') and is_ubuntu_22_04) or
210-
(filename.endswith('billboard.wbt') and sys.platform == 'darwin')
211+
(filename.endswith('billboard.wbt') and sys.platform == 'darwin') or
212+
(filename.endswith('billboard.wbt') and sys.platform == 'win32') or
213+
(filename.endswith('robot_window_html.wbt') and sys.platform == 'win32')
211214
))):
212215
worldsList.append(filename)
213216

0 commit comments

Comments
 (0)