diff --git a/.gitignore b/.gitignore index e1cf205905d93c46016f27f9e4df6a1da11cfd86..966ef052e8cb1dfe9ab17eff54ee874231f5dbb0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ .vagrant/ *.log *.retry +.tox diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 233bc80d8f4b0a2ed98f97e33a6269dd6ef0d882..bd9a4d714377ea51d2cd14419ae059cc9307b5d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ - repo: https://github.com/pre-commit/pre-commit-hooks - sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469 + sha: v0.7.1 hooks: - id: check-added-large-files - id: check-json @@ -9,27 +9,15 @@ - id: flake8 - id: check-symlinks - repo: https://github.com/adarnimrod/ansible-pre-commit.git - sha: 0fadd691465b97db8992cfc66650f630e433324b + sha: v0.6.0 hooks: - id: ansible-syntax-check - always_run: true - files: tests/playbook.yml - args: - - tests/playbook.yml - repo: https://github.com/willthames/ansible-lint - sha: 959ab0f525e9abb19cf75f34381015cf33695f61 + sha: v3.4.12 hooks: - id: ansible-lint - always_run: true files: tests/playbook.yml - args: - - tests/playbook.yml -- repo: local +- repo: https://github.com/adarnimrod/python-pre-commit.git + sha: v0.2.0 hooks: - id: piprot - name: piprot - description: Check up-to-date Python requirements - language: system - entry: piprot --quiet --outdated tests/requirements.txt - files: requirements.txt - always_run: true diff --git a/.travis.yml b/.travis.yml index b6502e54a81be24b4c391b7fb5dc4305bb6832a4..988ef0eb14b66b07b454302d6b5d141df9907171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,23 @@ --- language: python -python: ["2.7", "3.4"] +python: "2.7" dist: trusty sudo: True group: beta -services: [docker] env: - - platform: openbsd60 - driver: vagrant - - &openbsd59 platform=openbsd59 driver=vagrant - - driver: docker - platform: all + global: + - VBOX_MEMORY=2048 + matrix: + - TOXENV=pre-commit + - TOXENV=openbsd60 + - TOXENV=trusty + - TOXENV=precise + - &jessie TOXENV=jessie + - TOXENV=wheezy matrix: fast_finish: True allow_failures: - - python: "3.4" - - env: *openbsd59 + - env: *jessie cache: - pip - directories: @@ -26,14 +28,12 @@ install: - sudo apt-get install -y linux-headers-$(uname -r) virtualbox - wget https://releases.hashicorp.com/vagrant/1.9.1/vagrant_1.9.1_x86_64.deb - sudo dpkg -i vagrant_1.9.1_x86_64.deb - - pip install -r tests/requirements.txt | cat - - ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles - - molecule dependency + - pip install tox-travis | cat script: - - pre-commit run --all-files - - molecule test --driver $driver --platform $platform + - travis_wait 45 tox notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ email: false + on_failure: never diff --git a/README.rst b/README.rst index 4092b371f5414db7f2094d08ef7887a960233932..d9c12156efca1c71aa17563bb4adac1ab83ba048 100644 --- a/README.rst +++ b/README.rst @@ -31,22 +31,9 @@ See :code:`tests/playbook.yml`. Testing ------- -Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox. -Install the Python dependencies, dependent roles and roles required for -testing: - -.. code:: shell - - pip install -r tests/requirements.txt - ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles - molecule dependency - -To run the full test suite: - -.. code:: shell - - pre-commit run --all-files - molecule test --platform all +Testing requires Python 2.7, Tox, Vagrant and Virtualbox. To test simply run +:code:`tox`. `Pre-commit <http://pre-commit.com/>`_ is also setup for this +project. License ------- diff --git a/meta/main.yml b/meta/main.yml index 0128bbd828d0fd24f5960474ef97f1d187cf9fb7..e2ed2f797d6bf59047d05adbdeca9ff140340325 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -7,14 +7,15 @@ galaxy_info: platforms: - name: OpenBSD versions: - - 5.9 - 6.0 - name: Ubuntu versions: + - precise - trusty - name: Debian versions: - jessie + - wheezy galaxy_tags: [ php, fpm, fastcgi, http, web ] dependencies: - src: adarnimrod.php5 diff --git a/molecule.yml b/molecule.yml index f730df6f3c03caff662374ccfc2b3c43ec065c20..3707dc98daaf110dab56fd9cad8f5ba9d4a8822f 100644 --- a/molecule.yml +++ b/molecule.yml @@ -5,6 +5,10 @@ ansible: diff: True config_file: ../ansible.cfg +molecule: + ignore_paths: + - .tox + dependency: name: galaxy requirements_file: tests/requirements.yml @@ -18,21 +22,20 @@ vagrant: platforms: - name: openbsd60 box: fnichol/openbsd-6.0-i386 - - name: openbsd59 - box: fnichol/openbsd-5.9-i386 - - name: xenial - box: ubuntu/xenial32 - name: trusty box: ubuntu/trusty32 + - name: precise + box: hashicorp/precise32 - name: jessie - box: debian/jessie32 + box: deb/jessie-i386 - name: wheezy - box: debian/wheezy32 + box: bmorg/debian-wheezy-i386 instances: - name: php-fpm options: append_platform_to_hostname: yes raw_config_args: + - 'vm.boot_timeout = 600' - 'vm.synced_folder ".", "/vagrant", disabled: true' - 'vbguest.auto_update = false if Vagrant.has_plugin?("vbguest")' - 'landrush.enabled = false if Vagrant.has_plugin?("landrush")' @@ -40,45 +43,5 @@ vagrant: - | vm.provider "virtualbox" do |v| v.customize "pre-boot", ["modifyvm", :id, "--hwvirtex", "off"] + v.memory = ENV['VBOX_MEMORY'].to_i if ENV.has_key?('VBOX_MEMORY') end - -docker: - containers: - - name: php-fpm-xenial - image: ubuntu - image_version: xenial - command: /sbin/init - privileged: True - volume_mounts: - - /sys/fs/cgroup:/sys/fs/cgroup - - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket - environment: - DEBIAN_FRONTEND: noninteractive - container: docker - - name: php-fpm-trusty - image: ubuntu-upstart - image_version: trusty - command: /sbin/init - privileged: True - environment: - DEBIAN_FRONTEND: noninteractive - container: docker - - name: php-fpm-jessie - image: debian - image_version: jessie - command: /sbin/init - privileged: True - volume_mounts: - - /sys/fs/cgroup:/sys/fs/cgroup - - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket - environment: - DEBIAN_FRONTEND: noninteractive - container: docker - - name: php-fpm-wheezy - image: debian - image_version: wheezy - command: /sbin/init - privileged: True - environment: - DEBIAN_FRONTEND: noninteractive - container: docker diff --git a/tasks/main.yml b/tasks/main.yml index 59e4350c09e361d7883bd12b34d64d031155d273..c2996383c78270bff95db58c13ecb28844e1f269 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,7 +11,7 @@ - ansible_os_family in php_fpm_validate_config - ansible_os_family in php_fpm_pools_dir - ansible_os_family in php_fpm_user - - ansible_distribution_release in ['6.0', '5.9', 'jessie', 'trusty'] + - ansible_distribution_release in ['jessie', 'trusty'] or ansible_distribution_version in ['6.0'] - ansible_os_family != 'OpenBSD' or ansible_distribution_release in php_fpm_pkg_version - php_fpm_global_config is iterable - php_fpm_www_pool_config is iterable diff --git a/tests/playbook.yml b/tests/playbook.yml index af5468fa0316f4034b737edef3c3ee4a2d4a154e..07c1abbc95ffb5c9608b7c184cdd93539d1c1e02 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -1,11 +1,21 @@ --- - hosts: php-fpm-openbsd* gather_facts: false - roles: [openbsd-bootstrap] + roles: + - openbsd-bootstrap + - role: users + users: [] + users_use_sudo: True + users_lock_root_ssh: False -- hosts: php-fpm-xenial +- hosts: php-fpm-xenial, php-fpm-wheezy gather_facts: false - roles: [debian-bootstrap] + roles: + - debian-bootstrap + - role: users + users: [] + users_use_sudo: True + users_lock_root_ssh: False - hosts: all roles: diff --git a/tests/requirements.txt b/tests/requirements.txt index 1c8ea361c0af0ec637c22c71f1acdb9cd22295a0..c0ffb8cc7e76a09533f8b216ed2374b29e94fdff 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,11 +1,8 @@ -ansible==2.2.0.0 -testinfra==1.5.1 -molecule==1.17.3 -ansible-lint==3.4.9 -pre-commit==0.10.1 -piprot==0.9.7 +ansible==2.3.0.0 +testinfra==1.5.5 +molecule==1.23.2 +ansible-lint==3.4.12 python-vagrant==0.5.14 -docker-py==1.10.6 -netaddr==0.7.18 -passlib==1.7.0 -bcrypt==3.1.2 +netaddr==0.7.19 +passlib==1.7.1 +bcrypt==3.1.3 diff --git a/tests/requirements.yml b/tests/requirements.yml index 161b74a3fa979eaf4d7fa57ed94a4b4371a68ab8..fe471c1661c95ff67e5b82b1fae07ba14c9e4dee 100644 --- a/tests/requirements.yml +++ b/tests/requirements.yml @@ -5,3 +5,5 @@ name: debian-bootstrap - src: adarnimrod.nginx name: nginx +- src: adarnimrod.users + name: users diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..cd0873a5e0615e8dc74819f9051557d358d1d392 --- /dev/null +++ b/tox.ini @@ -0,0 +1,27 @@ +[tox] +skip_install = True +skipsdist = True +envlist = openbsd60,xenial,trusty,precise,stretch,jessie,wheezy + +[testenv] +envdir = {toxinidir}/.tox +deps = -rtests/requirements.txt +passenv = HOME VBOX* ANSIBLE_* +whitelist_externals = + sh +commands = + sh -c "ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles" + molecule test --platform {envname} + +[testenv:pre-commit] +envdir = {toxinidir}/.tox +deps = + -rtests/requirements.txt + pre-commit +passenv = HOME VBOX* ANSIBLE_* +whitelist_externals = + sh +commands = + sh -c "ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles" + molecule dependency + pre-commit run --all-files