Split GitHub Actions workflows

This commit is contained in:
cytopia 2019-11-23 13:01:12 +01:00
parent b5ed81e28a
commit 3551c89311
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
7 changed files with 560 additions and 50 deletions

207
.github/workflows/ci-smoke-linux.yml vendored Normal file
View File

@ -0,0 +1,207 @@
---
# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: Linux
# -------------------------------------------------------------------------------------------------
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:
# Runs on master Branch and Tags
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+*'
# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
smoke_linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
httpd:
- "apache-2.2"
- "apache-2.4"
- "nginx-stable"
- "nginx-mainline"
name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}]"
steps:
# ------------------------------------------------------------
# Checkout repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v1
- name: Show environment
shell: bash
run: |
env
- name: Show network
shell: bash
run: |
netstat -an || true
ss -tlun || true
- name: Show Docker version
shell: bash
run: |
docker version
# ------------------------------------------------------------
# Setup
# ------------------------------------------------------------
- name: Configure
shell: bash
run: |
cd .tests/
# Set the two candidates to test against
make configure KEY=PHP_SERVER VAL=${PHP}
make configure KEY=HTTPD_SERVER VAL=${HTTPD}
# 3306 is taken, so chose another one
make configure KEY=HOST_PORT_MYSQL VAL=3307
env:
PHP: ${{ matrix.php }}
HTTPD: ${{ matrix.httpd }}
- name: Pull images
shell: bash
run: |
cd .tests/
make pull
- name: Startup
shell: bash
run: |
cd .tests/
make start
- name: Docker logs
shell: bash
run: |
cd .tests/
make logs
# ------------------------------------------------------------
# Run tests
# ------------------------------------------------------------
- name: Test Modules
shell: bash
run: |
cd .tests/
make test-smoke-modules
if: success() || failure()
- name: Test Config
shell: bash
run: |
cd .tests/
make test-smoke-config
if: success() || failure()
- name: Test Intranet
shell: bash
run: |
cd .tests/
make test-smoke-intranet
if: success() || failure()
- name: Test Vendors
shell: bash
run: |
cd .tests/
make test-smoke-vendors
if: success() || failure()
- name: Test Vhosts
shell: bash
run: |
cd .tests/
make test-smoke-vhosts
if: success() || failure()
- name: Test Reverse Proxy
shell: bash
run: |
cd .tests/
make test-smoke-rproxies
if: success() || failure()
- name: Test SSL
shell: bash
run: |
cd .tests/
make test-smoke-ssl
if: success() || failure()
- name: Test Bind
shell: bash
run: |
cd .tests/
make test-smoke-bind
if: success() || failure()
- name: Test Autostart
shell: bash
run: |
cd .tests/
make test-smoke-autostart
if: success() || failure()
- name: "Test Framework: CakePHP"
shell: bash
run: |
cd .tests/
make test-smoke-framework-cakephp
if: success() || failure()
- name: "Test Framework: Drupal"
shell: bash
run: |
cd .tests/
make test-smoke-framework-drupal
if: success() || failure()
- name: "Test Framework: Wordpress"
shell: bash
run: |
cd .tests/
make test-smoke-framework-wordpress
if: success() || failure()
# ------------------------------------------------------------
# Finish
# ------------------------------------------------------------
- name: "Finish: Docker logs"
shell: bash
run: |
cd .tests/
make logs
if: success() || failure()

262
.github/workflows/ci-smoke-macos.yml.off vendored Normal file
View File

@ -0,0 +1,262 @@
---
# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: MacOS
# -------------------------------------------------------------------------------------------------
# When to run
# -------------------------------------------------------------------------------------------------
on:
# Runs on Pull Requests
pull_request:
# Runs on master Branch and Tags
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+*'
# -------------------------------------------------------------------------------------------------
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
smoke_macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
php:
- "7.2"
httpd:
- "nginx-stable"
name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}]"
steps:
# ------------------------------------------------------------
# Checkout repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v1
- name: "[Pre] Install Requirements"
shell: bash
run: |
brew install coreutils
brew install bash
brew install socat
- name: "[Pre] Install Docker"
shell: bash
run: |
brew install docker docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
while ! docker-machine create --driver xhyve default; do
docker-machine rm -f default
sleep 1;
done
# Export variable (this target)
eval "$(docker-machine env default)"
DOCKER_TLS_VERIFY="$( docker-machine env default | grep DOCKER_TLS_VERIFY | sed -e 's/.*="//g' -e 's/"$//g' )"
DOCKER_HOST="$( docker-machine env default | grep DOCKER_HOST | sed -e 's/.*="//g' -e 's/"$//g' )"
DOCKER_CERT_PATH="$( docker-machine env default | grep DOCKER_CERT_PATH | sed -e 's/.*="//g' -e 's/"$//g' )"
DOCKER_MACHINE_NAME="$( docker-machine env default | grep DOCKER_MACHINE_NAME | sed -e 's/.*="//g' -e 's/"$//g' )"
# Export variable (this other targets)
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#set-an-environment-variable-set-env
echo ::set-env name=DOCKER_TLS_VERIFY::${DOCKER_TLS_VERIFY}
echo ::set-env name=DOCKER_HOST::${DOCKER_HOST}
echo ::set-env name=DOCKER_CERT_PATH::${DOCKER_CERT_PATH}
echo ::set-env name=DOCKER_MACHINE_NAME::${DOCKER_MACHINE_NAME}
# Show info
docker-machine ls
docker-machine env default
docker version
- name: "[Pre] Install Docker Compose"
shell: bash
run: |
sudo curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
- name: "[Pre] Setup Docker machine"
shell: bash
run: |
# Setup DNS records
echo "127.0.0.1 localhost" | sudo tee -a /etc/hosts
# Portforwarding from DOCKER_HOST to local
HOST="$( echo "${DOCKER_HOST}" | sed -e 's|^tcp://||g' -e 's|:.*||g' )"
echo "${HOST}"
sudo socat -s -d -d tcp-listen:80,reuseaddr,fork tcp:${HOST}:80 &
sleep 2
sudo socat -s -d -d tcp-listen:443,reuseaddr,fork tcp:${HOST}:443 &
sleep 2
if ! netstat -an | grep -i LISTEN | grep -E '(:80)|(\.80)\s'; then
netstat -an | grep -i LISTEN;
false;
fi
if ! netstat -an | grep -i LISTEN | grep -E '(:443)|(\.443)\s'; then
netstat -an | grep -i LISTEN;
false;
fi
host localhost
curl -sS -I 'http://localhost:80' || true
curl -sS -I 'https://localhost:443' || true
- name: "[Info] Show environment"
shell: bash
run: |
env
if: success() || failure()
- name: "[Info] Show network"
shell: bash
run: |
netstat -an || true
ss -tlun || true
if: success() || failure()
# ------------------------------------------------------------
# Setup
# ------------------------------------------------------------
- name: Configure
shell: bash
run: |
cd .tests/
# Set the two candidates to test against
make configure KEY=PHP_SERVER VAL=${PHP}
make configure KEY=HTTPD_SERVER VAL=${HTTPD}
# 3306 is taken, so chose another one
make configure KEY=HOST_PORT_MYSQL VAL=3307
env:
PHP: ${{ matrix.php }}
HTTPD: ${{ matrix.httpd }}
if: success() || failure()
- name: Pull images
shell: bash
run: |
cd .tests/
make pull
if: success() || failure()
- name: Startup
shell: bash
run: |
cd .tests/
make start
if: success() || failure()
- name: Docker logs
shell: bash
run: |
cd .tests/
make logs
if: success() || failure()
# ------------------------------------------------------------
# Run tests
# ------------------------------------------------------------
- name: Test Modules
shell: bash
run: |
cd .tests/
make test-smoke-modules
if: success() || failure()
- name: Test Config
shell: bash
run: |
cd .tests/
make test-smoke-config
if: success() || failure()
- name: Test Intranet
shell: bash
run: |
cd .tests/
make test-smoke-intranet
if: success() || failure()
- name: Test Vendors
shell: bash
run: |
cd .tests/
make test-smoke-vendors
if: success() || failure()
- name: Test Vhosts
shell: bash
run: |
cd .tests/
make test-smoke-vhosts
if: success() || failure()
- name: Test Reverse Proxy
shell: bash
run: |
cd .tests/
make test-smoke-rproxies
if: success() || failure()
- name: Test SSL
shell: bash
run: |
cd .tests/
make test-smoke-ssl
if: success() || failure()
- name: Test Bind
shell: bash
run: |
cd .tests/
make test-smoke-bind
if: success() || failure()
- name: Test Autostart
shell: bash
run: |
cd .tests/
make test-smoke-autostart
if: success() || failure()
- name: "Test Framework: CakePHP"
shell: bash
run: |
cd .tests/
make test-smoke-framework-cakephp
if: success() || failure()
- name: "Test Framework: Drupal"
shell: bash
run: |
cd .tests/
make test-smoke-framework-drupal
if: success() || failure()
- name: "Test Framework: Wordpress"
shell: bash
run: |
cd .tests/
make test-smoke-framework-wordpress
if: success() || failure()
# ------------------------------------------------------------
# Finish
# ------------------------------------------------------------
- name: "[Post] Docker logs"
shell: bash
run: |
cd .tests/
make logs
if: success() || failure()

View File

@ -3,7 +3,7 @@
# -------------------------------------------------------------------------------------------------
# Job Name
# -------------------------------------------------------------------------------------------------
name: PHP-HTTPD
name: Config
# -------------------------------------------------------------------------------------------------
@ -25,7 +25,7 @@ on:
# What to run
# -------------------------------------------------------------------------------------------------
jobs:
smoke_php_httpd:
test_config:
runs-on: ubuntu-latest
@ -48,11 +48,8 @@ jobs:
- "apache-2.4"
- "nginx-stable"
- "nginx-mainline"
config:
- "default"
- "custom"
name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}] (${{ matrix.config }})"
name: "[PHP ${{ matrix.php }}] vs [${{ matrix.httpd }}]"
steps:
# ------------------------------------------------------------
@ -91,24 +88,21 @@ jobs:
make configure KEY=HOST_PORT_MYSQL VAL=3307
# Test full customization
if [ "${CONFIG}" = "custom" ]; then
make configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
make configure KEY=DOCKER_LOGS VAL="$(( RANDOM % 1 ))"
make configure KEY=TLD_SUFFIX VAL=loc2
make configure KEY=TIMEZONE VAL='Europe/Berlin'
make configure KEY=PHP_MODULES_DISABLE VAL=
make configure KEY=HTTPD_TEMPLATE_DIR VAL=.config
make configure KEY=HOST_PORT_HTTPD VAL=8080
make configure KEY=HOST_PORT_HTTPD_SSL VAL=8443
make configure KEY=MYSQL_ROOT_PASSWORD VAL=mysqlpass
make configure KEY=PGSQL_ROOT_USER VAL=pgroot
make configure KEY=PGSQL_ROOT_PASSWORD VAL=pgsqlpass
make configure KEY=DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN VAL=0
fi
make configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
make configure KEY=DOCKER_LOGS VAL="$(( RANDOM % 1 ))"
make configure KEY=TLD_SUFFIX VAL=loc2
make configure KEY=TIMEZONE VAL='Europe/Berlin'
make configure KEY=PHP_MODULES_DISABLE VAL=
make configure KEY=HTTPD_TEMPLATE_DIR VAL=.config
make configure KEY=HOST_PORT_HTTPD VAL=8080
make configure KEY=HOST_PORT_HTTPD_SSL VAL=8443
make configure KEY=MYSQL_ROOT_PASSWORD VAL=mysqlpass
make configure KEY=PGSQL_ROOT_USER VAL=pgroot
make configure KEY=PGSQL_ROOT_PASSWORD VAL=pgsqlpass
make configure KEY=DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN VAL=0
env:
PHP: ${{ matrix.php }}
HTTPD: ${{ matrix.httpd }}
CONFIG: ${{ matrix.config }}
- name: Pull images
shell: bash

View File

@ -146,25 +146,23 @@ run() {
local yellow="\\033[0;33m"
local reset="\\033[0m"
# Set command
if [ -n "${workdir}" ]; then
cmd="set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"
else
cmd="set -e && set -u && set -o pipefail && ${cmd}"
fi
# Print command?
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${yellow}%s \$${reset} %s\\n" "$(whoami)" "${cmd}"
fi
for ((i=0; i<retries; i++)); do
if [ -n "${workdir}" ]; then
if bash -c "set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
fi
else
if bash -c "set -e && set -u && set -o pipefail && ${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
if eval "${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
fi
sleep 1
done
@ -203,25 +201,23 @@ run_fail() {
local yellow="\\033[0;33m"
local reset="\\033[0m"
# Set command
if [ -n "${workdir}" ]; then
cmd="set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"
else
cmd="set -e && set -u && set -o pipefail && ${cmd}"
fi
# Print command?
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${yellow}%s \$${reset} %s\\n" "$(whoami)" "${cmd}"
fi
for ((i=0; i<retries; i++)); do
if [ -n "${workdir}" ]; then
if ! bash -c "set -e && set -u && set -o pipefail && cd ${workdir} && ${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
fi
else
if ! bash -c "set -e && set -u && set -o pipefail && ${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
if ! eval "${cmd}"; then
if [ "${verbose}" -eq "1" ]; then
>&2 printf "${green}[%s: in %s rounds]${reset}\\n" "OK" "$((i+1))"
fi
return 0
fi
sleep 1
done

View File

@ -24,4 +24,46 @@ fi
# ENTRYPOINT
# -------------------------------------------------------------------------------------------------
echo
echo "# --------------------------------------------------------------------------------"
echo "# docker-compose logs"
echo "# --------------------------------------------------------------------------------"
run "docker-compose logs || true" "1" "${DVLBOX_PATH}"
echo
echo "# --------------------------------------------------------------------------------"
echo "# docker-compose ps"
echo "# --------------------------------------------------------------------------------"
run "docker-compose ps || true" "1" "${DVLBOX_PATH}"
echo
echo "# --------------------------------------------------------------------------------"
echo "# Devilbox logs"
echo "# --------------------------------------------------------------------------------"
# shellcheck disable=SC2044
for file in $( find "${DVLBOX_PATH}/log" -type f ); do
dirname="$( basename "$( dirname "${file}" )" )"
filename="$( basename "${file}" )"
echo
echo "# ------------------------------------------------------------"
echo "# [${dirname}] ${filename}"
echo "# ------------------------------------------------------------"
cat "${file}"
echo
done
echo
echo "# --------------------------------------------------------------------------------"
echo "# mounts httpd"
echo "# --------------------------------------------------------------------------------"
run "docker-compose exec -T httpd ls -lap /shared/httpd/ || true" "1" "${DVLBOX_PATH}"
echo
echo "# --------------------------------------------------------------------------------"
echo "# mounts php"
echo "# --------------------------------------------------------------------------------"
run "docker-compose exec -T php ls -lap /shared/httpd/ || true" "1" "${DVLBOX_PATH}"

View File

@ -47,13 +47,21 @@ run "docker-compose up -d" "1" "${DVLBOX_PATH}"
###
printf "Waiting for HTTP 200 "
i=0
until curl -sS -o /dev/null -I -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}" 2>/dev/null | grep '200' >/dev/null; do
until curl -sS -I --fail -o /dev/null -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}" 2>/dev/null | grep '200' >/dev/null; do
printf "."
i=$(( i + 1 ))
if [ "${i}" -eq "60" ]; then
printf "[FAIL]\\n\\n"
curl -o /dev/null -I -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}"
echo "---- curl From host ----"
curl -sS -v "http://localhost:${HOST_PORT_HTTPD}" || true
curl -sS -I "http://localhost:${HOST_PORT_HTTPD}" || true
curl -sS -I -o /dev/null -w "%{http_code}" "http://localhost:${HOST_PORT_HTTPD}" || true
echo
echo "---- curl From PHP container ----"
run "docker-compose exec -T --user devilbox php curl -sS -v 'http://localhost/'" "1" "${DVLBOX_PATH}" || true
run "docker-compose exec -T --user devilbox php curl -sS -I 'http://localhost/'" "1" "${DVLBOX_PATH}" || true
run "docker-compose exec -T --user devilbox php curl -sS -I -o /dev/null -w '%{http_code}' 'http://localhost/'" "1" "${DVLBOX_PATH}" || true
exit 1
fi
@ -73,7 +81,8 @@ until curl -sS --fail "http://localhost:${HOST_PORT_HTTPD}" 2>/dev/null | grep '
i=$(( i + 1 ))
if [ "${i}" -eq "60" ]; then
printf "[FAIL]\\n"
curl -sS "http://localhost:${HOST_PORT_HTTPD}"
curl -sS -v "http://localhost:${HOST_PORT_HTTPD}"
curl -sS -I "http://localhost:${HOST_PORT_HTTPD}"
exit 1
fi