Repository: MarketSquare/robotframework-webservice (language: python)

Issue:
Integate variablefiles in docker image
Variable files can be added when launching robot webservice. 

The feature is missing, yet, from the docker image


Discussion / hints:

Fix patch:
diff --git a/Dockerfile b/Dockerfile
index 0a18201..5714033 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,7 @@
 FROM python:3.11
 
 ENV SUITE_FOLDER .
+ENV VARIABLE_FILES ""
 ENV PORT 5003
 
 WORKDIR robot
@@ -10,4 +11,6 @@ RUN pip install robotframework-webservice
 
 EXPOSE ${PORT}
 
-ENTRYPOINT exec python -m RobotFrameworkService.main -p ${PORT} -t ${SUITE_FOLDER}
\ No newline at end of file
+COPY docker-entrypoint.sh entrypoint.sh
+RUN chmod +x entrypoint.sh
+ENTRYPOINT ["/robot/entrypoint.sh"]
\ No newline at end of file
diff --git a/README.md b/README.md
index 78a2a96..9e58a89 100644
--- a/README.md
+++ b/README.md
@@ -2,28 +2,36 @@
 
 # Robot Task Webservice
 
-A web service managing Robot Framework tasks.
+A web service managing Robot Framework tasks/tests.
 
 # Goal
 
-This web service shall start Robot Framework tasks and return and cache the according reports.
+This web service shall start Robot Framework tasks/tests and return and cache the according reports.
 
 # Installation and Execution
-*Default docker image does not support variable files, yet*
 
 ## Docker
+You can run the image and map your test cases into the webservice with a volume :
 ```
-docker pull ghcr.io/marketsquare/robotframework-webservice:master
+docker run --rm --publish 5003:5003 \
+           --volume <host directory of test cases>:/robot/tests \
+           --env SUITE_FOLDER=tests \
+           ghcr.io/marketsquare/robotframework-webservice:master
 ```
-After that you can run the image and map your test cases in to the webservice with a volumen:
+You can also run the image and map your test cases and your variable files (separated by spaces) into the webservice with volumes :
 ```
-docker run -v <host directory of test cases>:/robot/tests --env SUITE_FOLDER=tests rf-webservice:latest
+docker run --rm --publish 5003:5003 \
+           --volume <host directory of test cases>:/robot/tests \
+           --volume <host directory of variable files>:/robot/variables \
+           --env SUITE_FOLDER=tests \
+           --env "VARIABLE_FILES=variables/variables.py variables/variables2.py" \
+           ghcr.io/marketsquare/robotframework-webservice:master
 ```
 
 ## Podman
 Almost as Docker, but you might need to attach the webservice to the host network:
 ```
-podman run --network host -v ./tasks:/robot/tasks --env SUITE_FOLDER=tasks rf-webservice:latest
+podman run --network host -v ./examples:/robot/tasks --env SUITE_FOLDER=tasks rf-webservice:latest
 ```
 
 ## Local
@@ -43,13 +51,13 @@ There are 2 types of endpoints:
 2. Reporting
 
 ## Execution
-Endpoints that trigger execution of a robot task, for instance:
+Endpoints that trigger execution of a robot task/test, for instance:
 
-Call robot task:
+Call robot task/test:
 
     http://localhost:5003/robotframework/run/mytask
 
-Call robot task with variables:
+Call robot task/test with variables:
 
     http://localhost:5003/robotframework/run/mytask?myVariable1=42&anotherVariable=Mustermann
 
@@ -58,7 +66,7 @@ Response contains a header field `x-request-id` that can be used to retrieve log
 There are endpoints for synchronous and asynchronous request:
 
 ```
-# connection remains open for duration of my task
+# connection remains open for duration of my task/test
 http://localhost:5003/robotframework/run/mytask
 
 # connection closes immediately - result must be requested with the x-request-id
@@ -107,8 +115,8 @@ Swagger-UI is available under `http://localhost:5003/docs`
 
 # Demo-Tasks
 
-This project contains some tasks for demonstration. They are located in ``tasks`` folder. You may add
-your own task suites in that directory, if you like.
+This project contains some tasks, tests and variables for demonstration. They are located in ``examples`` folder. You may add
+your own task/test suites in that directory, if you like.
 
 # Task name with spaces in URL
 
diff --git a/RobotFrameworkService/Config.py b/RobotFrameworkService/Config.py
index 8ed5c30..45344bf 100644
--- a/RobotFrameworkService/Config.py
+++ b/RobotFrameworkService/Config.py
@@ -1,6 +1,6 @@
 class Config:
     class Default:
-        taskfolder = "tasks"
+        taskfolder = "examples"
         variablefiles = None
         debugfile = None
 
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100644
index 0000000..645c469
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -n "${VARIABLE_FILES}" ]; then
+  variablefiles="--variablefiles ${VARIABLE_FILES}"
+else
+  variablefiles=""
+fi
+
+exec python -m RobotFrameworkService.main --port "${PORT}" --taskfolder "${SUITE_FOLDER}" ${variablefiles}
\ No newline at end of file
diff --git a/tasks/anothertask.robot b/examples/tasks/anothertask.robot
similarity index 69%
rename from tasks/anothertask.robot
rename to examples/tasks/anothertask.robot
index 22fe1e1..7b4cb56 100644
--- a/tasks/anothertask.robot
+++ b/examples/tasks/anothertask.robot
@@ -1,3 +1,3 @@
-*** Task ***
+*** Tasks ***
 Another task
     Log    ABCDEFG
diff --git a/tasks/demotask.robot b/examples/tasks/demotask.robot
similarity index 75%
rename from tasks/demotask.robot
rename to examples/tasks/demotask.robot
index ec76b66..5930ecd 100644
--- a/tasks/demotask.robot
+++ b/examples/tasks/demotask.robot
@@ -1,3 +1,3 @@
-*** Task ***
+*** Tasks ***
 Demonstration Task
     Log    Hello World!
diff --git a/tasks/evenmore.robot b/examples/tasks/evenmore.robot
similarity index 100%
rename from tasks/evenmore.robot
rename to examples/tasks/evenmore.robot
diff --git a/examples/variables/variables.py b/examples/variables/variables.py
new file mode 100644
index 0000000..049e005
--- /dev/null
+++ b/examples/variables/variables.py
@@ -0,0 +1,1 @@
+hello = "Hi"
diff --git a/examples/variables/variables2.py b/examples/variables/variables2.py
new file mode 100644
index 0000000..21bfc22
--- /dev/null
+++ b/examples/variables/variables2.py
@@ -0,0 +1,1 @@
+who = "World!"


Test patch:
diff --git a/examples/tests/demotest.robot b/examples/tests/demotest.robot
new file mode 100644
index 0000000..1577c02
--- /dev/null
+++ b/examples/tests/demotest.robot
@@ -0,0 +1,7 @@
+*** Variables ***
+${hello}    Hello
+${who}    John Doe
+
+*** Test Cases ***
+Demonstration Test
+    Log    ${hello} ${who}