1
1
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_gitea.git synced 2024-08-16 11:39:50 +02:00

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
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

View file

@ -1,18 +1,26 @@
---
sudo: required
language: 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:
- docker
before_install:
- sudo apt-get -qq update
- >
sudo apt-get install -o Dpkg::Options::="--force-confold"
--force-yes -y docker-ce
install:
- pip install -r requirements-travis.txt
- python -m pip -q install -r requirements-travis.txt
script:
- 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:
max: 100
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:
name: galaxy
driver:
name: docker
lint:
name: yamllint
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: centos7
image: centos:7
- name: debian-stretch
image: debian:stretch
- name: debian-jessie
image: debian:jessie
- name: ubuntu-xenial
image: ubuntu:xenial
- name: ubuntu-bionic
image: ubuntu:bionic
- name: instance
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
prepare: prepare.yml
converge: converge.yml
scenario:
name: default
test_sequence:
- lint
- destroy
- syntax
- create
- prepare
- converge
- verify
- destroy
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 testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hosts_file(host):
f = host.file('/etc/hosts')
def test_gitea_binary(host):
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
assert f.user == 'root'
assert f.group == 'root'
def test_gitea_config_file(host):
gitea_config = host.file('/etc/gitea/gitea.ini')
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-lint==4.1.0
ansible==2.9.6
ansible-lint==4.2.0
anyconfig==0.9.7
arrow==0.13.1
arrow==0.15.5
asn1crypto==0.24.0
atomicwrites==1.3.0
attrs==19.1.0
bcrypt==3.1.6
autopep8==1.5.1
bcrypt==3.1.7
binaryornot==0.4.4
Cerberus==1.2
certifi==2019.3.9
cffi==1.12.2
Cerberus==1.3.2
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==6.7
click-completion==0.3.1
colorama==0.3.9
cookiecutter==1.6.0
cryptography==2.6.1
docker==3.7.0
click==7.1.1
click-completion==0.5.2
click-help-colors==0.8
colorama==0.4.3
cookiecutter==1.7.0
cryptography==2.9
docker==4.2.0
docker-pycreds==0.4.0
entrypoints==0.3
fasteners==0.14.1
fasteners==0.15
flake8==3.7.7
future==0.17.1
future==0.18.2
git-url-parse==1.2.1
idna==2.7
Jinja2==2.10.1
idna==2.9
importlib-metadata==1.6.0
Jinja2==2.11.2
jinja2-time==0.2.0
MarkupSafe==1.1.1
mccabe==0.6.1
molecule==2.20.1
molecule==3.0.3
monotonic==1.5
more-itertools==6.0.0
paramiko==2.4.2
pathspec==0.5.9
paramiko==2.7.1
pathspec==0.8.0
pbr==5.1.1
pexpect==4.6.0
pluggy==0.9.0
poyo==0.4.2
pexpect==4.8.0
pi==0.1.2
pluggy==0.13.1
poyo==0.5.0
psutil==5.4.6
ptyprocess==0.6.0
py==1.8.0
pyasn1==0.4.5
pycodestyle==2.5.0
pycparser==2.19
pycparser==2.20
pyflakes==2.1.1
PyNaCl==1.3.0
pytest==4.3.1
python-dateutil==2.8.0
python-gilt==1.2.1
PyYAML==5.1
requests==2.21.0
ruamel.yaml==0.15.89
python-dateutil==2.8.1
python-gilt==1.2.3
PyYAML==5.3.1
requests==2.23.0
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
sh==1.12.14
six==1.11.0
tabulate==0.8.2
testinfra==1.19.0
shellingham==1.3.2
six==1.14.0
tabulate==0.8.7
testinfra==5.0.0
tree-format==0.1.2
urllib3==1.25.2
websocket-client==0.55.0
whichcraft==0.5.2
yamllint==1.11.1
urllib3==1.25.8
websocket-client==0.57.0
whichcraft==0.6.1
yamllint==1.22.1
zipp==3.1.0

View file

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