Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI resources based on Robot-Framework #21

Merged
merged 11 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
14 changes: 14 additions & 0 deletions .ci/robot_framework/html/home-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Home Page</title>
</head>
<body>
<h1>Welcome to the Home Page</h1>
<p>Click the link below to go to the search page.</p>
<a href="search-page.html">Go to Search Page</a>
</body>
</html>
18 changes: 18 additions & 0 deletions .ci/robot_framework/html/search-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Search Page</title>
</head>
<body>
<h1>Welcome to the Search Page</h1>
<form action="/search" method="get">
<label for="query">Search:</label>
<input type="text" id="query"
name="query">
<button type="submit">Search</button>
</form>
</body>
</html>
Loading
Loading