Skip to content

Commit

Permalink
build robotframework (#4)
Browse files Browse the repository at this point in the history
* build robotframework

* Build firefox geckodriver

* robot framework run test inside docker network
  • Loading branch information
lecaoquochung authored Oct 26, 2020
1 parent 9e8ba1c commit 1cec69d
Show file tree
Hide file tree
Showing 20 changed files with 400 additions and 135 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- run:
name: Start Server
command: |
./.circleci/qa.sh
./.circleci/start-server.sh
- run:
name: Test Frontend Reactjs
command: |
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- run:
name: Start Server
command: |
./.circleci/qa.sh
./.circleci/start-server.sh
- run:
name: Test Cucumber
command: |
Expand Down
34 changes: 34 additions & 0 deletions .circleci/geckodriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest)
os=$(uname -s)
arch=$(uname -m)
if [ $os = "Linux" ] ; then
case "$arch" in
i386 | i486 | i786 | x86)
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux32"))')
;;
x86_64 | x86-64 | x64 | amd64)
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')
;;
xscale | arm | armv61 | armv71 | armv81 | aarch64)
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("arm7hf"))')
;;
*)
echo Architecture not supported: $arch
exit 1
;;
esac
elif [ $os = "Darwin" ] ; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
fi

if [ -z $url ] ; then
echo OS not supported: $os
exit 1
fi

echo $url

curl -s -L "$url" | tar -xz
chmod +x geckodriver
mv geckodriver /usr/bin
10 changes: 5 additions & 5 deletions .circleci/qa.sh → .circleci/start-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ yarn install
# screen -d -m -S api /root/sbt/bin/sbt -Dconfig.file=conf/application.conf -Dplay.evolutions.db.default.autoApply=true "run 80"
# curl --retry 60 --retry-connrefused --retry-max-time 60 --retry-delay 1 http://127.0.0.1
screen -d -m -S api sudo -E sbt \
-Dconfig.file=conf/application.conf \
-Dplay.evolutions.db.default.autoApply=true \
"run 80"
-Dconfig.file=conf/application.conf \
-Dplay.evolutions.db.default.autoApply=true \
"run 80"

# Wait for the server to start up
curl --retry 120 \
curl --retry 60 \
--retry-connrefused \
--retry-max-time 120 \
--retry-delay 1 \
http://127.0.0.1

# Wait for the server to start up
curl --retry 120 \
curl --retry 60 \
--retry-connrefused \
--retry-max-time 120 \
--retry-delay 1 \
Expand Down
2 changes: 2 additions & 0 deletions .circleci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pwd
yarn --version
31 changes: 28 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ RUN apk add --no-cache \
RUN apk add --no-cache \
font-noto-gothic

# ENV CHROME_BIN="/usr/bin/chromium-browser" \
# PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

Expand All @@ -110,6 +108,28 @@ COPY package.json /home/qa
RUN yarn install
RUN yarn add puppeteer

# Firefox geckodriver
# https://github.com/lecaoquochung/geckodriver-alpine/blob/master/Dockerfile
# Get all the prereqs
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-bin-2.30-r0.apk
RUN apk add glibc-2.30-r0.apk
RUN apk add glibc-bin-2.30-r0.apk

# And of course we need Firefox if we actually want to *use* GeckoDriver
# RUN apk add firefox-esr=60.9.0-r0
RUN apk update && apk upgrade
RUN apk add firefox
RUN rm -rf /var/cache/apk/*

# Then install GeckoDriver
# RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
# RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
# RUN tar -zxf geckodriver-v0.26.0-linux64.tar.gz -C /usr/bin
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz
RUN tar -zxf geckodriver-v0.27.0-linux64.tar.gz -C /usr/bin

# Add user so we don't need --no-sandbox.
RUN addgroup -S qa && adduser -S -g audio,video qa \
&& mkdir -p /home/qa/Downloads /app \
Expand Down Expand Up @@ -143,7 +163,11 @@ RUN curl -O https://bootstrap.pypa.io/get-pip.py \
&& rm get-pip.py
RUN sudo ln -s /home/qa/.local/bin/aws /usr/local/bin/aws

# sbt build
# robotframework
COPY requirements.txt /home/qa
RUN pip3 install -r requirements.txt

# build
RUN env
RUN pwd
RUN sbt sbtVersion
Expand All @@ -155,3 +179,4 @@ RUN sudo aws --version
RUN aws --version
RUN python3 --version
RUN pip3 --version
RUN geckodriver --version
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
![](https://img.shields.io/docker/cloud/build/lecaoquochung/scala)
![](https://img.shields.io/docker/cloud/build/lecaoquochung/scala) ![](https://img.shields.io/circleci/build/github/lecaoquochung/sample-play-scala)

# sample play scala
# Get started
```
./help.sh up
```

# Cucumber
- Generate json report
```
yarn cucumber -f json:report/report.json --publish
yarn cucumber --tags="@friday" -f json:report/friday.json
yarn cucumber --tags="@puppeteer" -f json:report/puppeteer.json
```
- Share report
```
yarn cucumber -f json:report/report.json --publish
```

# Puppeteer
```
yarn cucumber --tags="@puppeteer" -f json:report/puppeteer.json
```

# Robotframework
```
python3 robotframework/login/server.py
pip3 install -r requirements.txt
robot robotframework/login_tests
```

# Reference
https://github.com/buildkite/docker-puppeteer
https://github.com/mlampedx/cucumber-puppeteer-example
https://hub.docker.com/repository/docker/lecaoquochung/scala/builds
41 changes: 29 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
version: '3.7'

services:
scala:
scala-build:
container_name: scala-build
build:
context: .
Expand All @@ -13,20 +13,37 @@ services:
environment:
- TZ=Asia/Tokyo
- LC_ALL=en_US.UTF-8
# ports:
# - 9001:80
# - 9002:9000

scala-test:
container_name: scala-test
image: lecaoquochung/scala:dev
scala:
container_name: scala
image: lecaoquochung/scala:test
working_dir: /home/qa/code
volumes:
- ".:/home/qa/code"
# entrypoint: ["sh", "-c", "sbt -Dconfig.file=conf/application.conf -Dplay.evolutions.db.default.autoApply=true run"]
command: >
sh -c "
sbt
-Dconfig.file=conf/application.conf \
-Dplay.evolutions.db.default.autoApply=true \
run
"
environment:
- TZ=Asia/Tokyo
- LC_ALL=en_US.UTF-8
ports:
- 39000:9000

python:
container_name: python
image: lecaoquochung/scala:test
working_dir: /home/qa/code
volumes:
- ".:/home/qa/code"
entrypoint: [ "sh", "-c", "sleep infinity" ]
command: >
sh -c "python3 robotframework/login/server.py"
environment:
- TZ=Asia/Tokyo
- LC_ALL=en_US.UTF-8
# ports:
# - 9003:80
# - 9004:9000
ports:
- 39001:9001
30 changes: 21 additions & 9 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ status() {
# run logs
logs() {
case $1 in
php|*) docker-compose logs ;;
python) docker-compose logs python;;
scala) docker-compose logs scala;;
all|*) docker-compose logs ;;
esac
}

Expand All @@ -83,17 +85,27 @@ run_ssh() {

# run cli
run_cli() {
echo "Bash version ${BASH_VERSION}..."
for i in {1..10}
do
echo "${!i}"
done
# echo "Bash version ${BASH_VERSION}..."
# for i in {1..10}
# do
# printf "${i}:${!i} "
# done
# echo " "

case $1 in
case $2 in
help)
cat <<EOF
# cucumber
cli yarn cucumber --tags="@friday" -f json:report/report.json --publish
# robotframework
EOF
;;
*)
docker-compose exec -T ${NAME} /bin/bash -c \
" \
${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} \
${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} \
${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} \
${21} ${22} ${23} ${24} ${25} ${26} ${27} ${28} ${29} ${30} \
${31} ${32} ${33} ${34} ${35} ${36} ${37} ${38} ${39} ${40}
Expand All @@ -105,7 +117,7 @@ run_cli() {
case $1 in
cli)
run_cli \
${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} \
${1} ${2:-help} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} \
${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} \
${21} ${22} ${23} ${24} ${25} ${26} ${27} ${28} ${29} ${30} \
${31} ${32} ${33} ${34} ${35} ${36} ${37} ${38} ${39} ${40}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-play-scala",
"version": "1.0.0-build-1",
"version": "1.0.0-build-3-firefox",
"license": "MIT",
"description": "sample play scala",
"dependencies": {
Expand Down
Loading

0 comments on commit 1cec69d

Please sign in to comment.