Skip to content

Commit 9f88d83

Browse files
author
James Cori
committed
Merge branch 'ci-test' into develop
2 parents f343de2 + b97a789 commit 9f88d83

File tree

21 files changed

+3366
-101
lines changed

21 files changed

+3366
-101
lines changed

.circleci/config.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/python:2.7-stretch-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip install awscli --upgrade
10+
sudo pip install docker-compose
11+
install_deploysuite: &install_deploysuite
12+
name: Installation of install_deploysuite.
13+
command: |
14+
git clone --branch v1.4 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
cp ./../buildscript/master_deploy.sh .
16+
cp ./../buildscript/buildenv.sh .
17+
cp ./../buildscript/awsconfiguration.sh .
18+
restore_cache_settings_for_build: &restore_cache_settings_for_build
19+
key: docker-node-modules-{{ checksum "package-lock.json" }}
20+
21+
save_cache_settings: &save_cache_settings
22+
key: docker-node-modules-{{ checksum "package-lock.json" }}
23+
paths:
24+
- node_modules
25+
26+
builddeploy_steps: &builddeploy_steps
27+
- checkout
28+
- setup_remote_docker
29+
- run: *install_dependency
30+
- run: *install_deploysuite
31+
#- restore_cache: *restore_cache_settings_for_build
32+
- run: ./build.sh ${APPNAME} ${CI_DEPLOY_TOKEN}
33+
#- save_cache: *save_cache_settings
34+
- deploy:
35+
name: Running MasterScript.
36+
command: |
37+
./awsconfiguration.sh $DEPLOY_ENV
38+
source awsenvconf
39+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
40+
source buildenvvar
41+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
42+
43+
44+
jobs:
45+
# Build & Deploy against development backend
46+
"build-dev":
47+
<<: *defaults
48+
environment:
49+
DEPLOY_ENV: "DEV"
50+
LOGICAL_ENV: "dev"
51+
APPNAME: "vanilla-forums"
52+
CI_DEPLOY_TOKEN: $CI_DEPLOY_TOKEN
53+
steps: *builddeploy_steps
54+
55+
"build-prod":
56+
<<: *defaults
57+
environment:
58+
DEPLOY_ENV: "PROD"
59+
LOGICAL_ENV: "prod"
60+
APPNAME: "vanilla-forums"
61+
CI_DEPLOY_TOKEN: $CI_DEPLOY_TOKEN
62+
steps: *builddeploy_steps
63+
64+
workflows:
65+
version: 2
66+
build:
67+
jobs:
68+
# Development builds are executed on "develop" branch only.
69+
- "build-dev":
70+
context : org-global
71+
filters:
72+
branches:
73+
only:
74+
- develop
75+
76+
# Production builds are exectuted only on tagged commits to the
77+
# master branch.
78+
- "build-prod":
79+
context : org-global
80+
filters:
81+
branches:
82+
only: master

Dockerfile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM webdevops/php-apache
22

3+
ARG CI_DEPLOY_TOKEN
34
ARG VANILLA_VERSION=3.3
45
ENV WEB_DOCUMENT_ROOT /vanillapp
56

@@ -13,12 +14,35 @@ RUN chmod -R 777 /vanillapp
1314
RUN rm -R /vanillapp/plugins/stubcontent
1415
# Clone the forum-plugins repository
1516
RUN git clone https://github.com/topcoder-platform/forums-plugins.git /tmp/forums-plugins
17+
# Copy the Filestack plugin
18+
RUN git clone https://${CI_DEPLOY_TOKEN}@github.com/topcoder-platform/forums-filestack-plugin /tmp/forums-plugins/Filestack
19+
20+
#Copy the Groups plugin
21+
RUN git clone https://${CI_DEPLOY_TOKEN}@github.com/topcoder-platform/forums-groups-plugin /tmp/forums-plugins/Groups
22+
23+
#Copy the SumoLogic plugin
24+
RUN git clone https://${CI_DEPLOY_TOKEN}@github.com/topcoder-platform/forums-sumologic-plugin /tmp/forums-plugins/Sumologic
25+
1626
# Copy all plugins to the Vanilla plugins folder
1727
RUN cp -r /tmp/forums-plugins/. /vanillapp/plugins
28+
29+
#Get the debug bar plugin
30+
RUN wget https://us.v-cdn.net/5018160/uploads/addons/KSBIPJYMC0F2.zip
31+
RUN unzip KSBIPJYMC0F2.zip
32+
RUN cp -r debugbar /vanillapp/plugins
33+
34+
# Install Topcoder dependencies
35+
RUN composer install --working-dir /vanillapp/plugins/Topcoder
36+
# Install Filestack dependencies
37+
RUN composer install --working-dir /vanillapp/plugins/Filestack
38+
# Install Groups dependencies
39+
RUN composer install --working-dir /vanillapp/plugins/Groups
1840
# Copy Vanilla configuration files
1941
COPY ./config/vanilla/. /vanillapp/conf/.
2042
# Copy Topcoder Vanilla files
2143
COPY ./vanilla/. /vanillapp/.
22-
44+
# Set permissions on config file
45+
RUN chown application:application /vanillapp/conf/config.php
46+
RUN chmod ug=rwx,o=rx /vanillapp/conf/config.php
2347
# Clone the forum-theme repository
24-
RUN git clone 'https://github.com/topcoder-platform/forums-theme.git' /vanillapp/themes/topcoder-theme
48+
RUN git clone 'https://github.com/topcoder-platform/forums-theme.git' /vanillapp/themes/topcoder-theme

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
APP_NAME=$1
4+
CI_DEPLOY_TOKEN=$2
5+
UPDATE_CACHE=""
6+
echo "" > vanilla.env
7+
CI_DEPLOY_TOKEN=$CI_DEPLOY_TOKEN docker-compose -f docker-compose.yml build $APP_NAME
8+
#docker create --name app $APP_NAME:latest

config/vanilla/bootstrap.before.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,12 @@ function _formatStringCallback($match, $setArgs = false) {
257257
// Store this name separately because of special 'You' case.
258258
$name = formatUsername($user, $format, $contextUserID);
259259
// Manually build instead of using userAnchor() because of special 'You' case.
260-
if(function_exists('topcoderRatingCssClass')) {
260+
if(function_exists('topcoderRatingCssClass') &&
261+
function_exists('topcoderRoleCssStyles')) {
261262
$ratingCssClass = topcoderRatingCssClass($user->Name);
262-
$result = anchor(htmlspecialchars($name), userUrl($user), $ratingCssClass);
263+
$roleCssClass = topcoderRoleCssStyles($user->Name);
264+
$topcoderStyles =$ratingCssClass.' '.$roleCssClass;
265+
$result = anchor(htmlspecialchars($name), userUrl($user), $topcoderStyles);
263266
} else {
264267
$result = anchor(htmlspecialchars($name), userUrl($user));
265268
}

config/vanilla/bootstrap.early.php

Lines changed: 81 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,75 @@
44
$Database = Gdn::database();
55
$SQL = $Database->sql();
66

7-
// DB settings
8-
saveToConfig('Database.Host', getenv('DB_HOSTNAME'), false);
9-
saveToConfig('Database.Name', getenv('DB_DATABASE'), false);
10-
saveToConfig('Database.User', getenv('DB_USERNAME'), false);
11-
saveToConfig('Database.Password', getenv('DB_PASSWORD'), false);
12-
13-
saveToConfig('Garden.Email.SupportName', getenv('MAIL_FROM_NAME'), false);
14-
saveToConfig('Garden.Email.SupportAddress', getenv('MAIL_FROM_ADDRESS'), false);
15-
saveToConfig('Garden.Email.UseSmtp', getenv('MAIL_USE_SMTP'), false);
16-
saveToConfig('Garden.Email.SmtpHost', getenv('MAIL_SMTP_HOSTNAME'), false);
17-
saveToConfig('Garden.Email.SmtpUser', getenv('MAIL_SMTP_USERNAME'), false);
18-
saveToConfig('Garden.Email.SmtpPassword', getenv('MAIL_SMTP_PASSWORD'), false);
19-
saveToConfig('Garden.Email.SmtpPort', getenv('MAIL_SMTP_PORT'), false);
20-
saveToConfig('Garden.Email.SmtpSecurity', getenv('MAIL_SMTP_SECURITY'), false);
21-
22-
//Disable plugins
23-
saveToConfig('EnabledPlugins.stubcontent', false);
24-
25-
//Enable plugins
26-
saveToConfig('EnabledPlugins.Topcoder', true);
27-
saveToConfig('EnabledPlugins.rich-editor',true);
28-
saveToConfig('EnabledPlugins.recaptcha', true);
29-
saveToConfig('EnabledPlugins.editor', true);
30-
saveToConfig('EnabledPlugins.emojiextender', true);
31-
saveToConfig('EnabledPlugins.GooglePrettify', true);
32-
saveToConfig('EnabledPlugins.Quotes', true);
33-
saveToConfig('EnabledPlugins.swagger-ui', true);
34-
saveToConfig('EnabledPlugins.oauth2', true);
35-
36-
// Set Theme Options
37-
saveToConfig('Garden.ThemeOptions.Styles.Key', 'Coral');
38-
saveToConfig('Garden.ThemeOptions.Styles.Value', '%s_coral');
39-
saveToConfig('Garden.ThemeOptions.Options.panelToLeft',true);
7+
// Cache Settings
8+
saveToConfig('Cache.Enabled', getenv('CACHE_ENABLED'), true);
9+
saveToConfig('Cache.Method', getenv('CACHE_METHOD'), 'dirtycache');
10+
saveToConfig('memcached.Store', getenv('MEMCACHED_SERVER'), 'localhost:11211');
11+
12+
saveToConfig('Garden.Email.SupportName', getenv('MAIL_FROM_NAME') );
13+
saveToConfig('Garden.Email.SupportAddress', getenv('MAIL_FROM_ADDRESS'));
14+
saveToConfig('Garden.Email.UseSmtp', getenv('MAIL_USE_SMTP'));
15+
saveToConfig('Garden.Email.SmtpHost', getenv('MAIL_SMTP_HOSTNAME'));
16+
saveToConfig('Garden.Email.SmtpUser', getenv('MAIL_SMTP_USERNAME'));
17+
saveToConfig('Garden.Email.SmtpPassword', getenv('MAIL_SMTP_PASSWORD'));
18+
saveToConfig('Garden.Email.SmtpPort', getenv('MAIL_SMTP_PORT'));
19+
saveToConfig('Garden.Email.SmtpSecurity', getenv('MAIL_SMTP_SECURITY'));
20+
21+
// Appearance
22+
saveToConfig('Garden.Theme', 'topcoder-theme', false);
23+
saveToConfig('Garden.MobileTheme', 'topcoder-theme', false);
24+
saveToConfig('Feature.NewFlyouts.Enabled', true);
4025

4126
// Profile settings
4227
saveToConfig('Garden.Profile.EditPhotos', false);
4328

4429
// Add settings for the Topcoder plugin
45-
if(c('Plugins.Topcoder.BaseApiURL') === false) {
46-
saveToConfig('Plugins.Topcoder.BaseApiURL', getenv('TOPCODER_PLUGIN_BASE_API_URL'), false);
47-
saveToConfig('Plugins.Topcoder.MemberApiURI', getenv('TOPCODER_PLUGIN_MEMBER_API_URI'), false);
48-
saveToConfig('Plugins.Topcoder.RoleApiURI', getenv('TOPCODER_PLUGIN_ROLE_API_URI'), false);
49-
saveToConfig('Plugins.Topcoder.MemberProfileURL', getenv('TOPCODER_PLUGIN_MEMBER_PROFILE_URL'), false);
30+
saveToConfig('Plugins.Topcoder.BaseApiURL', getenv('TOPCODER_PLUGIN_BASE_API_URL'),false);
31+
saveToConfig('Plugins.Topcoder.MemberApiURI', getenv('TOPCODER_PLUGIN_MEMBER_API_URI'),false);
32+
saveToConfig('Plugins.Topcoder.RoleApiURI', getenv('TOPCODER_PLUGIN_ROLE_API_URI'),false);
33+
saveToConfig('Plugins.Topcoder.ResourceRolesApiURI', '/v5/resource-roles', false);
34+
saveToConfig('Plugins.Topcoder.ResourcesApiURI', '/v5/resources', false);
35+
saveToConfig('Plugins.Topcoder.MemberProfileURL', 'https://www.topcoder-dev.com/members',false); // prod: getenv('TOPCODER_PLUGIN_MEMBER_PROFILE_URL')
36+
saveToConfig('Plugins.Topcoder.UseTopcoderAuthToken', getenv('TOPCODER_PLUGIN_USE_AUTH_TOKEN'),false);
37+
38+
saveToConfig('Plugins.Topcoder.ValidIssuers', str_replace(["[", "]", "\\", "\"", " "], '', getenv('VALID_ISSUERS')));
39+
40+
//Add settings for Topcoder M2M Auth0
41+
saveToConfig('Plugins.Topcoder.M2M.Auth0Audience','https://m2m.topcoder-dev.com/'); // getenv('AUTH0_AUDIENCE')
42+
saveToConfig('Plugins.Topcoder.M2M.Auth0ClientId', getenv('AUTH0_CLIENT_ID'));
43+
saveToConfig('Plugins.Topcoder.M2M.Auth0ClientSecret', getenv('AUTH0_CLIENT_SECRET'));
44+
saveToConfig('Plugins.Topcoder.M2M.Auth0Url', getenv('AUTH0_URL'));
45+
saveToConfig('Plugins.Topcoder.M2M.Auth0ProxyServerUrl', getenv('AUTH0_PROXY_SERVER_URL'));
46+
47+
//Add settings for Topcoder SSO Auth0
48+
saveToConfig('Plugins.Topcoder.SSO.Auth0Domain', 'https://api.topcoder-dev.com');
49+
saveToConfig('Plugins.Topcoder.SSO.AuthorizationURI', '/v3/authorizations/1');
50+
saveToConfig('Plugins.Topcoder.SSO.CookieName', 'v3jwt',false);
51+
saveToConfig('Plugins.Topcoder.SSO.TopcoderRS256.ID', 'BXWXUWnilVUPdN01t2Se29Tw2ZYNGZvH');
52+
saveToConfig('Plugins.Topcoder.SSO.TopcoderHS256.ID', 'JFDo7HMkf0q2CkVFHojy3zHWafziprhT');
53+
saveToConfig('Plugins.Topcoder.SSO.TopcoderHS256.Secret', getenv('TOPCODER_HS256_SECRET') );
54+
saveToConfig('Plugins.Topcoder.SSO.TopcoderRS256.UsernameClaim', 'nickname',false);
55+
saveToConfig('Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim', 'handle',false);
56+
$topcoderSSOAuth0Url = 'https://accounts-auth0.topcoder-dev.com/';
57+
saveToConfig('Plugins.Topcoder.SSO.RefreshTokenURL', $topcoderSSOAuth0Url,false);
58+
$signInUrl = getenv('TOPCODER_PLUGIN_SIGNIN_URL');
59+
$signOutUrl = getenv('TOPCODER_PLUGIN_SIGNOUT_URL');
60+
if($signInUrl === false) {
61+
$signInUrl =$topcoderSSOAuth0Url.'?retUrl='.urlencode('https://'.$_SERVER['SERVER_NAME'].'/');
5062
}
63+
if($signOutUrl === false) {
64+
$signOutUrl =$topcoderSSOAuth0Url.'?logout=true&retUrl='.urlencode('https://'.$_SERVER['SERVER_NAME'].'/');
65+
}
66+
saveToConfig('Plugins.Topcoder.AuthenticationProvider.SignInUrl', $signInUrl,false);
67+
saveToConfig('Plugins.Topcoder.AuthenticationProvider.SignOutUrl', $signOutUrl,false);
68+
saveToConfig('Plugins.Topcoder.AuthenticationProvider.RegisterUrl', 'https://www.topcoder-dev.com/user-selection/',false);
69+
70+
// Filestack
71+
saveToConfig('Plugins.Filestack.ApiKey', getenv('FILESTACK_API_KEY'),false);
72+
73+
// SumoLogic
74+
saveToConfig('Plugins.Sumologic.HttpSourceURL', '',false);
75+
saveToConfig('Plugins.Sumologic.BatchSize', '10',false);
5176

5277
// Add settings for the Editor plugin
5378
if(c('Plugins.editor.ForceWysiwyg') === false) {
@@ -68,66 +93,29 @@
6893
saveToConfig('Recaptcha.PublicKey', getenv('RECAPTCHA_PLUGIN_PUBLIC_KEY'), false);
6994
}
7095

71-
// Add settings for the OAuth 2 SSO plugin
72-
if ($SQL->getWhere('UserAuthenticationProvider', ['AuthenticationKey' => 'oauth2'])->numRows() == 0) {
73-
$attributes = array(
74-
'AssociationKey'=> getenv('TOPCODER_AUTH0_ASSOCIATION_KEY'),
75-
'AuthorizeUrl'=> getenv('TOPCODER_AUTH0_AUTHORIZE_URL'),
76-
'TokenUrl'=> getenv('TOPCODER_AUTH0_TOKEN_URL'),
77-
'AcceptedScope'=> getenv('TOPCODER_AUTH0_ACCEPTED_SCOPE'),
78-
'ProfileKeyEmail'=> getenv('TOPCODER_AUTH0_PROFILE_KEY_EMAIL'),
79-
'ProfileKeyPhoto'=> getenv('TOPCODER_AUTH0_PROFILE_KEY_PHOTO'),
80-
'ProfileKeyName'=> getenv('TOPCODER_AUTH0_PROFILE_KEY_NAME'),
81-
'ProfileKeyFullName'=> getenv('TOPCODER_AUTH0_PROFILE_KEY_FULL_NAME'),
82-
'ProfileKeyUniqueID'=> getenv('TOPCODER_AUTH0_PROFILE_KEY_UNIQUE_ID'),
83-
'Prompt'=> getenv('TOPCODER_AUTH0_PROMPT'),
84-
'BearerToken'=> getenv('TOPCODER_AUTH0_BEARER_TOKEN'),
85-
'BaseUrl'=> getenv('TOPCODER_AUTH0_BASE_URL')
86-
);
96+
97+
// Fix: OAuth 2 SSO should be inactive and not by default. It should be removed later.
98+
if ($SQL->getWhere('UserAuthenticationProvider', ['AuthenticationKey' => 'oauth2'])->numRows() > 0) {
99+
$SQL->update('UserAuthenticationProvider')
100+
->set('Active', 0)
101+
->set('IsDefault',0)
102+
->where('AuthenticationKey' , 'oauth2')->put();
103+
}
104+
105+
// Add Topcoder User Authentication Provider.
106+
// SignInUrl/SignOutUrl should be set in Topcoder plugin's setup; otherwise they couldn't be updated in DB
107+
if ($SQL->getWhere('UserAuthenticationProvider', ['AuthenticationKey' => 'topcoder'])->numRows() == 0) {
87108
$SQL->insert('UserAuthenticationProvider', [
88-
'AuthenticationKey' => 'oauth2',
89-
'AuthenticationSchemeAlias' => 'oauth2',
90-
'Name' => 'oauth2',
91-
'AssociationSecret' => getenv('TOPCODER_AUTH0_SECRET'),
92-
'RegisterUrl' => getenv('TOPCODER_AUTH0_REGISTER_URL'),
93-
'SignInUrl' => getenv('TOPCODER_AUTH0_SIGNIN_URL'),
94-
'SignOutUrl' => getenv('TOPCODER_AUTH0_SIGNOUT_URL'),
95-
'ProfileUrl' => getenv('TOPCODER_AUTH0_PROFILE_URL'),
96-
'Attributes' => json_encode($attributes,JSON_UNESCAPED_SLASHES),
109+
'AuthenticationKey' => 'topcoder',
110+
'AuthenticationSchemeAlias' => 'topcoder',
111+
'Name' => 'topcoder',
97112
'Active' => 1,
98113
'IsDefault' => 1
99114
]);
100115
}
101116

102-
// Define Topcoder Member role
103-
$topcoderRoleName = 'Topcoder Member';
104-
if($SQL->getWhere('Role', ['Name' => $topcoderRoleName])->numRows() == 0) {
105-
$roleID = $SQL->insert('Role', [
106-
'Name' => $topcoderRoleName,
107-
'Type' => 'member',
108-
'Deletable' => 0,
109-
'CanSession' => 1,
110-
'PersonalInfo' => 1,
111-
'Description' => 'Topcoder Members can edit Notification Preferences and participate in discussions.'
112-
]);
113-
114-
// Define the set of permissions to singIn, view Profiles and edit Notification Preferences
115-
$SQL->insert('Permission', [
116-
'RoleID' => $roleID,
117-
'`Garden.SignIn.Allow`' => 1,
118-
'`Garden.Profiles.View`' => 1,
119-
'`Garden.PersonalInfo.View`' => 1,
120-
'`Garden.AdvancedNotifications.Allow`' => 1
121-
]);
122-
123-
// Define the set of permissions to view categories
124-
$SQL->insert('Permission', [
125-
'RoleID' => $roleID,
126-
'JunctionTable' => 'Category',
127-
'JunctionColumn' => 'PermissionCategoryID',
128-
'JunctionID' => -1,
129-
'`Vanilla.Discussions.View`' => 1
130-
]);
131-
}
117+
// Fix: Add the 'topcoder' role type in Role Table. It should be removed after upgrading existing DB.
118+
// The Topcoder plugin's setup method will upgrade DB during Vanilla installation
119+
$SQL->query('alter table GDN_Role modify Type enum(\'topcoder\', \'guest\', \'unconfirmed\', \'applicant\', \'member\', \'moderator\', \'administrator\')');
132120

133121
}

0 commit comments

Comments
 (0)