Skip to content

Commit 82ae592

Browse files
authored
Issue #546 - Tests on MS Edge run successfully locally but fail in GitHub Actions (#550)
1 parent 91a89ec commit 82ae592

File tree

5 files changed

+57
-34
lines changed

5 files changed

+57
-34
lines changed

.github/workflows/docker-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ jobs:
217217
push:
218218
runs-on: ubuntu-latest
219219
needs: test
220-
if: github.event_name != 'pull_request'
220+
if: github.event_name != 'pull_request' && github.ref_type == 'tag'
221221
steps:
222222
- name: Checkout code
223223
uses: actions/checkout@v4
@@ -239,5 +239,5 @@ jobs:
239239
with:
240240
platforms: linux/amd64,linux/arm64
241241
push: ${{ github.event_name != 'pull_request' }}
242-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_type == 'branch' && 'latest' || github.ref_name }}
242+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
243243
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache

Dockerfile

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ LABEL description="Robot Framework in Docker"
77
# * linux/arm64
88
# * linux/amd64"
99

10+
ENV ROBOT_FRAMEWORK_BASE_FOLDER="/opt/robotframework"
11+
1012
# Set the Python dependencies' directory environment variable
11-
ENV ROBOT_DEPENDENCY_DIR="/opt/robotframework/dependencies"
13+
ENV ROBOT_DEPENDENCY_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/dependencies"
14+
15+
# Set the browser drivers' directory environment variable
16+
ENV ROBOT_DRIVER_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers"
1217

1318
# Set the reports directory environment variable
14-
ENV ROBOT_REPORTS_DIR="/opt/robotframework/reports"
19+
ENV ROBOT_REPORTS_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/reports"
1520

1621
# Set the tests directory environment variable
17-
ENV ROBOT_TESTS_DIR="/opt/robotframework/tests"
22+
ENV ROBOT_TESTS_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/tests"
1823

1924
# Set the working directory environment variable
20-
ENV ROBOT_WORK_DIR="/opt/robotframework/temp"
25+
ENV ROBOT_WORK_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/temp"
2126

2227
# Set the maximum number of rounds to rerun failed tests
2328
ENV ROBOT_RERUN_MAX_ROUNDS=0
@@ -116,8 +121,8 @@ RUN if [ `uname --machine` == "x86_64" ]; \
116121
fi \
117122
&& wget -q "https://github.com/mozilla/geckodriver/releases/download/${GECKO_DRIVER_VERSION}/geckodriver-${GECKO_DRIVER_VERSION}-${PLATFORM}.tar.gz" \
118123
&& tar xzf geckodriver-${GECKO_DRIVER_VERSION}-${PLATFORM}.tar.gz \
119-
&& mkdir -p /opt/robotframework/drivers/ \
120-
&& mv geckodriver /opt/robotframework/drivers/geckodriver \
124+
&& mkdir -p ${ROBOT_DRIVER_DIR}/ \
125+
&& mv geckodriver ${ROBOT_DRIVER_DIR}/geckodriver \
121126
&& rm geckodriver-${GECKO_DRIVER_VERSION}-${PLATFORM}.tar.gz
122127

123128
# Install Microsoft Edge & webdriver
@@ -137,8 +142,8 @@ RUN if [ `uname --machine` == "x86_64" ]; \
137142
zip \
138143
&& wget -q "https://msedgedriver.microsoft.com/${MICROSOFT_EDGE_VERSION}/edgedriver_${PLATFORM}.zip" \
139144
&& unzip edgedriver_${PLATFORM}.zip -d edge \
140-
&& mv edge/msedgedriver /opt/robotframework/drivers/msedgedriver \
141-
&& chmod ugo+x /opt/robotframework/drivers/msedgedriver \
145+
&& mv edge/msedgedriver ${ROBOT_DRIVER_DIR}/msedgedriver-original \
146+
&& chmod ugo+x ${ROBOT_DRIVER_DIR}/msedgedriver-original \
142147
&& rm -Rf edgedriver_${PLATFORM}.zip edge/ \
143148
# IMPORTANT: don't remove the wget package because it's a dependency of Microsoft Edge
144149
&& dnf remove -y \
@@ -152,30 +157,32 @@ ENV PATH=/opt/microsoft/msedge:$PATH
152157
RUN rfbrowser init chromium firefox
153158

154159
# Prepare binaries to be executed
155-
COPY bin/chromedriver.sh /opt/robotframework/drivers/chromedriver
156-
COPY bin/chrome.sh /opt/robotframework/bin/chrome
157-
COPY bin/run-tests-in-virtual-screen.sh /opt/robotframework/bin/
160+
COPY bin/chromedriver.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers/chromedriver
161+
COPY bin/chrome.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/bin/chrome
162+
COPY bin/msedgedriver.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers/msedgedriver
163+
COPY bin/run-tests-in-virtual-screen.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/bin/
158164

159165
# Create the default report and work folders with the default user to avoid runtime issues
160166
# These folders are writeable by anyone, to ensure the user can be changed on the command line.
161167
RUN mkdir -p ${ROBOT_REPORTS_DIR} \
162168
&& mkdir -p ${ROBOT_WORK_DIR} \
163-
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_REPORTS_DIR} \
164-
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_WORK_DIR} \
165-
&& chmod ugo+w ${ROBOT_REPORTS_DIR} ${ROBOT_WORK_DIR}
166-
167-
# Allow any user to write logs
168-
RUN chmod ugo+w /var/log \
169-
&& chown ${ROBOT_UID}:${ROBOT_GID} /var/log
170-
171-
# Update system path
172-
ENV PATH=/opt/robotframework/bin:/opt/robotframework/drivers:$PATH
173-
174-
# Ensure the directory for Python dependencies exists
175-
RUN mkdir -p ${ROBOT_DEPENDENCY_DIR} \
169+
&& chown -R ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_REPORTS_DIR} \
170+
&& chown -R ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_WORK_DIR} \
171+
&& chmod -R ugo+w ${ROBOT_REPORTS_DIR} ${ROBOT_WORK_DIR} \
172+
\
173+
# Allow any user to run the drivers and write logs
174+
&& chmod ugo+x ${ROBOT_DRIVER_DIR} \
175+
&& chmod ugo+w /var/log \
176+
&& chown ${ROBOT_UID}:${ROBOT_GID} /var/log \
177+
\
178+
# Ensure the directory for Python dependencies exists
179+
&& mkdir -p ${ROBOT_DEPENDENCY_DIR} \
176180
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_DEPENDENCY_DIR} \
177181
&& chmod 777 ${ROBOT_DEPENDENCY_DIR}
178182

183+
# Update system path
184+
ENV PATH=${ROBOT_FRAMEWORK_BASE_FOLDER}/bin:${ROBOT_DRIVER_DIR}:$PATH
185+
179186
# Set up a volume for the generated reports
180187
VOLUME ${ROBOT_REPORTS_DIR}
181188

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* [Error: Suite contains no tests](#error-suite-contains-no-tests)
2929
* [Database tests are failing in spite of the DatabaseLibrary being present](#database-tests-are-failing-in-spite-of-the-databaselibrary-being-present)
3030
* [Supported devices and architectures](#supported-devices-and-architectures)
31+
* [Container image is too large](#troubleshooting-image-too-large)
3132
* [Please contribute!](#please-contribute)
3233

3334
-----
@@ -200,6 +201,8 @@ rpa==1.50.0
200201
201202
**For large dependencies, it is still recommended to extend the project's image and to add them there, to avoid delaying the CI/CD pipelines with repeated dependency installations.**
202203
204+
<a name="rerunning-tests"></a>
205+
203206
### Rerunning tests
204207
205208
Failing tests can be rerun by setting the environment variable `ROBOT_RERUN_MAX_ROUNDS` to a value above 0. All reruns of failed tests are executed without parallelization.
@@ -467,7 +470,7 @@ It is anyway mandatory to extend the container image to install the specific dat
467470

468471
### Supported devices and architectures
469472

470-
As mentioned on the [Docker Hub](https://hub.docker.com/r/ppodgorsek/robot-framework), the project has been built and uploaded as a `linux/amd64` image only. This means ARM devices such as MacBook M1/M2 and Amazon EC2 Graviton won't be able to run the image with the default configuration.
473+
As mentioned on the [Docker Hub](https://hub.docker.com/r/ppodgorsek/robot-framework), the project has been built and uploaded for `linux/amd64` and `linux/arm64` architectures only.
471474

472475
As mentioned in the official documentation, [Podman](https://docs.podman.io/en/latest/markdown/podman-run.1.html#platform-os-arch) and [Docker](https://docs.docker.com/build/building/multi-platform/) provide a `--platform` option which selects a given application architecture, such as:
473476

@@ -479,12 +482,22 @@ docker run \
479482
ppodgorsek/robot-framework:<version>
480483
```
481484

482-
Please note that builds and automated tests of this project are only performed on `linux/amd64` and `linux/arm64` architectures so such emulation might not work, depending on your device and operating system.
483-
484485
**It is to be noted that Microsoft Edge is not available for Linux ARM. Please visit [the official Microsoft Edge website](https://www.microsoft.com/en-us/edge/business/download) and [the Arm developer website](https://learn.arm.com/install-guides/browsers/edge/) for more information.**
485486

486487
If this does not solve your platform-related issues, you might have to rebuild the image for your device/platform, specifying that `--platform` option during the build and run.
487488

489+
<a name="troubleshooting-image-too-large"></a>
490+
491+
### Container image is too large
492+
493+
Unfortunately, the image size is due to the presence of both Selenium and Playwright. (the latter requiring its own set of browsers)
494+
495+
Should you need to use Robot Framework in embedded devices, this is too much.
496+
497+
Instead, a basic multi-arch container (under 200MB) can be found in this public container registry: [Robot Framework for Embedded Multi-Arch Container](https://gitlab.com/gitlab-accelerates-embedded/comp/robot-for-embdd/container_registry).
498+
499+
It is built as part of the [Robot Framework for Embedded](https://gitlab.com/explore/catalog/gitlab-accelerates-embedded/comp/robot-for-embdd).
500+
488501
<a name="please-contribute"></a>
489502

490503
## Please contribute!

bin/msedgedriver.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exec /opt/robotframework/drivers/msedgedriver-original --disable-dev-shm-usage --verbose --log-path=/var/log/msedgedriver "$@"

test/selenium.robot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
Library SeleniumLibrary
33

44
*** Variables ***
5-
${BROWSER} %{BROWSER}
5+
${BROWSER} %{BROWSER}
66

77
*** Test Cases ***
88
Visit Bing
9-
Open Browser https://www.bing.com ${BROWSER}
10-
Capture Page Screenshot
9+
Open Browser https://www.bing.com ${BROWSER}
10+
Capture Page Screenshot
1111

1212
Visit Google
13-
Open Browser https://www.google.com ${BROWSER}
14-
Capture Page Screenshot
13+
Open Browser https://www.google.com ${BROWSER}
14+
Capture Page Screenshot

0 commit comments

Comments
 (0)