Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop #77

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .codepipeline/ec2/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ echo "Running Before Install"

# Install updates.
sudo apt update
sudo apt upgrade -y
DEBIAN_FRONTEND=noninteractive sudo apt upgrade -y
sudo apt autoclean
sudo apt autoremove -y
139 changes: 139 additions & 0 deletions .codepipeline/local-dev/local-dev-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php

//======= Override Main Module Company Parameters ============
Config::set('main.application_name', 'Cmfive');
Config::set('main.company_name', '2pi Software');
Config::set('main.company_url', 'https://2pisoftware.com');
Config::set('main.company_support_email', getenv('SMTP_SENDER') ?: '');

//=============== Timezone ===================================
date_default_timezone_set('Australia/Sydney');
Config::set("system.timezone", "Australia/Sydney");

//========== Database Configuration ==========================
Config::set("database", [
"hostname" => "mysqldb",
"username" => "cmfive",
"password" => "cmfive",
"database" => "cmfive",
"driver" => getenv('DB') ?: "mysql",
"backups" =>
[
'outputExt' => 'sql',
'commandPath' => [
'unix' => '/usr/bin/',
'windows' => '"C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\'
],
'backupCommand' => [
'unix' => 'mysqldump -u $username -h $hostname -P $port -p\'$password\' $dbname > $filename',
'windows' => 'mysqldump.exe" -h$hostname -P$port -u$username -p$password $dbname > $filename'
],
'restoreCommand' => [
'unix' => 'mysql -u $username -h $hostname -P $port -p\'$password\' $dbname < $filename',
'windows' => 'mysql.exe" -D$dbname -h$hostname -P$port -u$username -p$password < $filename'
],
]
]);

Config::set("report.database", [
"hostname" => "mysqldb",
"username" => "cmfivero",
"password" => "cmfivero",
"database" => "cmfive",
"driver" => getenv('DB') ?: "mysql",
]);

//=========== Email Layer Configuration =====================
Config::append('email', [
"layer" => "smtp", // smtp or sendmail or aws
"command" => "", // used for sendmail layer only
"host" => "email-smtp.ap-southeast-2.amazonaws.com",
"port" => 465,
"auth" => true,
"username" => getenv('SMTP_USERNAME') ?: '<email>',
"password" => getenv('SMTP_PASSWORD') ?: '<password>',
]);

//========== TestRunner Configuration ==========================
Config::set("system.environment", "development");
Config::set("core_template.foundation.reveal.animation", "none");
Config::set("core_template.foundation.reveal.animation_speed", 0);
//========== must be "ENABLED" to run ==========================
//========== "config" will pass through to CmfiveSite helper ===
Config::set('system.environment', "development");
Config::set(
"tests",
[
"testrunner" => "ENABLED",
"config" => '',
"yaml" =>
[
"- WebDriver:" =>
[
"url" => "http://webapp:3000",
"browser" => "chrome",
"wait" => "8",
"host" => "seleniumDrv",
"port" => "4444",
"capabilities" =>
[
"acceptInsecureCerts" => true,
"goog:chromeOptions" => [
"w3c" => "false",
"args" => '['
.'"--headless=new","--disable-gpu",'
.'"-proxy-bypass-list=*","--proxy-server=direct://","--dns-prefetch-disable",'
.'"--disk-cache-size=0","–-media-cache-size=0",'
.'"--window-size=1920,1200","--disable-remote-fonts",'
.'"--ignore-certificate-errors","--disable-extensions","--no-sandbox",'
// .'"--enable-logging=/var/customlog/ch.log","--v=1'
.'"--disable-dev-shm-usage"'
.']'
]
]
],
"- Db:" =>
[
"dsn" => "mysql:host=mysqldb:3306;dbname=cmfive",
"user" => "cmfive",
"password" => "cmfive",
],
"- Asserts:" => "",
]
]
);

//========= Anonymous Access ================================
// bypass authentication if sent from the following IP addresses
// specify an IP address and an array of allowed actions from that IP
Config::set("system.allow_from_ip", [
// "10.0.0.0" => array("action1", "action2"),
]);

// or bypass authentication for the following modules
Config::set("system.allow_module", [
// "rest", // uncomment this to switch on REST access to the database objects.
]);

// or bypass authentication for the following actions
Config::set('system.allow_action', [
"auth/login",
"auth/forgotpassword",
"auth/resetpassword",
//"admin/datamigration"
]);

//========= REST Configuration ==============================
// check the following configuration carefully to secure
// access to the REST infrastructure.
//===========================================================

// use the API_KEY to authenticate with username and password
Config::set('system.rest_api_key', "abcdefghijklmnopqrstuvwxyz1234567890");

// include class of objects that you want available via REST
// be aware that only the listed objects will be available via
// the REST API
Config::set('system.rest_include', [
// "Contact"
]);
38 changes: 21 additions & 17 deletions .codepipeline/local-dev/start.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/bash

./test/.install/install.sh

#setup for XDebug

if ping -c 1 host.docker.internal; then INTERNAL_HOST_IP=host.docker.internal; \
else if ping -c 1 docker.for.mac.localhost; then INTERNAL_HOST_IP=docker.for.mac.localhost; \
else if ping -c 1 docker.for.win.localhost; then INTERNAL_HOST_IP=docker.for.win.localhost; \
else INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}'); fi; fi; fi;
# if ping -c 1 host.docker.internal; then INTERNAL_HOST_IP=host.docker.internal; \
# else if ping -c 1 docker.for.mac.localhost; then INTERNAL_HOST_IP=docker.for.mac.localhost; \
# else if ping -c 1 docker.for.win.localhost; then INTERNAL_HOST_IP=docker.for.win.localhost; \
# else INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}'); fi; fi; fi;

# echo "zend_extension=xdebug.so" > /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.mode=debug" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.client_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.client_port=9003" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_connect_back=On" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_handler=dbgp" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_log=/tmp/xdebug.log" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini
# && echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini

echo "zend_extension=xdebug.so" > /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_autostart=1" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_handler=dbgp" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.client_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.mode=debug" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.client_port=9003" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini
&& echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.mode=debug,develop" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.discover_client_host=true" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini

service php8.1-fpm restart

supervisord -n -c /etc/supervisord.conf
2 changes: 1 addition & 1 deletion .codepipeline/test_agent/configs/test_agent-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"url" => "http://webapp:3000",
"browser" => "chrome",
"wait" => "60",
"host" => "selenium314",
"host" => "seleniumDrv",
"port" => "4444",
"capabilities" =>
[
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ name: CI
on: pull_request

jobs:
# WAS: michaelw90/PHP-Lint@master, stuck on docker PHP7.3!
# WORKS for: StephaneBour/actions-php-lint@8.1 = simply "php -l"
phplint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: michaelw90/PHP-Lint@master
- uses: actions/checkout@v3
- uses: overtrue/phplint@5.3.0
php-codesniffer74:
name: PHP CS 7.4
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/storage/session
/log

.phpunit.result.cache

desktop.ini
docker-compose.override.yml
.env
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ php cmfive.php
[select option 3 and fill in the prompts]
```

From there, navigate to [https://localhost:9002](https://localhost:9002) and log in with your admin account
From there, navigate to: [https://localhost:9002](https://localhost:9002) and log in with your admin account.
11 changes: 9 additions & 2 deletions cmfive.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,19 @@ function sketchComposerForCore($reference, $phpVersion)
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 0) {
$reference = "legacy/PHP7.0";
$phpVersion = "7.0";
} else {
$reference = "master";
}
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 4) {
$reference = "legacy/PHP7.4";
$phpVersion = "7.4";
}
if (is_null($reference) || is_null($phpVersion)) {
$reference = is_null($reference) ? "master" : $reference;
$phpVersion = is_null($phpVersion) ? (PHP_MAJOR_VERSION .".". PHP_MINOR_VERSION) : $phpVersion;
}
}

echo ("Composer has ref's as " . $reference . " & " . $phpVersion . ".\n");

$composer_string = <<<COMPOSER
{
"name": "2pisoftware/cmfive-boilerplate",
Expand Down
32 changes: 20 additions & 12 deletions cmfiveTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
defined('HELP_DIRECTORY') || define('HELP_DIRECTORY', DS . 'acceptance' . DS . 'helpers');
defined('UNIT_DIRECTORY') || define('UNIT_DIRECTORY', DS . 'unit');

defined('CEST_DESTINATION') || define('CEST_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'acceptance');
defined('STEP_DESTINATION') || define('STEP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . '_support' . DS . 'Step' . DS . 'Acceptance');
defined('HELP_DESTINATION') || define('HELP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . '_support' . DS . 'Helper');
defined('CEST_DESTINATION') || define('CEST_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Acceptance');
defined('STEP_DESTINATION') || define('STEP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Support' . DS . 'Step' . DS . 'Acceptance');
defined('HELP_DESTINATION') || define('HELP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Support' . DS . 'Helper');
defined('UNIT_DESTINATION') || define('UNIT_DESTINATION', 'test' . DS . 'unit');

defined('SHARED_SOURCE') || define('SHARED_SOURCE', 'boilerplate');
Expand Down Expand Up @@ -56,7 +56,7 @@
'UA_TestConfig' => "tests.config"
];

defined('DEBUG_RUN') || define('DEBUG_RUN', "run --steps --debug acceptance");
defined('DEBUG_RUN') || define('DEBUG_RUN', "run --steps --debug Acceptance");
defined('PHPUNIT_RUN') || define('PHPUNIT_RUN', "");

ini_set('display_errors', 1);
Expand Down Expand Up @@ -297,10 +297,10 @@ function allowRunner()
}
return true;
} else {
echo "Test runner not enabled in config\n";
echo "Test runner not enabled in config\n";
}
} else {
echo "system/web.php not found\n";
echo "system/web.php not found\n";
}
return false;
}
Expand Down Expand Up @@ -424,13 +424,13 @@ function purgeTestCode()
exec('del ' . CEST_DESTINATION . DS . '*Cest.php');
exec('del ' . STEP_DESTINATION . DS . '*.php');
exec('del ' . HELP_DESTINATION . DS . '*.php');
exec('del ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
// exec('del ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
exec('del ' . UNIT_DESTINATION . DS . '*.php');
} else {
exec('rm -f ' . CEST_DESTINATION . DS . '*Cest.php');
exec('rm -f ' . STEP_DESTINATION . DS . '*.php');
exec('rm -f ' . HELP_DESTINATION . DS . '*.php');
exec('rm -f ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
// exec('rm -f ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
exec('rm -f ' . UNIT_DESTINATION . DS . '*.php');
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ function reportModules($moduleCapabilities)

function registerConfig()
{
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "acceptance.suite.dist.yml";
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "Acceptance.suite.dist.yml";
$ConfigYML = fopen($destPath, "w");

if (!$ConfigYML) {
Expand Down Expand Up @@ -511,21 +511,29 @@ function registerHelpers($moduleCapabilities)
// hence could feed test data (CSV,SQL etc)
// $sharedParam & registerBoilerplateParametersmake it work

$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "acceptance.suite.yml";
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "Acceptance.suite.yml";
$HelperYML = fopen($destPath, "w");

if (!$HelperYML) {
return;
}

$hdr = "modules:\n enabled:\n";
$hdr = "actor: CmfiveUI\n"
. "gherkin:\n"
. " contexts:\n"
. " default:\n"
. " - \Tests\Support\AcceptanceTester\n"
. " - \Tests\Support\CmfiveUI\n"
. "modules:\n"
. " enabled:\n";

fwrite($HelperYML, $hdr);

foreach ($moduleCapabilities as $capabilities => $capability) {
if ($capabilities == "Helpers") {
foreach ($capability as $handler => $resources) {
foreach ($resources as $resource) {
fwrite($HelperYML, " - Helper\\" . $resource . ":\n");
fwrite($HelperYML, " - Tests\\Support\\Helper\\" . $resource . ":\n");
// per notes above, can insert required values here...
$from = $moduleCapabilities['Paths'][$handler][0];
$from = substr($from, 0, strpos($from, "acceptance")) . "acceptance" . DS;
Expand Down
Loading