139 lines
6.5 KiB
YAML
139 lines
6.5 KiB
YAML
name: Perform staging tests (REUSABLE)
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
TYPE:
|
|
required: true
|
|
type: string
|
|
RUNS_ON:
|
|
required: true
|
|
type: string
|
|
# secrets:
|
|
# PRIVATE_REGISTRY:
|
|
# required: true
|
|
# PRIVATE_REGISTRY_TOKEN:
|
|
# required: true
|
|
# TEST_DOMAINS:
|
|
# required: true
|
|
# ROOT_DOMAIN:
|
|
# required: true
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ${{ fromJSON(inputs.RUNS_ON) }}
|
|
steps:
|
|
# Prepare
|
|
- name: Checkout source code
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
|
- name: Login to ghcr
|
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- run: docker pull ghcr.io/bunkerity/bunkerweb-tests:testing && docker tag ghcr.io/bunkerity/bunkerweb-tests:testing local/bunkerweb-tests:latest
|
|
if: contains(fromJSON('["linux", "k8s"]'), inputs.TYPE) != true
|
|
- run: docker pull ghcr.io/bunkerity/scheduler-tests:testing && docker tag ghcr.io/bunkerity/scheduler-tests:testing local/scheduler-tests:latest
|
|
if: contains(fromJSON('["linux", "k8s"]'), inputs.TYPE) != true
|
|
- run: docker pull ghcr.io/bunkerity/autoconf-tests:testing && docker tag ghcr.io/bunkerity/autoconf-tests:testing local/autoconf-tests:latest
|
|
if: contains(fromJSON('["autoconf", "swarm"]'), inputs.TYPE)
|
|
- name: Push images to local repo
|
|
run: docker tag local/bunkerweb-tests:latest 192.168.42.100:5000/bunkerweb-tests:latest && docker push 192.168.42.100:5000/bunkerweb-tests:latest && docker tag local/scheduler-tests:latest 192.168.42.100:5000/scheduler-tests:latest && docker push 192.168.42.100:5000/scheduler-tests:latest && docker tag local/autoconf-tests:latest 192.168.42.100:5000/autoconf-tests:latest && docker push 192.168.42.100:5000/autoconf-tests:latest
|
|
if: inputs.TYPE == 'swarm'
|
|
- name: Install test dependencies
|
|
run: pip3 install --no-cache-dir --require-hashes -r tests/requirements.txt
|
|
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
|
|
with:
|
|
name: tf-k8s
|
|
path: /tmp
|
|
if: inputs.TYPE == 'k8s'
|
|
- run: |
|
|
echo "$SECRET_KEY" > /tmp/.secret_key
|
|
openssl enc -d -in /tmp/terraform.tar.enc -aes-256-cbc -pbkdf2 -iter 100000 -md sha256 -pass file:/tmp/.secret_key -out /tmp/terraform.tar
|
|
rm -f /tmp/.secret_key
|
|
tar xf /tmp/terraform.tar -C /
|
|
mkdir /tmp/reg
|
|
cp tests/terraform/k8s-reg.tf /tmp/reg
|
|
cp tests/terraform/providers.tf /tmp/reg
|
|
cd /tmp/reg
|
|
export TF_VAR_k8s_reg_user=${REG_USER}
|
|
export TF_VAR_k8s_reg_token=${REG_TOKEN}
|
|
terraform init
|
|
terraform apply -auto-approve
|
|
env:
|
|
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
|
REG_USER: ${{ github.actor }}
|
|
REG_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
if: inputs.TYPE == 'k8s'
|
|
- uses: azure/setup-kubectl@901a10e89ea615cf61f57ac05cecdf23e7de06d8 # v3.2
|
|
if: inputs.TYPE == 'k8s'
|
|
with:
|
|
version: "v1.28.2"
|
|
- uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
|
|
if: inputs.TYPE == 'k8s'
|
|
- name: Pull BW linux ubuntu test image
|
|
if: inputs.TYPE == 'linux'
|
|
run: docker pull ghcr.io/bunkerity/ubuntu-tests:testing && docker tag ghcr.io/bunkerity/ubuntu-tests:testing local/ubuntu:latest
|
|
- name: Pull BW linux debian test image
|
|
if: inputs.TYPE == 'linux'
|
|
run: docker pull ghcr.io/bunkerity/debian-tests:testing && docker tag ghcr.io/bunkerity/debian-tests:testing local/debian:latest
|
|
- name: Pull BW linux fedora test image
|
|
if: inputs.TYPE == 'linux'
|
|
run: docker pull ghcr.io/bunkerity/fedora-tests:testing && docker tag ghcr.io/bunkerity/fedora-tests:testing local/fedora:latest
|
|
- name: Pull BW linux rhel test image
|
|
if: inputs.TYPE == 'linux'
|
|
run: docker pull ghcr.io/bunkerity/rhel-tests:testing && docker tag ghcr.io/bunkerity/rhel-tests:testing local/rhel:latest
|
|
# Do tests
|
|
- name: Run tests
|
|
if: inputs.TYPE == 'docker'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "${{ inputs.TYPE }}"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_DOCKER }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run tests
|
|
if: inputs.TYPE == 'autoconf'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "${{ inputs.TYPE }}"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_AUTOCONF }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run tests
|
|
if: inputs.TYPE == 'swarm'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "${{ inputs.TYPE }}"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_SWARM }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run tests
|
|
if: inputs.TYPE == 'k8s'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "kubernetes"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_KUBERNETES }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
KUBECONFIG: "/tmp/k8s/kubeconfig"
|
|
PRIVATE_REGISTRY: ${{ secrets.PRIVATE_REGISTRY }}
|
|
IMAGE_TAG: "testing"
|
|
- name: Run Linux ubuntu tests
|
|
if: inputs.TYPE == 'linux'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "linux" "ubuntu"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_LINUX }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run Linux debian tests
|
|
if: inputs.TYPE == 'linux'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "linux" "debian"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_LINUX }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run Linux fedora tests
|
|
if: inputs.TYPE == 'linux'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "linux" "fedora"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_LINUX }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|
|
- name: Run Linux rhel tests
|
|
if: inputs.TYPE == 'linux'
|
|
run: export $(echo "$TEST_DOMAINS" | xargs) && ./tests/main.py "linux" "rhel"
|
|
env:
|
|
TEST_DOMAINS: ${{ secrets.TEST_DOMAINS_LINUX }}
|
|
ROOT_DOMAIN: ${{ secrets.ROOT_DOMAIN }}
|