feat-test-playbooks #5

Merged
realaravinth merged 19 commits from feat-test-playbooks into master 2023-12-13 00:49:03 +05:30
2 changed files with 24 additions and 23 deletions
Showing only changes of commit 713ec1dd18 - Show all commits

View file

@ -1,33 +1,22 @@
steps:
backend:
image: python:3-bookworm
environment:
- ANSIBLE_HOST_KEY_CHECKING=False
commands:
- apt-get update
- apt-get install -y ca-certificates curl gnupg tar wget libssl-dev python3-pip cython3 pipx apt-transport-https coreutils iputils-ping openssh-client libvirt-clients genisoimage
- export PATH=$PATH:/root/.local/bin
- eval "$(ssh-agent -s)"
- make ci.init
- cat /tmp/ci-ssh-id
- eval "$(ssh-agent -s)"
- ssh-add /tmp/ci-ssh-id
- ssh -o StrictHostKeyChecking=accept-new mcaptcha-ci@192.168.0.102 "echo f"
- install -m 0755 -d /etc/apt/keyrings
- curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu.gpg
- chmod a+r /etc/apt/keyrings/opentofu.gpg
- echo "deb [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" > /etc/apt/sources.list.d/opentofu.list
echo "deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" >> /etc/apt/sources.list.d/opentofu.list
- apt-get update
- apt-get install -y tofu
- tofu -chdir=terraform/mcaptcha/ init
- tofu -chdir=terraform/mcaptcha/ plan -var-file="ci.tfvars" -out="mcaptcha"
- tofu -chdir=terraform/mcaptcha/ apply "mcaptcha"
- cd ../../
- pipx install --include-deps ansible
- pipx ensurepath && echo $SHELL
- /root/.local/bin/ansible-galaxy install -r ./ansible/requirements.yml
- /root/.local/bin/ansible-playbook --become --connection=local -i localhost, --limit 127.0.0.1 ./ansible/mcaptcha.yml
- pipx install --include-deps pytest-testinfra
- cd tests/cache/ && py.test --verbose base.py
- cd tests/mcaptcha/ && py.test --verbose base.py
- echo yes | tofu destroy \
-var-file="ci.tfvars"
- pip install virtualenv && virtualenv venv
- . venv/bin/activate && pip install ansible pytest-testinfra requests
- . venv/bin/activate && ansible-galaxy install -r ./ansible/requirements.yml
- . venv/bin/activate && ansible-playbook --become -i terraform/mcaptcha/hosts.ini ./ansible/mcaptcha.yml
- cat terraform/mcaptcha/hosts.ini
- export ANSIBLE_REMOTE_USER=root
- . venv/bin/activate && py.test --hosts="ansible://mcaptcha_hosts" --ansible-inventory=terraform/mcaptcha/hosts.ini --verbose tests/cache/base.py
- . venv/bin/activate && py.test --hosts="ansible://mcaptcha_hosts" --ansible-inventory=terraform/mcaptcha/hosts.ini --verbose tests/mcaptcha/base.py
- make ci.clean
secrets: [TEST_NODE_SSH_KEY]

View file

@ -135,9 +135,21 @@ test.mcaptcha: ## Test mcaptcha configuration
$(call test_mcaptcha)
ci.init:
apt-get update
apt-get install -y ca-certificates curl gnupg tar wget libssl-dev python3-pip cython3 pipx apt-transport-https coreutils iputils-ping openssh-client libvirt-clients genisoimage
./scripts/ci.sh --init "$$TEST_NODE_SSH_KEY"
ssh-add /tmp/ci-ssh-id
ssh -o StrictHostKeyChecking=accept-new mcaptcha-ci@192.168.0.102 "echo f"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu.gpg
chmod a+r /etc/apt/keyrings/opentofu.gpg
echo "deb [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" > /etc/apt/sources.list.d/opentofu.list
echo "deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" >> /etc/apt/sources.list.d/opentofu.list
apt-get update
apt-get install -y tofu
ci.clean:
echo yes | tofu destroy -var-file="ci.tfvars"
./scripts/ci.sh --clean
help: ## Prints help for targets with comments