Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5b7fb77
Request ephemeral Hypernode when necessary
tdgroot Sep 12, 2022
58262d3
Add CI testsuite for ephemeral nodes
tdgroot Sep 13, 2022
c96089e
Allow 404 when querying the ephemeral hypernode logbook
tdgroot Sep 13, 2022
4ee2f38
Cleanup ephemeral hypernodes after running
tdgroot Sep 13, 2022
7f35ed5
Add support for openssh private keys
tdgroot Sep 13, 2022
b9c7ff5
Only cancel ephemeral hypernode on failure
tdgroot Sep 13, 2022
b913e28
Set working directory for ephemeral testsuite
tdgroot Sep 13, 2022
c3b64a5
Resolve waiting for ephemeral app only on relevant flows
tdgroot Sep 14, 2022
026d800
Fix always exiting with code 0
tdgroot Sep 14, 2022
9ed9ad4
Update hypernode/api-client
tdgroot Sep 14, 2022
b26a349
ci/ephemeral: remove obsolete env.php copy from source hypernode
tdgroot Sep 14, 2022
fa0bbbb
Merge branch 'master' of github.com:ByteInternet/hypernode-deploy int…
tdgroot Sep 14, 2022
82ec23f
Add deployment reporting
tdgroot Sep 14, 2022
1743ad7
Add Cleanup command for cancelling ephemeral Hypernodes
tdgroot Sep 14, 2022
38abf49
ci/ephemeral: test for deployment report
tdgroot Sep 14, 2022
5c4f7c7
Remove usage version DI variable for report version
tdgroot Sep 14, 2022
f6bd602
Add missing name and description for Cleanup command
tdgroot Sep 14, 2022
7d82205
ci/ephemeral: fix deployment report tests
tdgroot Sep 14, 2022
6ebb15b
ci/ephemeral: verbose and output deployment-report.json
tdgroot Sep 14, 2022
0883799
ci/ephemeral: fix deployment report tests
tdgroot Sep 14, 2022
2aac900
composer: set hypernode/deploy-configuration to v3.x-dev
tdgroot Sep 19, 2022
b1c4a05
DeployRunner: fix imports after configurable interface refactorings
tdgroot Sep 19, 2022
3f7e33b
TaskBuilder: fix imports after configurable interface refactorings
tdgroot Sep 19, 2022
4d61c10
Merge branch 'master' of github.com:ByteInternet/hypernode-deploy int…
tdgroot Sep 19, 2022
18c7bfc
Merge pull request #45 from ByteInternet/create_ephemeral_hypernode
tdgroot Sep 19, 2022
ef959f2
Merge branch 'master' of github.com:ByteInternet/hypernode-deploy int…
tdgroot Sep 19, 2022
225af92
feat: allow for errors in initial window
AlexanderGrooff Sep 19, 2022
5a9e590
typo: excepted -> expected
AlexanderGrooff Sep 20, 2022
6d3fcda
Merge pull request #50 from ByteInternet/allow-error-window
AlexanderGrooff Sep 20, 2022
fd77a20
ci: rename pubkey
tdgroot Sep 20, 2022
8862a9d
Merge remote-tracking branch 'origin/v3' into v3
tdgroot Sep 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@ jobs:
strategy:
matrix:
php_version: [7.4, 8.1]
testsuite: [general, ephemeral]
runs-on: ubuntu-latest
steps:
- name: Checkout hypernode-deploy
uses: actions/checkout@v3
- name: Run test script
run: MAGENTO_REPO=./magento2 ./runtests.sh
shell: bash
env:
PHP_VERSION: ${{ matrix.php_version }}
- name: Checkout hypernode-deploy
uses: actions/checkout@v3
- name: Run general testsuite
if: ${{ matrix.testsuite == 'general' }}
run: MAGENTO_REPO=./magento2 ./runtests.sh general
shell: bash
env:
PHP_VERSION: ${{ matrix.php_version }}
- name: Start SSH agent for ephemeral testsuite
if: ${{ matrix.testsuite == 'ephemeral' && matrix.php_version == '8.1' }}
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Run ephemeral testsuite
if: ${{ matrix.testsuite == 'ephemeral' && matrix.php_version == '8.1' }}
run: ./runtests.sh ephemeral
shell: bash
env:
PHP_VERSION: ${{ matrix.php_version }}
HYPERNODE_API_TOKEN: ${{ secrets.HYPERNODE_API_TOKEN }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
code_quality:
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions ci/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN apt-get update && \
git \
patch \
bash \
jq \
ca-certificates \
wget \
curl \
Expand Down
1 change: 1 addition & 0 deletions ci/hypernode-insecure-deploy-ci-key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDqf5tGbhjIbRQJ40bTvw69z0kUHQEeDtGkX5DTzXJ1IPHcFpbq+nxc3f++45V8FA3fq31xTjCR3+TWy/AGCVmuntVwJVCEaC/U3X0YDscmzAA4LEOfmMHIGnrJdeTJS4+N6L5uIlZqyBIeJXyEEgFpcHm4i1HGm13DR/XG7lTaXSkRI9IVb0i3S0VdrRjtqkg4M3ZjgNfAwmoDE3dGNwIBH5EVy8t/YNj/RH0TNdhTDL3AGwne6h2bTWb5SNLHNXvu2Wc5aiJlvn2E2W7mcpnPxEkVs1AeDEaPHcLaGE2+Bt/I4ntyjOy9pFDcf28sPKj76S3Sq0Wwdb8rYmT+lerIPfjwj1VPXTU1dhvDJ1ffTufp3Sn67qi7NfBMYayYxLJWh9q84RHgYhog2SNXM+autsTU40GDZUtDtORRZ+Rg5i1cGxUCRT+Fpcx3aFCM/yTLvU80qZkmfgkQwKnGCCFygDsXPuFbyRXRz9MI1+lYGg17ufW5HSHrAw34Rw2yd8k= hypernode-deploy-ci
17 changes: 17 additions & 0 deletions ci/test/magento/deploy_ephemeral.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Hypernode\DeployConfiguration;

/**
* Start by setting up the configuration
*
* The magento 2 configuration contains some default configuration for shared folders / files and running installers
* @see ApplicationTemplate\Magento2::initializeDefaultConfiguration
*/

$configuration = new ApplicationTemplate\Magento2(['en_US', 'nl_NL']);

$productionStage = $configuration->addStage('test', 'banaan.store');
$productionStage->addEphemeralServer('hndeployintegr8');

return $configuration;
47 changes: 47 additions & 0 deletions ci/test/run-ephemeral.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -e
set -x

# Handy aliases
HN="ssh app@hndeployintegr8.hypernode.io -o StrictHostKeyChecking=no"
DP="docker run --rm -v /tmp/m2build:/web -e HYPERNODE_API_TOKEN -e SSH_PRIVATE_KEY -w /web hndeploy"

# Build Docker image
docker build \
-f ci/build/Dockerfile \
--build-arg NODE_VERSION=16 \
--build-arg PHP_VERSION="${PHP_VERSION:-8.1}" \
-t hndeploy \
.

# Copy application from remote to local
$HN /data/web/magento2/bin/magento app:config:dump scopes themes
mkdir /tmp/m2build
mkdir -p "$HOME/.ssh"
cp ci/test/magento/deploy_ephemeral.php /tmp/m2build/deploy.php
rsync -a -e "ssh -o StrictHostKeyChecking=no" app@hndeployintegr8.hypernode.io:magento2/ /tmp/m2build
rm /tmp/m2build/app/etc/env.php

# Build application
$DP hypernode-deploy build -f /web/deploy.php -vvv

##########################################
# DEPLOY WITHOUT PLATFORM CONFIGURATIONS #
# This should pass, but not generate any #
# Nginx/Supervisor/etc configs #
##########################################
# SSH from deploy container to hypernode container
$DP hypernode-deploy deploy test -f /web/deploy.php -vvv

# Run some tests

$DP ls -l
$DP test -f deployment-report.json
$DP jq . deployment-report.json
$DP jq .version deployment-report.json -r
$DP jq .stage deployment-report.json -r
$DP jq .hostnames[0] deployment-report.json -r
$DP jq .ephemeral_hypernodes[0] deployment-report.json -r

$DP hypernode-deploy cleanup -vvv
163 changes: 163 additions & 0 deletions ci/test/run-general.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#!/usr/bin/env bash

set -e
set -x

export PHP_VERSION_SHORT=$(echo "${PHP_VERSION:-8.1}" | sed 's/\.//')

# Handy aliases
HN="docker-compose exec -T hypernode"
DP="docker-compose exec -T deploy"
DP1="docker-compose exec --workdir=/web1 -T deploy"
DP2="docker-compose exec --workdir=/web2 -T deploy"

function install_magento() {
$HN mysql -e "DROP DATABASE IF EXISTS dummytag_preinstalled_magento"
$HN mysql -e "CREATE DATABASE dummytag_preinstalled_magento"
local pw=$($HN bash -c "grep password /data/web/.my.cnf | cut -d' ' -f3")

# Strip carriage return of pw and saves it in a new variable
pw=$(echo $pw | tr -d '\r')

$HN bash -c "/data/web/magento2/bin/magento setup:install \
--base-url=http://banaan1.store \
--db-host=mysqlmaster.dummytag.hypernode.io \
--db-name=dummytag_preinstalled_magento --db-user=app \
--db-password=$pw \
--admin-firstname=admin --admin-lastname=admin \
--admin-email=admin@admin.com --admin-user=admin \
--admin-password=admin123 --language=en_US --currency=USD \
--timezone=America/Chicago --elasticsearch-host=localhost"
}

# Install docker-compose if it's not installed
if ! [ -x "$(command -v docker-compose)" ]; then
pip install docker-compose
fi

# Clear up env
trap "docker-compose down -v" EXIT

docker-compose up -d

# Create working initial Magento install on the Hypernode container
$HN composer create-project --repository=https://mage-os.hypernode.com/mirror/ magento/project-community-edition /data/web/magento2
echo "Waiting for MySQL to be available on the Hypernode container"
$HN bash -c "until mysql -e 'select 1' ; do sleep 1; done"
install_magento

# Copy env to the deploy container
$HN /data/web/magento2/bin/magento app:config:dump scopes themes
echo "Waiting for SSH to be available on the Hypernode container"
chmod 0600 ci/test/.ssh/id_rsa
chmod 0600 ci/test/.ssh/authorized_keys
$DP rsync -a app@hypernode:/data/web/magento2/ /web
$DP rsync -v -a /config/ /web
$DP rm /web/app/etc/env.php

# Create second app
$DP cp -ra /web /web1
$DP cp -ra /web /web2

# Build both apps
$DP1 hypernode-deploy build -v -f /web1/deploy1.php
$DP2 hypernode-deploy build -v -f /web2/deploy2.php

# Prepare env
$HN mkdir -p /data/web/apps/banaan1.store/shared/app/etc/
$HN cp /data/web/magento2/app/etc/env.php /data/web/apps/banaan1.store/shared/app/etc/env.php
$HN mkdir -p /data/web/apps/banaan2.store/shared/app/etc/
$HN cp /data/web/magento2/app/etc/env.php /data/web/apps/banaan2.store/shared/app/etc/env.php
$HN chown -R app:app /data/web/apps

##########################################
# DEPLOY WITHOUT PLATFORM CONFIGURATIONS #
# This should pass, but not generate any #
# Nginx/Supervisor/etc configs #
##########################################
# SSH from deploy container to hypernode container
$DP1 hypernode-deploy deploy production -f /web1/deploy1_without_platformconfig.php -v

# Check if deployment made only one release for store1
test $($HN ls /data/web/apps/banaan1.store/releases/ | wc -l) = 1

# Platform configs shouldn't be present yet
$HN test ! -d /data/web/nginx/banaan1.store
$HN test ! -d /data/web/supervisor/banaan1.store
$HN crontab -l -u app | grep "### BEGIN banaan1.store ###" && exit 1
$HN test ! -d /data/web/varnish/banaan1.store

##################
# DEPLOY STORE 2 #
##################
# Store 2
$DP2 hypernode-deploy deploy production -f /web2/deploy2.php -v

# Check if deployment made only one release for store2
test $($HN ls /data/web/apps/banaan2.store/releases/ | wc -l) = 1
$HN ls -al /data/web/nginx/banaan2.store/
$HN ls -al /data/web/apps/banaan2.store/current/
$HN ls -al /data/web/apps/banaan2.store/current/.hypernode/nginx/
$HN test -f /data/web/nginx/banaan2.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan2.store && exit 1)
$HN test $($HN readlink -f /data/web/nginx/banaan2.store) = /data/web/apps/banaan2.store/releases/1/.hypernode/nginx

##################################
# DEPLOY PLATFORM CONFIGURATIONS #
# Now we should get revisions of #
# all platform configs. #
##################################
$DP1 hypernode-deploy deploy production -v -f /web1/deploy1.php

# Check if example location block was placed
$HN ls -al /data/web/nginx/banaan1.store/
$HN ls -al /data/web/apps/banaan1.store/current/
$HN ls -al /data/web/apps/banaan1.store/current/.hypernode/nginx/
$HN test -f /data/web/nginx/banaan1.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan1.store && exit 1)
$HN test $($HN readlink -f /data/web/nginx/banaan1.store) = /data/web/apps/banaan1.store/releases/2/.hypernode/nginx

$HN test -f /data/web/supervisor/banaan1.store/example.conf || ($HN ls -al /data/web/supervisor/ && exit 1)
$HN test $($HN readlink -f /data/web/supervisor/banaan1.store) = /data/web/apps/banaan1.store/releases/2/.hypernode/supervisor

# Test this once we enable supervisor in the hypernode docker image
# $HN supervisorctl status | grep example | grep -v FATAL || ($HN supervisorctl status && exit 1)

# Test if varnish dirs exists and vcl has been placed
$HN ls -al /data/web/varnish/banaan1.store/
$HN ls -al /data/web/apps/banaan1.store/current/.hypernode/varnish/

$HN test -f /data/web/varnish/banaan1.store/varnish.vcl || ($HN ls -al /data/web/varnish/ && exit 1)
$HN test $($HN readlink -f /data/web/varnish/banaan1.store/varnish.vcl) = /data/web/apps/banaan1.store/releases/2/.hypernode/varnish/varnish.vcl

# Check the content of the crontab block
$HN crontab -l -u app | grep "### BEGIN banaan1.store ###"
$HN crontab -l -u app | grep "### END banaan1.store ###"
$HN crontab -l -u app | sed -n -e '/### BEGIN banaan1.store ###/,/### END banaan1.store ###/ p' | grep "banaan"

######################################
# REMOVE A NGINX LOCATION #
# Create a new release but make sure #
# that the file is removed in the #
# new release. #
######################################
# Remove example location
$DP rm /web1/etc/nginx/server.example.conf

# Deploy again
$DP1 hypernode-deploy deploy production -f /web1/deploy1.php

# Check if another deployment was made
test $($HN ls /data/web/apps/banaan1.store/releases/ | wc -l) = 3
$HN test $($HN readlink -f /data/web/nginx/banaan1.store) = /data/web/apps/banaan1.store/releases/3/.hypernode/nginx
$HN test $($HN readlink -f /data/web/supervisor/banaan1.store) = /data/web/apps/banaan1.store/releases/3/.hypernode/supervisor
$HN test $($HN readlink -f /data/web/varnish/banaan1.store/varnish.vcl) = /data/web/apps/banaan1.store/releases/3/.hypernode/varnish/varnish.vcl

# Verify example location block is removed
$HN test ! -f /data/web/nginx/banaan1.store/server.example.conf || ($HN ls -al /data/web/nginx/banaan1.store && exit 1)

# Check if the second application is still working as intended
test $($HN ls /data/web/apps/banaan2.store/releases/ | wc -l) = 1
$HN ls -al /data/web/nginx/banaan2.store/
$HN ls -al /data/web/apps/banaan2.store/current/
$HN ls -al /data/web/apps/banaan2.store/current/.hypernode/nginx/
$HN test -f /data/web/nginx/banaan2.store/server.example.conf || ($HN ls -al /data/web/nginx && $HN ls -al /data/web/nginx/banaan2.store && exit 1)
$HN test $($HN readlink -f /data/web/nginx/banaan2.store) = /data/web/apps/banaan2.store/releases/1/.hypernode/nginx
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"composer-runtime-api": "^2",
"deployer/deployer": "dev-master#e374a8e as v7.0.0",
"doctrine/annotations": "^1.6",
"hypernode/deploy-configuration": "^2.0",
"guzzlehttp/guzzle": "^7.5",
"hypernode/api-client": "dev-master",
"hypernode/deploy-configuration": "v3.x-dev",
"php-di/php-di": "^6.0",
"psr/log": "^1.0",
"symfony/console": "^5.4",
Expand Down
Loading