Skip to content

Commit

Permalink
Merge pull request #1 from clickoneagencia/ci
Browse files Browse the repository at this point in the history
Configure validations using CI
  • Loading branch information
arendondiosa authored Jun 15, 2024
2 parents 7e2ec2a + e01ba83 commit 6fb7b68
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 31 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Automation Checks

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
id-token: write
contents: write
pages: write

jobs:
build-and-test:
name: Automation for agencia-clickone
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout branch
uses: actions/checkout@v2
with:
path: automation
- name: Run automation tests
run: |
cd automation
ls -la
./run_tests.sh -S ${{ env.INPUT_SRC }}
env:
INPUT_SRC: automation
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: github-pages
path: automation/results/

deploy:
needs: build-and-test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.DS_Store
Results/*
ci-cache/
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM python:3.11.9-slim

ENV PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.11/site-packages:/usr/lib/python3.11/site-packages:/app"
ENV FORCE_COLOR true
ENV DEBIAN_FRONTEND noninteractive
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_CACHE_DIR="/cache/pip"

USER root
WORKDIR /app
RUN ["/bin/bash", "-c", "mkdir -p /app"]

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential gnupg2 libnss3 libxss1 libasound2 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdbus-1-3 libdrm2 libgbm1 libgtk-3-0 libnspr4 libxcomposite1 libxdamage1 libxfixes3 xvfb make gcc git curl wget unzip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/

# Download and install Docker binaries
RUN curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz -o /tmp/docker.tgz && \
tar --extract --file /tmp/docker.tgz --strip-components=1 --directory /usr/local/bin/ && \
rm /tmp/docker.tgz

# Install containerd (optional, if not included in the Docker binaries)
RUN curl -fsSL https://github.com/containerd/containerd/releases/download/v1.4.11/containerd-1.4.11-linux-amd64.tar.gz -o /tmp/containerd.tgz && \
tar --extract --file /tmp/containerd.tgz --strip-components=1 --directory /usr/local/bin/ && \
rm /tmp/containerd.tgz

RUN curl https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.61/linux64/chrome-linux64.zip --output chrome-linux64.zip
RUN unzip chrome-linux64.zip
RUN mv chrome-linux64 /chrome
RUN ln -s /chrome/chrome /usr/bin/google-chrome
RUN chown root:root /usr/bin/google-chrome
RUN chmod +x /usr/bin/google-chrome
RUN rm chrome-linux64.zip

RUN curl https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.61/linux64/chromedriver-linux64.zip --output chromedriver-linux64.zip
RUN unzip chromedriver-linux64.zip
RUN mv chromedriver-linux64/chromedriver /usr/bin/chromedriver
RUN chown root:root /usr/bin/chromedriver
RUN chmod +x /usr/bin/chromedriver
RUN rm chromedriver-linux64.zip

# Set environment variables
ENV DISPLAY=:99

# Start Xvfb and keep the container running
CMD ["sh", "-c", "Xvfb :99 -screen 0 1024x768x16 & robot --outputdir /opt/robotframework/reports /opt/robotframework/tests"]
29 changes: 13 additions & 16 deletions Tests/agenciaclickone/ContactForm.robot
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
*** Settings ***
Documentation Contact Form
Library SeleniumLibrary
Library Process

*** Variables ***
${BROWSER} chrome

*** Test Cases ***
Verify contact form for ClickOne - Google Chrome
Verify contact form for ClickOne
[Documentation] This test case verifies the contact form
[Tags] Functional
Open Browser https://agenciaclickone.com/ chrome
${chrome_options}= Create Chrome Options
Open Browser https://agenciaclickone.com/ ${BROWSER} options=${chrome_options}
Input Text //*[@id="form-field-name"] John Doe
Input Text //*[@id="form-field-email"] [email protected]
Input Text //*[@id="form-field-message"] 30000000
Click Element //*[@id="form-field-Aceptolapoliticadeprivacidad"]
Click Button //*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2]/div/div/div/div/form/div/div[5]/button
Wait Until Page Contains Gracias por contactarnos 15
Close Browser

Verify contact form for ClickOne - Forefox
[Documentation] This test case verifies the contact form
[Tags] Functional
Open Browser https://agenciaclickone.com/ firefox
Input Text //*[@id="form-field-name"] John Doe
Input Text //*[@id="form-field-email"] [email protected]
Input Text //*[@id="form-field-message"] 30000000
Click Element //*[@id="form-field-Aceptolapoliticadeprivacidad"]
Click Button //*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2]/div/div/div/div/form/div/div[5]/button
Wait Until Page Contains Gracias por contactarnos 15
Close Browser
[Teardown] Close Browser

*** Keywords ***
Create Chrome Options
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${options} add_argument --headless
Call Method ${options} add_argument --disable-gpu
Call Method ${options} add_argument --no-sandbox
Call Method ${options} add_argument --disable-dev-shm-usage
RETURN ${options}
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
nextjs-app:
container_name: clickone-automation
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/app
command: robot -d results /app/Tests
restart: always
42 changes: 27 additions & 15 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,40 @@ channels:
- defaults
- conda-forge
dependencies:
- bzip2=1.0.8=h6c40b1e_6
- ca-certificates=2024.3.11=hecd8cb5_0
- libffi=3.4.4=hecd8cb5_1
- ncurses=6.4=hcec6c5f_0
- openssl=3.0.13=hca72f7f_2
- pip=24.0=py311hecd8cb5_0
- python=3.11.9=hf27a42d_0
- readline=8.2=hca72f7f_0
- setuptools=69.5.1=py311hecd8cb5_0
- sqlite=3.45.3=h6c40b1e_0
- tk=8.6.14=h4d00af3_0
- tzdata=2024a=h04d1e81_0
- wheel=0.43.0=py311hecd8cb5_0
- xz=5.4.6=h6c40b1e_1
- zlib=1.2.13=h4b97444_1
- bzip2=1.0.8
- ca-certificates=2024.3.11
- libffi=3.4.4
- ncurses=6.4
- openssl=3.0.13
- pip=24.0
- python=3.11.9
- readline=8.2
- setuptools=69.5.1
- sqlite=3.45.3
- tk=8.6.14
- tzdata=2024a
- wheel=0.43.0
- xz=5.4.6
- zlib=1.2.13
- pip:
- attrs==23.2.0
- certifi==2024.6.2
- charset-normalizer==3.3.2
- click==8.1.7
- grpcio==1.63.0
- grpcio-tools==1.63.0
- h11==0.14.0
- idna==3.7
- outcome==1.3.0.post0
- overrides==7.7.0
- packaging==24.1
- protobuf==5.26.1
- pysocks==1.7.1
- python-dotenv==1.0.1
- requests==2.32.3
- robotframework==7.0.1
- robotframework-assertion-engine==3.0.3
- robotframework-browser==18.5.1
- robotframework-pythonlibcore==4.4.1
- robotframework-seleniumlibrary==6.4.0
- selenium==4.21.0
Expand All @@ -36,4 +47,5 @@ dependencies:
- trio-websocket==0.11.1
- typing-extensions==4.12.2
- urllib3==2.2.1
- wrapt==1.16.0
- wsproto==1.2.0
34 changes: 34 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
appdirs==1.4.4
attrs==23.2.0
beautifulsoup4==4.12.3
certifi==2024.6.2
charset-normalizer==3.3.2
click==8.1.7
grpcio==1.63.0
grpcio-tools==1.63.0
h11==0.14.0
idna==3.7
lxml==5.2.2
outcome==1.3.0.post0
overrides==7.7.0
packaging==24.1
protobuf==5.26.1
PySocks==1.7.1
python-dotenv==1.0.1
requests==2.32.3
robotframework==7.0.1
robotframework-assertion-engine==3.0.3
robotframework-browser==18.5.1
robotframework-pythonlibcore==4.4.1
robotframework-seleniumlibrary==6.4.0
selenium==4.21.0
sniffio==1.3.1
sortedcontainers==2.4.0
soupsieve==2.5
tqdm==4.66.4
trio==0.25.1
trio-websocket==0.11.1
typing_extensions==4.12.2
urllib3==2.2.1
wrapt==1.16.0
wsproto==1.2.0
31 changes: 31 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

while getopts "I:S:" flag
do
case "${flag}" in
S) INPUT_SRC=${OPTARG};;
I) INSTALL_PACKAGES=${OPTARG};;
*) echo "${OPTARG} is an invalid parameter";;
esac
done

SRC=${INPUT_SRC:=""}
INSTALL_PACKAGES=true
RUN_COMMAND="cd /app/$SRC"

if [ "$INSTALL_PACKAGES" = true ] ; then
UPDATE_PACKAGE_MANAGER_CMD="python3.11 -m pip install --upgrade pip"
INSTALLATION_PACKAGES_CMD="pip3.11 install -r requirements.txt"
RUN_COMMAND="${RUN_COMMAND}; ${UPDATE_PACKAGE_MANAGER_CMD}; ${INSTALLATION_PACKAGES_CMD}"
fi

RUN_COMMAND="${RUN_COMMAND}; robot -d results Tests"

# exit when any command fails
set -e

docker run -i --name automation_tests --rm \
-v $(pwd):/app/automation \
-v $(pwd)/ci-cache/py/3.11/cache:/cache/pip \
clickoneagencia/automation \
/bin/sh -c "$RUN_COMMAND"

0 comments on commit 6fb7b68

Please sign in to comment.