mirror of
https://github.com/geerlingguy/ansible-role-php.git
synced 2024-11-15 10:35:11 +01:00
88 lines
2.8 KiB
YAML
88 lines
2.8 KiB
YAML
---
|
|
sudo: required
|
|
|
|
env:
|
|
# Only test source install on latest supported OSes.
|
|
- distribution: centos
|
|
version: 7
|
|
init: /usr/lib/systemd/systemd
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
SITE: source
|
|
PHP_VERSION: 7.0.3
|
|
- distribution: ubuntu
|
|
version: 14.04
|
|
init: /sbin/init
|
|
run_opts: ""
|
|
SITE: source
|
|
PHP_VERSION: 7.0.3
|
|
|
|
# Test package install on all supported OSes.
|
|
- distribution: centos
|
|
version: 6
|
|
init: /sbin/init
|
|
run_opts: ""
|
|
SITE: package
|
|
PHP_VERSION: 5.6
|
|
- distribution: centos
|
|
version: 7
|
|
init: /usr/lib/systemd/systemd
|
|
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
SITE: package
|
|
PHP_VERSION: 5.6
|
|
- distribution: ubuntu
|
|
version: 14.04
|
|
init: /sbin/init
|
|
run_opts: ""
|
|
SITE: package
|
|
PHP_VERSION: 5.6
|
|
- distribution: ubuntu
|
|
version: 12.04
|
|
init: /sbin/init
|
|
run_opts: ""
|
|
SITE: package
|
|
PHP_VERSION: 5.6
|
|
|
|
services:
|
|
- docker
|
|
|
|
before_install:
|
|
# - sudo apt-get update
|
|
# Pull container
|
|
- 'sudo docker pull ${distribution}:${version}'
|
|
# Customize container
|
|
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
|
|
|
|
script:
|
|
- container_id=$(mktemp)
|
|
# Run container in detached state
|
|
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
|
|
|
|
# Install dependencies.
|
|
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
|
|
|
|
# Ansible syntax check.
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml --syntax-check'
|
|
|
|
# Test role.
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml'
|
|
|
|
# Test role idempotence.
|
|
- >
|
|
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml
|
|
| grep -q 'changed=0.*failed=0'
|
|
&& (echo 'Idempotence test: pass' && exit 0)
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|
|
|
|
# Ensure PHP is installed and at the right version.
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which php'
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x /usr/bin/php'
|
|
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm php --version'
|
|
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm /usr/bin/php --version | grep -qF "PHP $PHP_VERSION"'
|
|
|
|
# Clean up
|
|
- 'sudo docker stop "$(cat ${container_id})"'
|
|
|
|
notifications:
|
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|