mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-04-21 14:02:09 +07:00
Travis CI with vagrant + docker
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
FROM williamyeh/ansible:debian8-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh", "5.6"]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM williamyeh/ansible:debian8-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh", "7.0"]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM williamyeh/ansible:debian8-onbuild
|
||||
|
||||
RUN apt-get update
|
||||
CMD ["sh", "tests/test.sh", "7.1"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
php_version: '5.6'
|
||||
@@ -1 +0,0 @@
|
||||
php_version: '7.0'
|
||||
7
tests/includes/dotdeb.yml
Normal file
7
tests/includes/dotdeb.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: APT | Install DotDeb key
|
||||
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
|
||||
|
||||
- name: APT | Add Dotdeb repository
|
||||
apt_repository: repo='deb http://packages.dotdeb.org {{ ansible_distribution_release }} all' state=present
|
||||
7
tests/includes/sury.yml
Normal file
7
tests/includes/sury.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: APT | Install Sury key
|
||||
apt_key: url='https://packages.sury.org/php/apt.gpg' state=present
|
||||
|
||||
- name: APT | Add Sury repository
|
||||
apt_repository: repo='deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main' state=present
|
||||
@@ -1,7 +0,0 @@
|
||||
localhost
|
||||
|
||||
[php-5.6]
|
||||
localhost
|
||||
|
||||
[php-7.0]
|
||||
localhost
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
|
||||
|
||||
DIR=$( dirname $0 )
|
||||
PLAYBOOK="$DIR/test.yml"
|
||||
ANSIBLE_ARG="localhost"
|
||||
|
||||
set -ev
|
||||
|
||||
ansible --version
|
||||
|
||||
# Check syntax
|
||||
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
|
||||
|
||||
# Check role
|
||||
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK
|
||||
|
||||
# Check indempotence
|
||||
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK \
|
||||
| grep -q 'changed=0.*failed=0' \
|
||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
@@ -13,28 +13,16 @@
|
||||
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
|
||||
with_items: ['apt-transport-https', 'curl', 'lsb-release', 'ca-certificates']
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install DotDeb key
|
||||
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
|
||||
|
||||
- name: APT | Add Dotdeb repository for Jessie + PHP7
|
||||
apt_repository: repo='deb http://packages.dotdeb.org jessie all' state=present
|
||||
|
||||
- name: INCLUDE | Dotdeb
|
||||
include: includes/dotdeb.yml
|
||||
when: >
|
||||
ansible_distribution_major_version | version_compare(8, 'eq') and
|
||||
php_version | version_compare('7.0', 'eq')
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install Sury key
|
||||
apt_key: url='https://packages.sury.org/php/apt.gpg' state=present
|
||||
|
||||
- name: APT | Add Dotdeb repository for Jessie + PHP7
|
||||
apt_repository: repo='deb https://packages.sury.org/php/ jessie main' state=present
|
||||
|
||||
- name: INCLUDE | Sury
|
||||
include: includes/sury.yml
|
||||
when: >
|
||||
ansible_distribution_major_version | version_compare(8, 'eq') and
|
||||
ansible_distribution_major_version | version_compare(9, 'le') and
|
||||
php_version | version_compare('7.1', 'eq')
|
||||
|
||||
- name: APT | Install nginx
|
||||
@@ -82,7 +70,7 @@
|
||||
copy: dest=/var/www/phpinfo.php content='<?php phpinfo();'
|
||||
|
||||
- name: SHELL | Check vhost
|
||||
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version [57].*<' | sed -r 's/<//g'"
|
||||
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version {{ php_version }}' | sed -r 's/<//g'"
|
||||
args:
|
||||
warn: false
|
||||
changed_when: false
|
||||
|
||||
Reference in New Issue
Block a user