Skip to content

Commit 6cc3383

Browse files
committed
Merge branch 'master' into production for v1.36.0
1 parent 6256954 commit 6cc3383

5 files changed

Lines changed: 205 additions & 120 deletions

File tree

.circleci/config.yml

Lines changed: 71 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -52,71 +52,80 @@ jobs:
5252
- attach_workspace:
5353
at: workspace
5454
- gcp-cli/install
55-
- run: sudo docker-php-ext-install pdo_mysql
56-
- run: |
57-
cd workspace
58-
# record version
59-
echo "CircleCI build number:${CIRCLE_BUILD_NUM}
60-
Git hash: ${CIRCLE_SHA1}
61-
${CIRCLE_TAG+Release: ${CIRCLE_TAG}}" > assets/version.txt
62-
# generate config file
63-
echo "<?php
64-
\$settings['version'] = '${CIRCLE_BUILD_NUM}';
65-
${CIRCLE_TAG+\$settings['release'] = '${CIRCLE_TAG}';}
66-
\$settings['db_socket'] = '/cloudsql/${BOXWISE_PRIMARYDB_SOCKET}';
67-
\$settings['db_database'] = '${<< parameters.envVariablePrefix >>DBNAME}';
68-
\$settings['db_user'] = '${<< parameters.envVariablePrefix >>DBNAME}';
69-
\$settings['db_pass'] = '${<< parameters.envVariablePrefix >>DBPASS}';
70-
\$settings['sentry_key'] = '${BOXWISE_SENTRY}';
71-
\$settings['test_pwd'] = '${CYPRESS_TEST_PWD}';
72-
\$settings['upload_dir'] = '${UPLOAD_DIR}/<< parameters.serviceName >>';
73-
\$settings['auth0_domain'] = '${<< parameters.envVariablePrefix >>AUTH0_DOMAIN}';
74-
\$settings['auth0_api_id'] = '${<< parameters.envVariablePrefix >>AUTH0_API_ID}';
75-
\$settings['auth0_api_domain'] = '${<< parameters.envVariablePrefix >>AUTH0_API_DOMAIN}';
76-
\$settings['auth0_api_audience'] = '${<< parameters.envVariablePrefix >>AUTH0_API_AUDIENCE}';
77-
\$settings['auth0_client_id'] = '${<< parameters.envVariablePrefix >>AUTH0_CLIENT_ID}';
78-
\$settings['auth0_db_connection_id'] = '${<< parameters.envVariablePrefix >>AUTH0_DB_CONNECTION_ID}';
79-
\$settings['auth0_client_secret'] = '${<< parameters.envVariablePrefix >>AUTH0_CLIENT_SECRET}';
80-
\$settings['auth0_cookie_secret'] = '${<< parameters.envVariablePrefix >>AUTH0_COOKIE_SECRET}';
81-
\$settings['auth0_redirect_uri'] = '${<< parameters.envVariablePrefix >>AUTH0_REDIRECT_URI}';
82-
\$settings['v2_base_url'] = '${<< parameters.envVariablePrefix >>V2_BASE_URL}';
83-
\$settings['jwt_claim_prefix'] = 'https://www.boxtribute.com';" > library/config.php
84-
echo "paths:
85-
migrations: '%%PHINX_CONFIG_DIR%%/db/migrations'
86-
environments:
87-
default_migration_table: phinxlog
88-
<< parameters.serviceName >>:
89-
adapter: mysql
90-
host: 127.0.0.1
91-
name: ${<< parameters.envVariablePrefix >>DBNAME}
92-
user: ${<< parameters.envVariablePrefix >>DBNAME}
93-
pass: ${<< parameters.envVariablePrefix >>DBPASS}
94-
port: 3306
95-
charset: utf8
96-
mysql_attr_init_command: SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'
97-
version_order: creation" > phinx.yml
98-
# generate google app engine config for target environment
99-
sed 's/service: default/service: << parameters.serviceName >>/g' app.yaml > app-<< parameters.serviceName >>.yaml
100-
if [ << parameters.serviceName >> == production ]; then echo -e "\ninstance_class: F2" >> app-production.yaml; fi;
101-
- run: |
102-
# get google credentials
103-
echo $GOOGLE_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
104-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
105-
# download cloud sql proxy to enable db access
106-
curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64
107-
chmod +x cloud_sql_proxy
10855
- run:
56+
name: Install deploy dependencies
57+
command: sudo docker-php-ext-install pdo_mysql
58+
- run:
59+
name: Generate config.php and phinx.yml files
60+
command: |
61+
cd workspace
62+
# record version
63+
echo "CircleCI build number:${CIRCLE_BUILD_NUM}
64+
Git hash: ${CIRCLE_SHA1}
65+
${CIRCLE_TAG+Release: ${CIRCLE_TAG}}" > assets/version.txt
66+
# generate config file
67+
echo "<?php
68+
\$settings['version'] = '${CIRCLE_BUILD_NUM}';
69+
${CIRCLE_TAG+\$settings['release'] = '${CIRCLE_TAG}';}
70+
\$settings['db_socket'] = '/cloudsql/${BOXWISE_PRIMARYDB_SOCKET}';
71+
\$settings['db_database'] = '${<< parameters.envVariablePrefix >>DBNAME}';
72+
\$settings['db_user'] = '${<< parameters.envVariablePrefix >>DBNAME}';
73+
\$settings['db_pass'] = '${<< parameters.envVariablePrefix >>DBPASS}';
74+
\$settings['sentry_key'] = '${BOXWISE_SENTRY}';
75+
\$settings['test_pwd'] = '${CYPRESS_TEST_PWD}';
76+
\$settings['upload_dir'] = '${UPLOAD_DIR}/<< parameters.serviceName >>';
77+
\$settings['auth0_domain'] = '${<< parameters.envVariablePrefix >>AUTH0_DOMAIN}';
78+
\$settings['auth0_api_id'] = '${<< parameters.envVariablePrefix >>AUTH0_API_ID}';
79+
\$settings['auth0_api_domain'] = '${<< parameters.envVariablePrefix >>AUTH0_API_DOMAIN}';
80+
\$settings['auth0_api_audience'] = '${<< parameters.envVariablePrefix >>AUTH0_API_AUDIENCE}';
81+
\$settings['auth0_client_id'] = '${<< parameters.envVariablePrefix >>AUTH0_CLIENT_ID}';
82+
\$settings['auth0_db_connection_id'] = '${<< parameters.envVariablePrefix >>AUTH0_DB_CONNECTION_ID}';
83+
\$settings['auth0_client_secret'] = '${<< parameters.envVariablePrefix >>AUTH0_CLIENT_SECRET}';
84+
\$settings['auth0_cookie_secret'] = '${<< parameters.envVariablePrefix >>AUTH0_COOKIE_SECRET}';
85+
\$settings['auth0_redirect_uri'] = '${<< parameters.envVariablePrefix >>AUTH0_REDIRECT_URI}';
86+
\$settings['v2_base_url'] = '${<< parameters.envVariablePrefix >>V2_BASE_URL}';
87+
\$settings['jwt_claim_prefix'] = 'https://www.boxtribute.com';" > library/config.php
88+
echo "paths:
89+
migrations: '%%PHINX_CONFIG_DIR%%/db/migrations'
90+
environments:
91+
default_migration_table: phinxlog
92+
<< parameters.serviceName >>:
93+
adapter: mysql
94+
host: 127.0.0.1
95+
name: ${<< parameters.envVariablePrefix >>DBNAME}
96+
user: ${<< parameters.envVariablePrefix >>DBNAME}
97+
pass: ${<< parameters.envVariablePrefix >>DBPASS}
98+
port: 3306
99+
charset: utf8
100+
mysql_attr_init_command: SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'
101+
version_order: creation" > phinx.yml
102+
# generate google app engine config for target environment
103+
sed 's/service: default/service: << parameters.serviceName >>/g' app.yaml > app-<< parameters.serviceName >>.yaml
104+
if [ << parameters.serviceName >> == production ]; then echo -e "\ninstance_class: F2" >> app-production.yaml; fi;
105+
- run:
106+
name: Download cloud_sql_proxy
107+
command: |
108+
# get google credentials
109+
echo $GOOGLE_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
110+
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
111+
# download cloud sql proxy to enable db access
112+
curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64
113+
chmod +x cloud_sql_proxy
114+
- run:
115+
name: Launch cloud_sql_proxy
109116
command: ./cloud_sql_proxy -instances=${BOXWISE_PRIMARYDB_SOCKET}=tcp:3306
110117
background: true
111-
- run: |
112-
# wait for cloud sql proxy to initialize
113-
sleep 3s
114-
cd workspace
115-
# apply db changes
116-
echo "Migrating << parameters.serviceName >> database"
117-
vendor/bin/phinx migrate -e << parameters.serviceName >>
118-
# deploy
119-
gcloud app deploy app-<< parameters.serviceName >>.yaml --version ${CIRCLE_BUILD_NUM}
118+
- run:
119+
name: Run DB migrations and deploy to GCloud
120+
command: |
121+
# wait for cloud sql proxy to initialize
122+
sleep 3s
123+
cd workspace
124+
# apply db changes
125+
echo "Migrating << parameters.serviceName >> database"
126+
vendor/bin/phinx migrate -e << parameters.serviceName >>
127+
# deploy
128+
gcloud app deploy app-<< parameters.serviceName >>.yaml --version ${CIRCLE_BUILD_NUM}
120129
121130
create-sentry-release:
122131
docker:

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ We have evolved the app to now be centrally hosted so we can offer the product t
1515

1616
If you are interested in being part of this project, write us at [jointheteam@boxtribute.org](mailto:jointheteam@boxtribute.org)! You can also check out our [website](https://www.boxtribute.org/#join) for more details about the kind of help we need on this project.
1717

18+
## Developer instructions and info
19+
1820
### Preparation for Installation
1921

2022
- Install [Docker](https://www.docker.com/products/docker-desktop)
@@ -205,17 +207,27 @@ All tests in `cypress/integrations` should be found and can be directly executed
205207
We experienced before that tests can fail in CircleCI, but not in the local environment. The main reason for it is that Cypress is usually executing the commands slower in a local dev environment.
206208
Therefore, a few additional guidelines when writing test:
207209

208-
- When you want to execute a redirect, e.g. example by clicking a button or tab, please add an assertion after the click, e.g. of the url `cy.url().should('include', 'people_deactivated')`. Due to this assertion cypress will definitely wait until the redirect is executed.
210+
- When you want to execute a redirect, e.g. by clicking a button or tab, please add an assertion after the click, e.g. of the url `cy.url().should('include', 'people_deactivated')`. Due to this assertion cypress will definitely wait until the redirect is executed.
209211
- Only if you use `cy.visit()` you can be sure that the cypress test wait until a page is fully loaded. Therefore, try to navigate as much as possible with `cy.visit()`.
210212

213+
## DevOps
214+
215+
### Release new version
216+
217+
1. `git checkout production`
218+
1. `git pull origin production`
219+
1. `git pull origin master --commit`
220+
1. For the deploy to the demo environment: `git push origin production`
221+
1. For the deploy to the production environment: `git tag -s v1.X.Y -m v1.X.Y` (bump X if DB migration involved) and `git push origin production --tags`
222+
211223
### Notes for setting up an Auth0 tenant
212224

213225
If you are setting up a new Auth0 tenant, we require access to the Auth0 Management API. In order to do this
214226

215227
- Under 'APIs' select Auth0 Management API, go to 'Machine to Machine Applications' and enable access
216228
- Grant scopes for read/update/delete/create users and users_app_metadata.
217229

218-
### Contribution guidelines
230+
## Contribution guidelines
219231

220232
You gotta be awesome and kind.
221233
For everything else, please see our [contribution guidelines](https://github.com/boxwise/dropapp/blob/master/CONTRIBUTING.md)
@@ -224,6 +236,6 @@ For everything else, please see our [contribution guidelines](https://github.com
224236

225237
Drop us an email to hello@boxtribute.org!
226238

227-
### License
239+
## License
228240

229241
See the [LICENSE](./LICENSE) file for license rights and limitations (Apache 2.0).

0 commit comments

Comments
 (0)