diff --git a/.gitignore b/.gitignore index 3150878..3fe07ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ \#* .\#* -.venv/ \ No newline at end of file +.venv/ +container-structure-test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index c28f300..b7cd2cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,10 @@ sudo: required language: bash services: - docker + matrix: include: - - env: TEST=limesurvey-apache - script: docker build -t martialblog/limesurvey-apache -f apache/Dockerfile . - - env: TEST=limesurvey-fpm - script: docker build -t martialblog/limesurvey-fpm -f fpm/Dockerfile . + - env: TAG=martialblog/limesurvey-apache + script: docker build -q -t $TAG -f apache/Dockerfile . && tests/run.sh $TAG + - env: TAG=martialblog/limesurvey-fpm + script: docker build -q -t $TAG -f fpm/Dockerfile . && tests/run.sh $TAG diff --git a/tests/image_tests.yaml b/tests/image_tests.yaml new file mode 100644 index 0000000..8a07bda --- /dev/null +++ b/tests/image_tests.yaml @@ -0,0 +1,77 @@ +schemaVersion: "2.0.0" + +globalEnvVars: + - key: "PATH" + value: "/env/bin:$PATH" + +fileContentTests: + - name: 'Limesurvey admin file content' + path: '/var/www/html/admin/index.php' + expectedContents: ['LimeSurvey'] + +fileExistenceTests: + - name: 'Limesurvey files' + path: '/var/www/html/index.php' + shouldExist: true + permissions: '-rw-rw-r--' + - name: 'Limesurvey admin files' + path: '/var/www/html/admin/index.php' + shouldExist: true + permissions: '-rw-rw-r--' + - name: 'Ldap syslink' + path: '/usr/lib/x86_64-linux-gnu/libldap.so' + shouldExist: true + - name: "Dependencies - PHP - gd" + path: '/usr/local/etc/php/conf.d/docker-php-ext-gd.ini' + shouldExist: true + - name: "Dependencies - PHP - imap" + path: '/usr/local/etc/php/conf.d/docker-php-ext-imap.ini' + shouldExist: true + - name: "Dependencies - PHP - ldap" + path: '/usr/local/etc/php/conf.d/docker-php-ext-ldap.ini' + shouldExist: true + - name: "Dependencies - PHP - pgsql" + path: '/usr/local/etc/php/conf.d/docker-php-ext-pgsql.ini' + shouldExist: true + - name: "Dependencies - PHP - zip" + path: '/usr/local/etc/php/conf.d/docker-php-ext-zip.ini' + shouldExist: true + - name: "Dependencies - PHP - sodium" + path: '/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini' + shouldExist: true + - name: "Dependencies - PHP - pdo_mysql" + path: '/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini' + shouldExist: true + - name: "Dependencies - PHP - pdo_pgsql" + path: '/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini' + shouldExist: true + +commandTests: + - name: "Dependencies - libldap2-dev" + command: "dpkg" + args: ["-l", "libldap2-dev"] + exitCode: 0 + - name: "Dependencies - zlib1g-dev" + command: "dpkg" + args: ["-l", "zlib1g-dev"] + exitCode: 0 + - name: "Dependencies - libc-client-dev" + command: "dpkg" + args: ["-l", "libc-client-dev"] + exitCode: 0 + - name: "Dependencies - libkrb5-dev" + command: "dpkg" + args: ["-l", "libkrb5-dev"] + exitCode: 0 + - name: "Dependencies - libpng-dev" + command: "dpkg" + args: ["-l", "libpng-dev"] + exitCode: 0 + - name: "Dependencies - libpq-dev" + command: "dpkg" + args: ["-l", "libpq-dev"] + exitCode: 0 + - name: "Dependencies - PHP Modules" + command: "php" + args: ["-m"] + expectedOutput: ["ldap", "zip", "pdo_mysql", "pdo_sqlite", "gd", "mbstring", "PDO", "imap"] diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..9c59ba8 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +IMAGE=$1 + +if [ ! -f container-structure-test ]; then + curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test + chmod +x container-structure-test +fi + +./container-structure-test test --image $IMAGE --config tests/image_tests.yaml