Skip to content

Commit

Permalink
kanvas moderation'
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Nov 30, 2021
0 parents commit 67f3d11
Show file tree
Hide file tree
Showing 32 changed files with 3,084 additions and 0 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: "Tests"

# This is a basic workflow this are the triggered

on: [push, pull_request]

jobs:
run-tests:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-18.04
env:
extensions: mbstring, intl, json, phalcon4, mysql, pgsql, xdebug, mongodb, redis
key: cache-v0.0.2
DATA_API_MYSQL_HOST: 127.0.0.1
DATA_API_MYSQL_USER: root
DATA_API_MYSQL_PASS: password
DATA_API_MYSQL_NAME: kanvas_content
WORKFLOW_CORE_PATH: ./
DATA_API_MEMCACHED_HOST: 127.0.0.1
DATA_API_MEMCACHED_PORT: 11211
DATA_API_MEMCACHED_WEIGHT: 100
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
ELASTIC_HOST: 127.0.0.1:9200
APP_IP: api.kanvas.ld
APP_ENV: development
PHINX_CONFIG_DIR: storage
RECOMBEE_PRIVATE_TOKEN: ${{ secrets.RECOMBEE_PRIVATE_TOKEN }}
CANVAS_PHINX_CONFIG_DIR: vendor/canvas/core/storage
services:
mysql:
image: mariadb:10.4
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: kanvas_content
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
rabbitmq:
image: rabbitmq
ports:
- 5672:5672
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
# <port on host>:<port on container>
- 9200:9200
strategy:
fail-fast: false
matrix:
php-versions: ['7.4']
steps:
- uses: actions/checkout@v1

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
tools: pecl

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist --no-suggest

- name: Update Composer dependencies
run: composer update --prefer-dist --no-suggest

- name: Setup Kanvas Env Variable
run: cp storage/ci/.env.example .env

- name: Setup Kanvas Phinx
run: cp vendor/canvas/core/storage/ci/phinx.php.example kanvas-phinx.php

- name: Phinx migrate Kanvas
run: vendor/bin/phinx migrate -c kanvas-phinx.php

- name: Phinx Migrate Kanvas Seed
run: vendor/bin/phinx seed:run -c kanvas-phinx.php

- name: Setup Env Variable
run: cp storage/ci/.env.example .env

- name: Run test
if: success()
run: vendor/bin/codecept run
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Kanvas Content

Provides a set a Contracts and Behaviors for any kanvas app that manages user generated content
61 changes: 61 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

# Can be changed while bootstrapping project
actor_suffix: Tester

paths:
# Where the modules stored
tests: tests
output: tests/_output
# Directory for fixture data
data: tests/_data
# Directory for custom modules (helpers)
support: tests/_support
envs: tests/_envs

bootstrap:
_bootstrap.php

settings:
# The name of bootstrap that will be used.
# Each bootstrap file should be inside a suite directory.
colors: true
# Tests (especially functional) can take a lot of memory
# We set a high limit for them by default.
memory_limit: 128M
log: true

coverage:
enabled: true
remote: false
include:
- ./*.php
exclude:
- phinx.php
- storage/*
- tests/*
- vendor/*

extensions:
enabled:
- Codeception\Extension\RunFailed # default extension

# Global modules configuration.
modules:
config:
Phalcon4:
cleanup: false
savepoints: false
DB:
dsn: 'mysql:host=%WORKFLOW_MYSQL_HOST%;dbname=%WORKFLOW_MYSQL_NAME%'
user: '%WORKFLOW_MYSQL_USER%'
password: '%WORKFLOW_MYSQL_PASS%'
dump: 'tests/_data/dump.sql'
populate: false
cleanup: false
reconnect: true

# Get params from .env file
params:
- .env

error_level: "E_ALL"
50 changes: 50 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "kanvas/moderation",
"description": "Kanvas App Content Moderation Subsystem",
"keywords": [
"kanvas",
"Content",
"user content"
],
"license": "MIT",
"authors": [
{
"name": "Frederick",
"email": "frederickpeal@gmail.com"
}
],
"type": "project",
"require": {
"php": ">= 7.4",
"ext-phalcon": ">=4",
"canvas/core": "^0.3"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.2",
"codeception/module-filesystem": "^1.0",
"codeception/module-phalcon": "^1.0",
"codeception/module-phalcon4": "^1.0",
"codeception/module-rest": "^1.2",
"codeception/verify": "*",
"phalcon/incubator": "4.0.x-dev",
"phalcon/incubator-acl": "^1.0.0-alpha.1",
"phalcon/incubator-test": "^1.0.0-alpha.1",
"robmorgan/phinx": "^0.12",
"fzaninotto/faker": "^1.9",
"vlucas/phpdotenv": "^4.1",
"odan/phinx-migrations-generator": "^5",
"mark-gerarts/auto-mapper-plus": "2.0.0-alpha1",
"squizlabs/php_codesniffer": "3.2",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^9.1",
"phalcon/ide-stubs": "^4.0"
},
"autoload": {
"psr-4": {
"Kanvas\\Moderation\\": "src/",
"Kanvas\\Moderation\\Tests\\Support\\":"tests/_support"

}
}
}
40 changes: 40 additions & 0 deletions phinx.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Dotenv\Dotenv;

$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();

return [
'paths' => [
'migrations' => [
getenv('WORKFLOW_CORE_PATH') . '/storage/db/migrations',
],
'seeds' => [
getenv('WORKFLOW_CORE_PATH') . '/storage/db/seeds',
],
],
'environments' => [
'default_migration_table' => 'ut_migrations',
'default_database' => 'development',
'production' => [
'adapter' => 'mysql',
'host' => getenv('WORKFLOW_MYSQL_HOST'),
'name' => getenv('WORKFLOW_MYSQL_NAME'),
'user' => getenv('WORKFLOW_MYSQL_USER'),
'pass' => getenv('WORKFLOW_MYSQL_PASS'),
'port' => 3306,
'charset' => 'utf8',
],
'development' => [
'adapter' => 'mysql',
'host' => getenv('WORKFLOW_MYSQL_HOST'),
'name' => getenv('WORKFLOW_MYSQL_NAME'),
'user' => getenv('WORKFLOW_MYSQL_USER'),
'pass' => getenv('WORKFLOW_MYSQL_PASS'),
'port' => 3306,
'charset' => 'utf8',
],
],
'version_order' => 'creation',
];
57 changes: 57 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<ruleset name="Phalcon">
<description>Phalcon Coding Standards</description>
<arg value="-colors" />
<arg value="s" />
<rule ref="PSR2">
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>

<!-- 2.3 Lines -->

<!-- The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit. -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120" />
<property name="absoluteLineLimit" value="0" />
</properties>
</rule>

<!-- 2.5 Keywords and True/False/Null -->

<!-- PHP keywords MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseKeyword" />

<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant" />

<!-- Visibility MUST be declared on all methods. -->
<rule ref="Squiz.Scope.MethodScope" />
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />

<!-- 5. Control Structures -->

<!-- The general style rules for control structures are as follows:
There MUST be one space after the control structure keyword
There MUST NOT be a space after the opening parenthesis
There MUST NOT be a space before the closing parenthesis
There MUST be one space between the closing parenthesis and the opening brace
The structure body MUST be indented once
The closing brace MUST be on the next line after the body -->
<rule ref="Squiz.ControlStructures.ControlSignature" />
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace" />
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
<rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
<rule ref="Squiz.ControlStructures.LowercaseDeclaration" />
<!-- checked by PSR2.ControlStructures.ControlStructureSpacing -->

<file>tests/cli</file>
<file>tests/integration</file>
<file>tests/unit</file>
<file>tests/_data/fixtures/Traits</file>
<file>tests/_support/Helper</file>
</ruleset>

0 comments on commit 67f3d11

Please sign in to comment.