Skip to content

Commit

Permalink
run actions
Browse files Browse the repository at this point in the history
  • Loading branch information
szachovy committed Jun 22, 2024
1 parent b56e677 commit 8b7b783
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
64 changes: 64 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run tests

on:
push:
branches: '**'

jobs:
tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.0.10

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: 3.10

- name: Cache Python packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: pip install --no-cache-dir --user ansible==9.5.1

- name: Setup OpenSSH Server
run: |
sudo apt update
sudo apt install --yes openssh-server=1:8.9p1-3ubuntu0.7
sudo service ssh start
- name: Initialize Terraform infrastructure
run: terraform init
working-directory: ./tests/setup

- name: Validate Terraform configuration
run: terraform validate
working-directory: ./tests/setup

- name: Apply Terraform infrastructure
run: terraform apply --auto-approve
working-directory: ./tests/setup

- name: Run testsuite
run: ansible-playbook --inventory inventory.yml deploy.yml
working-directory: ./tests/testsuite

- name: Cleanup
if: always()
run: terraform destroy --auto-approve
working-directory: ./tests/setup

- name: Notify on failure
if: failure()
run: echo "The workflow failed."
36 changes: 18 additions & 18 deletions tests/setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resource "null_resource" "manage_ssh" {
}

provisioner "local-exec" {
when = create
when = create
command = <<-EOT
ssh-keygen -t rsa -b 2048 -f id_rsa -N ''
chmod 600 id_rsa.pub
Expand All @@ -26,7 +26,7 @@ resource "null_resource" "manage_ssh" {
}

provisioner "local-exec" {
when = destroy
when = destroy
command = <<-EOT
rm id_rsa id_rsa.pub
sed --in-place \
Expand All @@ -38,11 +38,11 @@ resource "null_resource" "manage_ssh" {
}

resource "docker_network" "nodes_network" {
name = "${var.node_prefix}-network"
name = "${var.node_prefix}-network"

ipam_config {
subnet = "${var.subnet}"
gateway = "${var.gateway}"
subnet = var.subnet
gateway = var.gateway
}

labels {
Expand Down Expand Up @@ -73,15 +73,15 @@ resource "docker_image" "node_image" {
}

resource "docker_container" "nodes" {
count = "5"
name = "${var.node_prefix}-${count.index}"
hostname = "${var.node_prefix}-${count.index}"
image = "${docker_image.node_image.name}"
count = "5"
name = "${var.node_prefix}-${count.index}"
hostname = "${var.node_prefix}-${count.index}"
image = docker_image.node_image.name
privileged = true

ports {
internal = 8088
external = "${8088 + count.index}"
external = 8088 + count.index
}

ulimit {
Expand All @@ -91,7 +91,7 @@ resource "docker_container" "nodes" {
}

networks_advanced {
name = "${docker_network.nodes_network.name}"
name = docker_network.nodes_network.name
ipv4_address = cidrhost("${var.subnet}", "${2 + count.index}")
}

Expand All @@ -111,7 +111,7 @@ resource "docker_container" "nodes" {
EOT

environment = {
HOSTNAME = "${var.node_prefix}-${count.index}"
HOSTNAME = "${var.node_prefix}-${count.index}"
IP_ADDRESS = cidrhost("${var.subnet}", "${2 + count.index}")
}
}
Expand All @@ -129,7 +129,7 @@ resource "null_resource" "generate_ansible_group_vars" {
}

provisioner "local-exec" {
when = create
when = create
command = <<-EOT
mkdir $(dirname $GROUP_VARS_FILE)
cp $DEFAULTS_FILE $GROUP_VARS_FILE
Expand All @@ -141,18 +141,18 @@ resource "null_resource" "generate_ansible_group_vars" {
EOT

environment = {
DEFAULTS_FILE="../../src/defaults.yml"
GROUP_VARS_FILE="../testsuite/group_vars/testing.yml"
NODE_PREFIX="${var.node_prefix}"
DEFAULTS_FILE = "../../src/defaults.yml"
GROUP_VARS_FILE = "../testsuite/group_vars/testing.yml"
NODE_PREFIX = "${var.node_prefix}"
}
}

provisioner "local-exec" {
when = destroy
when = destroy
command = "rm --recursive $(dirname $GROUP_VARS_FILE)"

environment = {
GROUP_VARS_FILE="../testsuite/group_vars/testing.yml"
GROUP_VARS_FILE = "../testsuite/group_vars/testing.yml"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/testsuite/roles/testing/files/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests==2.32.3
docker==7.1.0
retry==0.9.2
4 changes: 2 additions & 2 deletions tests/testsuite/roles/testing/tasks/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
command: "/bin/bash -c
'wget https://bootstrap.pypa.io/get-pip.py &&
python3 get-pip.py &&
pip install --no-cache-dir --user requests==2.32.3 docker==7.1.0 retry==0.9.2'"
pip install --no-cache-dir --user --requirement {{ role_path }}/files/requirements.txt'"
timeout: 15

- name: "copy superset functional tests source to the container"
Expand Down Expand Up @@ -44,7 +44,7 @@
command: "/bin/bash -c
'wget https://bootstrap.pypa.io/get-pip.py &&
python3 get-pip.py &&
pip install --no-cache-dir --user requests==2.32.3 docker==7.1.0 retry==0.9.2'"
pip install --no-cache-dir --user --requirement {{ role_path }}/files/requirements.txt'"
timeout: 15

- name: "copy mgmt functional tests source to the container"
Expand Down

0 comments on commit 8b7b783

Please sign in to comment.