Skip to content

Commit

Permalink
Add CI resources based on Robot-Framework
Browse files Browse the repository at this point in the history
* Include Docker setup and scripts (`Dockerfile`, `install-requirements.sh`,
  `podman-compose.sh`, `prepare-board.sh`).
* Add initial Robot Framework resources, tests, and test setup files.
* Integrate scripts for touch events and video performance testing with Robot
  Framework.
* Add `conf/nginx.conf` for NGINX configuration and `docker-compose.yml` for
  environment setup.
* Provide a comprehensive `README.md` for project setup and usage instructions.

Also:

* Add `.gitattributes` configuration for handling large files with Git LFS.
* Include `.github/scripts/` with various sanitizer scripts
  (`run-all-sanatizers`, `sanatizer-pycodestyle`, `sanatizer-pyflake8`,
 `sanatizer-shellcheck`) for automated code quality checks.
* Add GitHub Actions workflow (`sanatizers.yml`) to run sanitizers on pull
  requests.
* Add `.gitignore` with entries for backup files, virtual environments, and
  testing artifacts.
  • Loading branch information
psaavedra committed Jan 25, 2025
1 parent 902a518 commit 670aa54
Show file tree
Hide file tree
Showing 37 changed files with 1,292 additions and 4 deletions.
63 changes: 63 additions & 0 deletions .ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
A Robot Framework tests suite for automating the validation of the
meta-wpe-image images.

# Installation

We have the `install-requirements.sh` and `podman-compose.sh` scripts in the
project.The first one is a convenient script for installing the Podman
requirements. The second, is a wrapper for execute the podman-compose command
but with the environment variables defined in the setup-env.sh.

``` sh
./install-requirements.sh
cp setup-env-local.sh.sample setup-env-local.sh # Use an editor for adapt the content
```

A sample environment setup file (`setup-env-local.sh.sample`) is provided to
guide the initial configuration. It sets the variables for the test board and
network configurations adapted to your environment.

## How It Works

To set up the testing environment, run:

```sh
./podman-compose.sh up --force-recreate --always-recreate-deps --build -d -t 4
```

Once the environment is running, you can trigger the tests with the
`./run-tests.sh` launcher:

```sh
./run-tests.sh
```
### Services Setup

The `./podman-compose.sh up` command initializes the following services:

- **webserver**: Runs an NGINX container, exposing port **8008** for HTTP
requests.
- **robot**: Runs a Python-based container configured for executing tests
using the Robot Framework.

### Running Tests

To execute the tests, use:

```sh
./run-tests.sh [options]
```

Options:

- `--force-recreate` : Recreate and build containers before running tests.
- `--help` : Display the help message for available options.

### Stopping the Containers

To stop the Podman containers, use:

```sh
./podman-compose.sh down -t 4
```

35 changes: 35 additions & 0 deletions .ci/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
server {
listen 8008;
listen [::]:8008;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

location /robot_framework/html/ {
root /;
autoindex on;
}

location /tests_results/ {
root /;
autoindex on;
}

#error_page 404 /404.html;

# redirect server error pages to the static page
# /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

}


14 changes: 14 additions & 0 deletions .ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'
services:
webserver:
image: docker.io/library/nginx:latest
network_mode: host
volumes:
- ./conf/nginx.conf:/etc/nginx/conf.d/default.conf
- ./robot_framework/html:/robot_framework/html
- ./tests_results:/tests_results
robot:
build: docker/robot/
network_mode: host
volumes:
- .:/app
5 changes: 5 additions & 0 deletions .ci/docker/robot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3-slim

WORKDIR /app

CMD ["robot_framework/init-robot.sh"]
37 changes: 37 additions & 0 deletions .ci/install-requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/sh -e

# Identify the Linux distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
else
echo "Distribution identification file /etc/os-release is missing."
exit 1
fi

# Function to install podman-compose on Fedora
install_fedora() {
echo "Installing podman-compose on Fedora..."
sudo yum install -y podman-compose pycodestyle python3-pyflakes shellcheck
}

# Function to install podman-compose on Debian or Ubuntu
install_debian_ubuntu() {
echo "Installing podman-compose on $NAME..."
sudo apt update
sudo apt install -y podman-compose pycodestyle pyflakes3 shellcheck
}

# Installation process based on the identified distribution
case $ID in
fedora)
install_fedora
;;
ubuntu | debian)
install_debian_ubuntu
;;
*)
echo "Your distribution ($ID) is not supported by this script."
exit 2
;;
esac

12 changes: 12 additions & 0 deletions .ci/podman-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/sh

set -e

if [ ! -e ./setup-env.sh ]
then
echo "Please, create a ./setup-env.sh to run this command"
exit 1
fi

. ./setup-env.sh
exec podman-compose "$@"
30 changes: 30 additions & 0 deletions .ci/prepare-board.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! /bin/bash

set -eu

BASEPATH="$(dirname "$(readlink -f "$0")")"

SETUPENV="${BASEPATH}/setup-env.sh"

if [ ! -e "${SETUPENV}" ]
then
echo "Please, create a ${SETUPENV} to run this command"
exit 1
fi

# shellcheck source=./setup-env.sh
. "${SETUPENV}"

sshi() {
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "root@${TEST_BOARD_IP}" "$@"
}

scpi() {
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r "$@" "root@${TEST_BOARD_IP}":
}

pushd "${BASEPATH}"
scpi scripts
popd

sshi "/usr/bin/kill-demo || true"
3 changes: 3 additions & 0 deletions .ci/robot_framework/html/bbb_sunflower_1080p_30fps_normal.mp4
Git LFS file not shown
70 changes: 70 additions & 0 deletions .ci/robot_framework/html/glyphs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Static HTML Page</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.number-list {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="text">
<h2>Text</h2>

<!-- Regular text -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>

<!-- Bold text -->
<p><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</strong></p>

<!-- Italic text -->
<p><em>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</em></p>

<!-- Heading -->
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</h2>
</div>

<div class="numbers">
<h2>Numbers from 0 to 100</h2>
<!-- Generate numbers dynamically -->
<p><script>
for (let i = 0; i <= 100; i++) {
document.write(' ' + i);
}
</script></p>
<p><strong><script>
for (let i = 0; i <= 100; i++) {
document.write(' ' + i);
}
</script></strong></p>
<p><em><script>
for (let i = 0; i <= 100; i++) {
document.write(' ' + i);
}
</script></em></p>
<h2><script>
for (let i = 0; i <= 100; i++) {
document.write(' ' + i);
}
</script></h2>
</div>
<div class="status">
<h2> Status:
<script>
document.write('Ready');
</script>
</h2>
</div>
</body>
</html>
101 changes: 101 additions & 0 deletions .ci/robot_framework/html/vertical_scroll.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alternating Color Blocks</title>
<style>
/* Style for blocks */
.block {
width: 100%;
height: 135px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
font-weight: bold;
color: black;
}
/* Alternate colors for blocks */
.block:nth-child(odd) {
background-color: yellow;
}
.block:nth-child(even) {
background-color: white;
}
</style>
</head>
<body>

<!-- Container for blocks -->
<div class="container">
<!-- Generate blocks 1 to 64 -->
<div class="block">1</div>
<div class="block">2</div>
<div class="block">3</div>
<div class="block">4</div>
<div class="block">5</div>
<div class="block">6</div>
<div class="block">7</div>
<div class="block">8</div>
<div class="block">9</div>
<div class="block">10</div>
<div class="block">11</div>
<div class="block">12</div>
<div class="block">13</div>
<div class="block">14</div>
<div class="block">15</div>
<div class="block">16</div>
<div class="block">17</div>
<div class="block">18</div>
<div class="block">19</div>
<div class="block">20</div>
<div class="block">21</div>
<div class="block">22</div>
<div class="block">23</div>
<div class="block">24</div>
<div class="block">25</div>
<div class="block">26</div>
<div class="block">27</div>
<div class="block">28</div>
<div class="block">29</div>
<div class="block">30</div>
<div class="block">31</div>
<div class="block">32</div>
<div class="block">33</div>
<div class="block">34</div>
<div class="block">35</div>
<div class="block">36</div>
<div class="block">37</div>
<div class="block">38</div>
<div class="block">39</div>
<div class="block">40</div>
<div class="block">41</div>
<div class="block">42</div>
<div class="block">43</div>
<div class="block">44</div>
<div class="block">45</div>
<div class="block">46</div>
<div class="block">47</div>
<div class="block">48</div>
<div class="block">49</div>
<div class="block">50</div>
<div class="block">51</div>
<div class="block">52</div>
<div class="block">53</div>
<div class="block">54</div>
<div class="block">55</div>
<div class="block">56</div>
<div class="block">57</div>
<div class="block">58</div>
<div class="block">59</div>
<div class="block">60</div>
<div class="block">61</div>
<div class="block">62</div>
<div class="block">63</div>
<div class="block">64</div>
</div>

</body>
</html>

Loading

0 comments on commit 670aa54

Please sign in to comment.