Loading .gitlab-ci.yml +81 −14 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ services: stages: - build - test - prepare - review - deploy cache: Loading @@ -27,23 +29,84 @@ build: test: stage: test image: php:7.1.11-fpm-alpine3.4 # TODO: Fix cassandra driver conflicts image: minds/php-tests:latest script: - apk update && apk add libpng-dev freetype-dev libjpeg-turbo-dev - docker-php-ext-install mbstring - docker-php-ext-install bcmath - docker-php-ext-install gd - bin/phpspec run prepare:fpm: stage: prepare image: minds/ci:latest script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF -f containers/php-fpm/Dockerfile . - docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF prepare:runners: stage: prepare image: minds/ci:latest script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF -f containers/php-runners/Dockerfile . - docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF review:start: stage: review image: minds/helm-eks:latest script: - aws eks update-kubeconfig --name=sandbox - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - "helm upgrade \ --install \ --reuse-values \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.tag=$CI_BUILD_REF \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.tag=$CI_BUILD_REF \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --wait \ $CI_BUILD_REF_SLUG \ ./helm-charts/minds" environment: name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN on_stop: review:stop except: refs: - master - test/gitlab-ci review:stop: stage: review image: minds/helm-eks:latest script: - aws eks update-kubeconfig --name=sandbox - helm del --purge $CI_BUILD_REF_SLUG environment: name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN action: stop variables: GIT_STRATEGY: none when: manual except: refs: - master - test/gitlab-ci deploy:fpm: stage: deploy image: docker:latest image: minds/ci:latest script: - apk add --no-cache curl jq python py-pip - pip install awscli - docker build -t $REPOSITORY_URL_FPM -f containers/php-fpm/Dockerfile . - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF # Push to production registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $REPOSITORY_URL_FPM - docker push $REPOSITORY_URL_FPM # Push to gitlab register - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:latest - docker push $CI_REGISTRY_IMAGE/fpm:latest - aws ecs update-service --service=$SERVICE_FPM --force-new-deployment --region us-east-1 --cluster=$CLUSTER only: refs: Loading @@ -54,13 +117,17 @@ deploy:fpm: deploy:runners: stage: deploy image: docker:latest image: minds/ci:latest script: - apk add --no-cache curl jq python py-pip - pip install awscli - docker build -t $REPOSITORY_URL_RUNNERS -f containers/php-runners/Dockerfile . - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF # Push to production register - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $REPOSITORY_URL_RUNNERS - docker push $REPOSITORY_URL_RUNNERS # Push gitlab registry - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest - docker push $CI_REGISTRY_IMAGE/runners:latest - aws ecs update-service --service=$SERVICE_RUNNERS --force-new-deployment --region us-east-1 --cluster=$CLUSTER only: refs: Loading Controllers/Cli/Install.php +14 −25 Original line number Diff line number Diff line Loading @@ -71,34 +71,19 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac $provisioner->reloadStorage(); $this->out('OK'); } } catch (Exception $e) { // REVNOTE: This seems unused, currently. None of the database provisioners currently // throw ProvisionException. We should maybe catch general exceptions (log them) and continue, // and not ProvisionExceptions. I considered removing this altogether, but it is useful to continue // past server errors in an setup. if ($this->getOpt('graceful-storage-provision')) { $this->out($e->getMessage()); $this->out('Error in cassandra setup. Continuing.'); } else { throw $e; } } catch (Exception $ex) { $this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage()); } try { if ($installType == "all" || $installType == "cockroach") { $this->out('- Provisioning Cockroach:', $this::OUTPUT_INLINE); $this->out('- Provisioning Cockroach:'); $isCleanCockroach = $this->getopt("cleanCockroach") != null; $provisioner->provisionCockroach(null, $isCleanCockroach); $this->out('OK'); } } catch (Exception $e) { // See REVNOTE above. if ($this->getOpt('graceful-storage-provision')) { $this->out($e->getMessage()); $this->out('Error in cockroach setup. Continuing.'); } else { throw $e; } } catch (Exception $ex) { $this->out('Something BAD happened while provisioning Cockroach' . $ex->getMessage()); } if (($installType == "all") || ($installType == "site")) { Loading @@ -106,9 +91,13 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac $provisioner->setupSite(); $this->out('OK'); try { $this->out('- Setting up administrative user (ignore warnings, if any):', $this::OUTPUT_INLINE); $provisioner->setupFirstAdmin(); $this->out('OK'); } catch (\Exception $ex) { $this->out('Could not setup initial user'); } } $this->out(['Done!', 'Open your browser and go to ' . $provisioner->getSiteUrl()], $this::OUTPUT_PRE); Loading Controllers/api/v2/admin/firehose.php +11 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Minds\Api\Factory; use Minds\Interfaces; use Minds\Core\Di\Di; use Minds\Core\Session; use Minds\Core; use Minds\Entities\Activity; class firehose implements Interfaces\Api, Interfaces\ApiAdminPam Loading @@ -20,6 +21,9 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam */ public function get($pages) { /** @var User $currentUser */ $currentUser = Core\Session::getLoggedinUser(); $algorithm = $pages[0] ?? null; if (!$algorithm) { Loading @@ -34,18 +38,12 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam case 'activities': $type = 'activity'; break; case 'channels': $type = 'user'; break; case 'images': $type = 'object:image'; break; case 'videos': $type = 'object:video'; break; case 'groups': $type = 'group'; break; case 'blogs': $type = 'object:blog'; break; Loading Loading @@ -113,6 +111,13 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam return Factory::response(['status' => 'error', 'message' => $e->getMessage()]); } if ($type !== 'activity') { /** @var Core\Feeds\Top\Entities $entities */ $entities = new Core\Feeds\Top\Entities(); $entities->setActor($currentUser); $activities = $activities->map([$entities, 'cast']); } return Factory::response([ 'status' => 'success', 'entities' => Exportable::_($activities) Loading Core/Email/Batches/MissedSinceLogin.php +6 −6 Original line number Diff line number Diff line Loading @@ -94,11 +94,11 @@ class MissedSinceLogin implements EmailBatchInterface ->setValue(true) ->setOffset($this->offset); $blogs = $this->getTrendingBlogs(); //$blogs = $this->getTrendingBlogs(); $i = 0; foreach ($iterator as $user) { $user = new \Minds\Entities\User('ottman'); $user = new \Minds\Entities\User('mark'); ++$i; echo "\n[$i]: $user->guid ($iterator->offset)"; Loading @@ -107,13 +107,13 @@ class MissedSinceLogin implements EmailBatchInterface // return true; //} $campaign = new Campaigns\WithBlogs(); $campaign = new Campaigns\MissedSinceLogin(); $campaign ->setUser($user) //->setTemplateKey($this->templatePath) //->setSubject($this->subject) ->setBlogs($blogs) ->setTemplateKey($this->templatePath) ->setSubject($this->subject) //->setBlogs($blogs) ->send(); echo ' sent'; Loading Core/Email/Campaigns/MissedSinceLogin.php +1 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class MissedSinceLogin extends EmailCampaign $this->template->setTemplate('default.tpl'); $this->template->setBody("./Templates/$this->templateKey.tpl"); $this->template->toggleMarkdown(true); $this->template->set('user', $this->user); $this->template->set('username', $this->user->username); Loading @@ -75,7 +76,6 @@ class MissedSinceLogin extends EmailCampaign $this->template->set('entities', $this->entities); $this->user = new \Minds\Entities\User('jack'); $message = new Message(); $message->setTo($this->user) ->setMessageId(implode('-', Loading Loading
.gitlab-ci.yml +81 −14 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ services: stages: - build - test - prepare - review - deploy cache: Loading @@ -27,23 +29,84 @@ build: test: stage: test image: php:7.1.11-fpm-alpine3.4 # TODO: Fix cassandra driver conflicts image: minds/php-tests:latest script: - apk update && apk add libpng-dev freetype-dev libjpeg-turbo-dev - docker-php-ext-install mbstring - docker-php-ext-install bcmath - docker-php-ext-install gd - bin/phpspec run prepare:fpm: stage: prepare image: minds/ci:latest script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF -f containers/php-fpm/Dockerfile . - docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF prepare:runners: stage: prepare image: minds/ci:latest script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF -f containers/php-runners/Dockerfile . - docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF review:start: stage: review image: minds/helm-eks:latest script: - aws eks update-kubeconfig --name=sandbox - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - "helm upgrade \ --install \ --reuse-values \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.tag=$CI_BUILD_REF \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.tag=$CI_BUILD_REF \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --wait \ $CI_BUILD_REF_SLUG \ ./helm-charts/minds" environment: name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN on_stop: review:stop except: refs: - master - test/gitlab-ci review:stop: stage: review image: minds/helm-eks:latest script: - aws eks update-kubeconfig --name=sandbox - helm del --purge $CI_BUILD_REF_SLUG environment: name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN action: stop variables: GIT_STRATEGY: none when: manual except: refs: - master - test/gitlab-ci deploy:fpm: stage: deploy image: docker:latest image: minds/ci:latest script: - apk add --no-cache curl jq python py-pip - pip install awscli - docker build -t $REPOSITORY_URL_FPM -f containers/php-fpm/Dockerfile . - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF # Push to production registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $REPOSITORY_URL_FPM - docker push $REPOSITORY_URL_FPM # Push to gitlab register - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:latest - docker push $CI_REGISTRY_IMAGE/fpm:latest - aws ecs update-service --service=$SERVICE_FPM --force-new-deployment --region us-east-1 --cluster=$CLUSTER only: refs: Loading @@ -54,13 +117,17 @@ deploy:fpm: deploy:runners: stage: deploy image: docker:latest image: minds/ci:latest script: - apk add --no-cache curl jq python py-pip - pip install awscli - docker build -t $REPOSITORY_URL_RUNNERS -f containers/php-runners/Dockerfile . - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF # Push to production register - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $REPOSITORY_URL_RUNNERS - docker push $REPOSITORY_URL_RUNNERS # Push gitlab registry - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest - docker push $CI_REGISTRY_IMAGE/runners:latest - aws ecs update-service --service=$SERVICE_RUNNERS --force-new-deployment --region us-east-1 --cluster=$CLUSTER only: refs: Loading
Controllers/Cli/Install.php +14 −25 Original line number Diff line number Diff line Loading @@ -71,34 +71,19 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac $provisioner->reloadStorage(); $this->out('OK'); } } catch (Exception $e) { // REVNOTE: This seems unused, currently. None of the database provisioners currently // throw ProvisionException. We should maybe catch general exceptions (log them) and continue, // and not ProvisionExceptions. I considered removing this altogether, but it is useful to continue // past server errors in an setup. if ($this->getOpt('graceful-storage-provision')) { $this->out($e->getMessage()); $this->out('Error in cassandra setup. Continuing.'); } else { throw $e; } } catch (Exception $ex) { $this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage()); } try { if ($installType == "all" || $installType == "cockroach") { $this->out('- Provisioning Cockroach:', $this::OUTPUT_INLINE); $this->out('- Provisioning Cockroach:'); $isCleanCockroach = $this->getopt("cleanCockroach") != null; $provisioner->provisionCockroach(null, $isCleanCockroach); $this->out('OK'); } } catch (Exception $e) { // See REVNOTE above. if ($this->getOpt('graceful-storage-provision')) { $this->out($e->getMessage()); $this->out('Error in cockroach setup. Continuing.'); } else { throw $e; } } catch (Exception $ex) { $this->out('Something BAD happened while provisioning Cockroach' . $ex->getMessage()); } if (($installType == "all") || ($installType == "site")) { Loading @@ -106,9 +91,13 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac $provisioner->setupSite(); $this->out('OK'); try { $this->out('- Setting up administrative user (ignore warnings, if any):', $this::OUTPUT_INLINE); $provisioner->setupFirstAdmin(); $this->out('OK'); } catch (\Exception $ex) { $this->out('Could not setup initial user'); } } $this->out(['Done!', 'Open your browser and go to ' . $provisioner->getSiteUrl()], $this::OUTPUT_PRE); Loading
Controllers/api/v2/admin/firehose.php +11 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Minds\Api\Factory; use Minds\Interfaces; use Minds\Core\Di\Di; use Minds\Core\Session; use Minds\Core; use Minds\Entities\Activity; class firehose implements Interfaces\Api, Interfaces\ApiAdminPam Loading @@ -20,6 +21,9 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam */ public function get($pages) { /** @var User $currentUser */ $currentUser = Core\Session::getLoggedinUser(); $algorithm = $pages[0] ?? null; if (!$algorithm) { Loading @@ -34,18 +38,12 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam case 'activities': $type = 'activity'; break; case 'channels': $type = 'user'; break; case 'images': $type = 'object:image'; break; case 'videos': $type = 'object:video'; break; case 'groups': $type = 'group'; break; case 'blogs': $type = 'object:blog'; break; Loading Loading @@ -113,6 +111,13 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam return Factory::response(['status' => 'error', 'message' => $e->getMessage()]); } if ($type !== 'activity') { /** @var Core\Feeds\Top\Entities $entities */ $entities = new Core\Feeds\Top\Entities(); $entities->setActor($currentUser); $activities = $activities->map([$entities, 'cast']); } return Factory::response([ 'status' => 'success', 'entities' => Exportable::_($activities) Loading
Core/Email/Batches/MissedSinceLogin.php +6 −6 Original line number Diff line number Diff line Loading @@ -94,11 +94,11 @@ class MissedSinceLogin implements EmailBatchInterface ->setValue(true) ->setOffset($this->offset); $blogs = $this->getTrendingBlogs(); //$blogs = $this->getTrendingBlogs(); $i = 0; foreach ($iterator as $user) { $user = new \Minds\Entities\User('ottman'); $user = new \Minds\Entities\User('mark'); ++$i; echo "\n[$i]: $user->guid ($iterator->offset)"; Loading @@ -107,13 +107,13 @@ class MissedSinceLogin implements EmailBatchInterface // return true; //} $campaign = new Campaigns\WithBlogs(); $campaign = new Campaigns\MissedSinceLogin(); $campaign ->setUser($user) //->setTemplateKey($this->templatePath) //->setSubject($this->subject) ->setBlogs($blogs) ->setTemplateKey($this->templatePath) ->setSubject($this->subject) //->setBlogs($blogs) ->send(); echo ' sent'; Loading
Core/Email/Campaigns/MissedSinceLogin.php +1 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ class MissedSinceLogin extends EmailCampaign $this->template->setTemplate('default.tpl'); $this->template->setBody("./Templates/$this->templateKey.tpl"); $this->template->toggleMarkdown(true); $this->template->set('user', $this->user); $this->template->set('username', $this->user->username); Loading @@ -75,7 +76,6 @@ class MissedSinceLogin extends EmailCampaign $this->template->set('entities', $this->entities); $this->user = new \Minds\Entities\User('jack'); $message = new Message(); $message->setTo($this->user) ->setMessageId(implode('-', Loading