Commit cdcbd1b5 authored by Marcelo Rivera's avatar Marcelo Rivera
Browse files

Merge remote-tracking branch 'upstream/master' into...

Merge remote-tracking branch 'upstream/master' into sprint/HipsterHedgehog.fix.deleting-post-doesnt-delete-it-from-moderated-group-queue
parents 358abfcf 10072639
Loading
Loading
Loading
Loading
+81 −14
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ services:
stages:
  - build
  - test
  - prepare
  - review
  - deploy

cache:
@@ -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:
@@ -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:
+14 −25
Original line number Diff line number Diff line
@@ -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")) {
@@ -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);
+11 −6
Original line number Diff line number Diff line
@@ -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
@@ -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) {
@@ -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;
@@ -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)
+6 −6
Original line number Diff line number Diff line
@@ -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)";

@@ -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';
+1 −1
Original line number Diff line number Diff line
@@ -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);
@@ -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