-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from ByteInternet/v3
- Loading branch information
Showing
21 changed files
with
2,237 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected] | ||
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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ RUN apt-get update && \ | |
git \ | ||
patch \ | ||
bash \ | ||
jq \ | ||
ca-certificates \ | ||
wget \ | ||
curl \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] -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" [email protected]: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ | ||
[email protected] --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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.