improved testing

This commit is contained in:
dhs 2020-04-17 09:22:34 +02:00 committed by Thomas Maurice
parent 15a5f64e8a
commit 7e59a636cb
13 changed files with 156 additions and 102 deletions

9
.ansible-lint Normal file
View file

@ -0,0 +1,9 @@
use_default_rules: true
exclude_paths:
- venv/
- molecule/default/
- tests/
#skip_list:
# - '301'

9
.gitignore vendored
View file

@ -1 +1,10 @@
*.pyc *.pyc
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

View file

@ -1,18 +1,26 @@
--- ---
sudo: required
language: python language: python
python: python:
- "3.6" - "3.7"
env:
matrix:
- MOLECULE_DISTRO: centos8
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: debian10
- MOLECULE_DISTRO: debian9
- MOLECULE_DISTRO: fedora31
services: services:
- docker - docker
before_install:
- sudo apt-get -qq update
- >
sudo apt-get install -o Dpkg::Options::="--force-confold"
--force-yes -y docker-ce
install: install:
- pip install -r requirements-travis.txt - python -m pip -q install -r requirements-travis.txt
script: script:
- molecule test - molecule test
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ # notifications:
# webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -4,3 +4,8 @@ rules:
line-length: line-length:
max: 100 max: 100
level: warning level: warning
ignore: |
/venv/
/env/
/molecule/

View file

@ -1,14 +0,0 @@
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo git bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel git python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python git sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python git sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo git bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python git sudo bash ca-certificates && xbps-remove -O; fi

View file

@ -1,16 +0,0 @@
*******
Docker driver installation guide
*******
Requirements
============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker
Install
=======
$ sudo pip install docker-py

View file

@ -0,0 +1,9 @@
---
- name: Converge
hosts: all
become: true
roles:
- ansible-role-gitea
vars:
gitea_http_domain: localhost
gitea_root_url: http://localhost

View file

@ -1,32 +1,40 @@
--- ---
dependency: dependency:
name: galaxy name: galaxy
driver: driver:
name: docker name: docker
lint:
name: yamllint lint: |
set -e
yamllint .
ansible-lint
platforms: platforms:
- name: centos7 - name: instance
image: centos:7 image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
- name: debian-stretch pre_build_image: true
image: debian:stretch command: ${MOLECULE_DOCKER_COMMAND:-""}
- name: debian-jessie volumes:
image: debian:jessie - /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: ubuntu-xenial privileged: true
image: ubuntu:xenial
- name: ubuntu-bionic
image: ubuntu:bionic
provisioner: provisioner:
name: ansible name: ansible
lint: playbooks:
name: ansible-lint prepare: prepare.yml
converge: converge.yml
scenario: scenario:
name: default
test_sequence: test_sequence:
- lint - lint
- destroy - destroy
- syntax
- create - create
- prepare
- converge - converge
- verify
- destroy - destroy
verifier: verifier:

View file

@ -1,5 +0,0 @@
---
- name: Converge
hosts: all
roles:
- role: ansible-role-gitea

View file

@ -0,0 +1,22 @@
---
- name: Perpare
hosts: all
become: true
tasks:
- name: install dependencies for gitea (RedHat based systems)
yum:
name: "{{ packages }}"
state: present
update_cache: true
when: ansible_os_family == "RedHat"
- name: install dependencies for gitea (Debian based systems)
apt:
name: "{{ packages }}"
state: present
update_cache: true
when: ansible_os_family == "Debian"
vars:
packages:
- git
- curl

View file

@ -1,14 +1,25 @@
import os import os
import testinfra.utils.ansible_runner import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hosts_file(host): def test_gitea_binary(host):
f = host.file('/etc/hosts') gitea_bin = host.file('/usr/local/bin/gitea')
assert gitea_bin.exists
assert gitea_bin.user == 'root'
assert gitea_bin.group == 'root'
assert f.exists def test_gitea_config_file(host):
assert f.user == 'root' gitea_config = host.file('/etc/gitea/gitea.ini')
assert f.group == 'root' assert gitea_config.exists
assert gitea_config.mode == 0o600
def test_gitea_service_running(host):
gitea = host.service('gitea')
assert gitea.is_running
def test_gitea_reachable(host):
gitea_http = host.run('curl http://localhost:3000')
assert gitea_http.rc == 0

View file

@ -1,62 +1,69 @@
ansible==2.7.12 ansible==2.9.6
ansible-lint==4.1.0 ansible-lint==4.2.0
anyconfig==0.9.7 anyconfig==0.9.7
arrow==0.13.1 arrow==0.15.5
asn1crypto==0.24.0 asn1crypto==0.24.0
atomicwrites==1.3.0 atomicwrites==1.3.0
attrs==19.1.0 attrs==19.1.0
bcrypt==3.1.6 autopep8==1.5.1
bcrypt==3.1.7
binaryornot==0.4.4 binaryornot==0.4.4
Cerberus==1.2 Cerberus==1.3.2
certifi==2019.3.9 certifi==2020.4.5.1
cffi==1.12.2 cffi==1.14.0
chardet==3.0.4 chardet==3.0.4
click==6.7 click==7.1.1
click-completion==0.3.1 click-completion==0.5.2
colorama==0.3.9 click-help-colors==0.8
cookiecutter==1.6.0 colorama==0.4.3
cryptography==2.6.1 cookiecutter==1.7.0
docker==3.7.0 cryptography==2.9
docker==4.2.0
docker-pycreds==0.4.0 docker-pycreds==0.4.0
entrypoints==0.3 entrypoints==0.3
fasteners==0.14.1 fasteners==0.15
flake8==3.7.7 flake8==3.7.7
future==0.17.1 future==0.18.2
git-url-parse==1.2.1 git-url-parse==1.2.1
idna==2.7 idna==2.9
Jinja2==2.10.1 importlib-metadata==1.6.0
Jinja2==2.11.2
jinja2-time==0.2.0 jinja2-time==0.2.0
MarkupSafe==1.1.1 MarkupSafe==1.1.1
mccabe==0.6.1 mccabe==0.6.1
molecule==2.20.1 molecule==3.0.3
monotonic==1.5 monotonic==1.5
more-itertools==6.0.0 more-itertools==6.0.0
paramiko==2.4.2 paramiko==2.7.1
pathspec==0.5.9 pathspec==0.8.0
pbr==5.1.1 pbr==5.1.1
pexpect==4.6.0 pexpect==4.8.0
pluggy==0.9.0 pi==0.1.2
poyo==0.4.2 pluggy==0.13.1
poyo==0.5.0
psutil==5.4.6 psutil==5.4.6
ptyprocess==0.6.0 ptyprocess==0.6.0
py==1.8.0 py==1.8.0
pyasn1==0.4.5 pyasn1==0.4.5
pycodestyle==2.5.0 pycodestyle==2.5.0
pycparser==2.19 pycparser==2.20
pyflakes==2.1.1 pyflakes==2.1.1
PyNaCl==1.3.0 PyNaCl==1.3.0
pytest==4.3.1 pytest==4.3.1
python-dateutil==2.8.0 python-dateutil==2.8.1
python-gilt==1.2.1 python-gilt==1.2.3
PyYAML==5.1 PyYAML==5.3.1
requests==2.21.0 requests==2.23.0
ruamel.yaml==0.15.89 ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
sh==1.12.14 sh==1.12.14
six==1.11.0 shellingham==1.3.2
tabulate==0.8.2 six==1.14.0
testinfra==1.19.0 tabulate==0.8.7
testinfra==5.0.0
tree-format==0.1.2 tree-format==0.1.2
urllib3==1.25.2 urllib3==1.25.8
websocket-client==0.55.0 websocket-client==0.57.0
whichcraft==0.5.2 whichcraft==0.6.1
yamllint==1.11.1 yamllint==1.22.1
zipp==3.1.0

View file

@ -52,6 +52,7 @@
state: started state: started
enabled: true enabled: true
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
ignore_errors: true
- include: fail2ban.yml - include: fail2ban.yml
when: gitea_fail2ban_enabled|bool when: gitea_fail2ban_enabled|bool