Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
push:
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -239,5 +239,5 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_type == 'branch' && 'latest' || github.ref_name }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache
55 changes: 31 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ LABEL description="Robot Framework in Docker"
# * linux/arm64
# * linux/amd64"

ENV ROBOT_FRAMEWORK_BASE_FOLDER="/opt/robotframework"

# Set the Python dependencies' directory environment variable
ENV ROBOT_DEPENDENCY_DIR="/opt/robotframework/dependencies"
ENV ROBOT_DEPENDENCY_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/dependencies"

# Set the browser drivers' directory environment variable
ENV ROBOT_DRIVER_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers"

# Set the reports directory environment variable
ENV ROBOT_REPORTS_DIR="/opt/robotframework/reports"
ENV ROBOT_REPORTS_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/reports"

# Set the tests directory environment variable
ENV ROBOT_TESTS_DIR="/opt/robotframework/tests"
ENV ROBOT_TESTS_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/tests"

# Set the working directory environment variable
ENV ROBOT_WORK_DIR="/opt/robotframework/temp"
ENV ROBOT_WORK_DIR="${ROBOT_FRAMEWORK_BASE_FOLDER}/temp"

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

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

# Prepare binaries to be executed
COPY bin/chromedriver.sh /opt/robotframework/drivers/chromedriver
COPY bin/chrome.sh /opt/robotframework/bin/chrome
COPY bin/run-tests-in-virtual-screen.sh /opt/robotframework/bin/
COPY bin/chromedriver.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers/chromedriver
COPY bin/chrome.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/bin/chrome
COPY bin/msedgedriver.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/drivers/msedgedriver
COPY bin/run-tests-in-virtual-screen.sh ${ROBOT_FRAMEWORK_BASE_FOLDER}/bin/

# Create the default report and work folders with the default user to avoid runtime issues
# These folders are writeable by anyone, to ensure the user can be changed on the command line.
RUN mkdir -p ${ROBOT_REPORTS_DIR} \
&& mkdir -p ${ROBOT_WORK_DIR} \
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_REPORTS_DIR} \
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_WORK_DIR} \
&& chmod ugo+w ${ROBOT_REPORTS_DIR} ${ROBOT_WORK_DIR}

# Allow any user to write logs
RUN chmod ugo+w /var/log \
&& chown ${ROBOT_UID}:${ROBOT_GID} /var/log

# Update system path
ENV PATH=/opt/robotframework/bin:/opt/robotframework/drivers:$PATH

# Ensure the directory for Python dependencies exists
RUN mkdir -p ${ROBOT_DEPENDENCY_DIR} \
&& chown -R ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_REPORTS_DIR} \
&& chown -R ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_WORK_DIR} \
&& chmod -R ugo+w ${ROBOT_REPORTS_DIR} ${ROBOT_WORK_DIR} \
\
# Allow any user to run the drivers and write logs
&& chmod ugo+x ${ROBOT_DRIVER_DIR} \
&& chmod ugo+w /var/log \
&& chown ${ROBOT_UID}:${ROBOT_GID} /var/log \
\
# Ensure the directory for Python dependencies exists
&& mkdir -p ${ROBOT_DEPENDENCY_DIR} \
&& chown ${ROBOT_UID}:${ROBOT_GID} ${ROBOT_DEPENDENCY_DIR} \
&& chmod 777 ${ROBOT_DEPENDENCY_DIR}

# Update system path
ENV PATH=${ROBOT_FRAMEWORK_BASE_FOLDER}/bin:${ROBOT_DRIVER_DIR}:$PATH

# Set up a volume for the generated reports
VOLUME ${ROBOT_REPORTS_DIR}

Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [Error: Suite contains no tests](#error-suite-contains-no-tests)
* [Database tests are failing in spite of the DatabaseLibrary being present](#database-tests-are-failing-in-spite-of-the-databaselibrary-being-present)
* [Supported devices and architectures](#supported-devices-and-architectures)
* [Container image is too large](#troubleshooting-image-too-large)
* [Please contribute!](#please-contribute)

-----
Expand Down Expand Up @@ -200,6 +201,8 @@ rpa==1.50.0

**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.**

<a name="rerunning-tests"></a>

### Rerunning tests

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.
Expand Down Expand Up @@ -467,7 +470,7 @@ It is anyway mandatory to extend the container image to install the specific dat

### Supported devices and architectures

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.
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.

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:

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

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.

**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.**

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.

<a name="troubleshooting-image-too-large"></a>

### Container image is too large

Unfortunately, the image size is due to the presence of both Selenium and Playwright. (the latter requiring its own set of browsers)

Should you need to use Robot Framework in embedded devices, this is too much.

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).

It is built as part of the [Robot Framework for Embedded](https://gitlab.com/explore/catalog/gitlab-accelerates-embedded/comp/robot-for-embdd).

<a name="please-contribute"></a>

## Please contribute!
Expand Down
3 changes: 3 additions & 0 deletions bin/msedgedriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec /opt/robotframework/drivers/msedgedriver-original --disable-dev-shm-usage --verbose --log-path=/var/log/msedgedriver "$@"
10 changes: 5 additions & 5 deletions test/selenium.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Library SeleniumLibrary

*** Variables ***
${BROWSER} %{BROWSER}
${BROWSER} %{BROWSER}

*** Test Cases ***
Visit Bing
Open Browser https://www.bing.com ${BROWSER}
Capture Page Screenshot
Open Browser https://www.bing.com ${BROWSER}
Capture Page Screenshot

Visit Google
Open Browser https://www.google.com ${BROWSER}
Capture Page Screenshot
Open Browser https://www.google.com ${BROWSER}
Capture Page Screenshot