Skip to content

Commit dd8d2c6

Browse files
authored
Merge pull request #319 from ppodgorsek/feature/install-datetimetz
* Update Dockerfile * Update README.md Co-authored-by: Paul Podgorsek <[email protected]>
2 parents 38f958a + bbee5a2 commit dd8d2c6

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

.github/workflows/docker-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ jobs:
7272
- name: Custom User and Group Test
7373
run:
7474
docker run --user=2000:2000 --shm-size=1g -v `pwd`/test:/opt/robotframework/tests:Z -e BROWSER=$BROWSER $IMAGE_NAME
75+
- name: Datetime
76+
run:
77+
docker run --user=2000:2000 --shm-size=1g -v `pwd`/test:/opt/robotframework/tests:Z -e BROWSER=$BROWSER -e TZ="America/New_York" $IMAGE_NAME

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ENV SCREEN_COLOUR_DEPTH 24
1717
ENV SCREEN_HEIGHT 1080
1818
ENV SCREEN_WIDTH 1920
1919

20+
# Setup the timezone to use, defaults to UTC
21+
ENV TZ UTC
22+
2023
# Set number of threads for parallel execution
2124
# By default, no parallelisation
2225
ENV ROBOT_THREADS 1
@@ -29,6 +32,7 @@ ENV ROBOT_GID 1000
2932
ENV ALPINE_GLIBC 2.31-r0
3033
ENV CHROMIUM_VERSION 86.0
3134
ENV DATABASE_LIBRARY_VERSION 1.2
35+
ENV DATETIMETZ_VERSION 1.0.6
3236
ENV FAKER_VERSION 5.0.0
3337
ENV FIREFOX_VERSION 78
3438
ENV FTP_LIBRARY_VERSION 1.9
@@ -63,6 +67,7 @@ RUN apk update \
6367
"chromium-chromedriver~$CHROMIUM_VERSION" \
6468
"firefox-esr~$FIREFOX_VERSION" \
6569
xauth \
70+
tzdata \
6671
"xvfb-run~$XVFB_VERSION" \
6772
&& mv /usr/lib/chromium/chrome /usr/lib/chromium/chrome-original \
6873
&& ln -sfv /opt/robotframework/bin/chromium-browser /usr/lib/chromium/chrome \
@@ -73,6 +78,7 @@ RUN apk update \
7378
--no-cache-dir \
7479
robotframework==$ROBOT_FRAMEWORK_VERSION \
7580
robotframework-databaselibrary==$DATABASE_LIBRARY_VERSION \
81+
robotframework-datetime-tz==$DATETIMETZ_VERSION \
7682
robotframework-faker==$FAKER_VERSION \
7783
robotframework-ftplibrary==$FTP_LIBRARY_VERSION \
7884
robotframework-imaplibrary2==$IMAP_LIBRARY_VERSION \
@@ -99,6 +105,7 @@ RUN apk update \
99105
&& mv geckodriver /opt/robotframework/drivers/geckodriver \
100106
&& rm geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz \
101107

108+
# Clean up buildtime dependencies
102109
&& apk del --no-cache --update-cache .build-deps
103110

104111
# Create the default report and work folders with the default user to avoid runtime issues

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The versions used are:
1717

1818
* [Robot Framework](https://github.com/robotframework/robotframework) 3.2.2
1919
* [Robot Framework DatabaseLibrary](https://github.com/franz-see/Robotframework-Database-Library) 1.2
20+
* [Robot Framework DateTimeTZ](https://github.com/testautomation/DateTimeTZ) 1.0.6
2021
* [Robot Framework Faker](https://github.com/guykisel/robotframework-faker) 5.0.0
2122
* [Robot Framework FTPLibrary](https://github.com/kowalpy/Robot-Framework-FTP-Library) 1.9
2223
* [Robot Framework IMAPLibrary 2](https://pypi.org/project/robotframework-imaplibrary2/) 0.3.8
@@ -92,6 +93,16 @@ This project includes the IMAP library which allows Robot Framework to connect t
9293

9394
A suggestion to automate email testing is to run a [Mailcatcher instance in Docker which allows IMAP connections](https://github.com/estelora/docker-mailcatcher-imap). This will ensure emails are discarded once the tests have been run.
9495

96+
### Dealing with Datetimes and Timezones
97+
98+
This project is meant to allow your tests to run anywhere. Sometimes that can be in a different timezone than your local one or of the location under test. To help solve such issues, this image includes the [DateTimeTZ Library](https://testautomation.github.io/DateTimeTZ/doc/DateTimeTZ.html).
99+
100+
To set the timezone used inside the Docker image, you can set the `TZ` environment variable:
101+
102+
docker run \
103+
-e TZ=America/New_York \
104+
ppodgorsek/robot-framework:latest
105+
95106
## Security consideration
96107

97108
By default, containers are implicitly run using `--user=1000:1000`, please remember to adjust that command-line setting accordingly, for example:

test/faker.robot

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,4 @@ Can call Password
5656
${pass}= Password 5823 ${True} ${False} ${True} ${True}
5757
Length Should Be ${pass} 5823
5858
${pass}= Password ${5823} ${True} ${False} ${True} ${True}
59-
Length Should Be ${pass} 5823
60-
61-
*** Keywords ***
59+
Length Should Be ${pass} 5823

test/timezones.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Force Tags timezone
3+
Test Timeout 1 minute
4+
Library DateTimeTZ
5+
6+
*** Test Cases ***
7+
Get Time with Datetime
8+
${ts}= Get Timestamp
9+
Set Test Message ${ts}

0 commit comments

Comments
 (0)