2020-10-27 14:10:50 -04:00
|
|
|
version: 2.1
|
2020-10-29 10:52:45 -04:00
|
|
|
|
|
|
|
aliases:
|
|
|
|
- &defaults
|
|
|
|
docker:
|
|
|
|
- image: circleci/node:12-browsers
|
|
|
|
auth:
|
|
|
|
username: $DOCKERHUB_USERNAME
|
|
|
|
password: $DOCKERHUB_PASSWORD
|
2020-10-30 09:41:30 -04:00
|
|
|
working_directory: ~/repo
|
2020-11-09 10:42:54 -05:00
|
|
|
- &environment
|
|
|
|
CXX: g++-4.8
|
|
|
|
FASTLY_ACTIVATE_CHANGES: true
|
|
|
|
NODE_ENV: production
|
|
|
|
S3_LOCAL_DIR: build
|
|
|
|
SENTRY_ORG: scratch-foundation
|
|
|
|
SKIP_CLEANUP: true
|
2020-11-09 15:02:55 -05:00
|
|
|
# WWW_VERSION: ${CIRCLE_SHA1:0:5}
|
2020-11-09 10:42:54 -05:00
|
|
|
- &env_production
|
|
|
|
API_HOST: https://api.scratch.mit.edu
|
|
|
|
ASSET_HOST: https://assets.scratch.mit.edu
|
|
|
|
BACKPACK_HOST: https://backpack.scratch.mit.edu
|
|
|
|
CLOUDDATA_HOST: clouddata.scratch.mit.edu
|
|
|
|
FASTLY_API_KEY: ${FASTLY_API_KEY_PRODUCTION}
|
|
|
|
FASTLY_SERVICE_ID: ${FASTLY_SERVICE_ID_PRODUCTION}
|
|
|
|
GA_TRACKER: UA-30688952-1
|
|
|
|
PROJECT_HOST: https://projects.scratch.mit.edu
|
|
|
|
RECAPTCHA_SITE_KEY: 6LeRbUwUAAAAAFYhKgk3G9OKWqE_OJ7Z-7VTUCbl
|
|
|
|
ROOT_URL: https://scratch.mit.edu
|
|
|
|
S3_BUCKET_NAME: scratch-www-production
|
|
|
|
SCRATCH_ENV: production
|
|
|
|
SENTRY_DSN: https://ebc2f8a6bc7b44ca8fd902fd4f16b3d7@sentry.io/1357122
|
|
|
|
SENTRY_PROJECT: scratch-30-production
|
|
|
|
STATIC_HOST: https://cdn2.scratch.mit.edu
|
2020-11-10 09:24:32 -05:00
|
|
|
TEST_PROJECT_ID: "414835599"
|
2020-11-10 10:41:12 -05:00
|
|
|
# - env_staging: &env_staging
|
2020-11-09 10:42:54 -05:00
|
|
|
- &save_git_cache
|
|
|
|
save_cache:
|
|
|
|
paths:
|
|
|
|
- .git
|
|
|
|
key: v1-git-{{ .Revision }}
|
|
|
|
- &restore_git_cache
|
|
|
|
restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-git-{{ .Revision }}
|
|
|
|
- v1-git-
|
2020-10-30 17:18:40 -04:00
|
|
|
- &save_npm_cache
|
|
|
|
save_cache:
|
|
|
|
paths:
|
|
|
|
- node_modules
|
2020-11-09 11:10:27 -05:00
|
|
|
key: v1-npm-{{ checksum "package-lock.json" }}
|
2020-10-30 17:23:11 -04:00
|
|
|
- &restore_npm_cache
|
2020-10-30 17:18:40 -04:00
|
|
|
restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-npm-{{ checksum "package-lock.json" }}
|
|
|
|
- v1-npm-
|
2020-11-09 10:42:54 -05:00
|
|
|
- &save_build_cache
|
2020-11-09 10:57:19 -05:00
|
|
|
save_cache:
|
2020-11-09 10:42:54 -05:00
|
|
|
paths:
|
|
|
|
- ./build
|
|
|
|
- ./intl
|
2020-11-09 11:10:27 -05:00
|
|
|
key: v1-build-{{ .Revision }}
|
2020-11-09 10:42:54 -05:00
|
|
|
- &restore_build_cache
|
|
|
|
restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-build-{{ .Revision }}
|
|
|
|
- v1-build-
|
|
|
|
|
2020-10-29 10:52:45 -04:00
|
|
|
jobs:
|
2020-11-09 14:50:21 -05:00
|
|
|
build-staging:
|
2020-10-29 10:52:45 -04:00
|
|
|
<<: *defaults
|
2020-11-09 14:50:21 -05:00
|
|
|
environment:
|
|
|
|
<<: *environment
|
2020-11-10 10:24:49 -05:00
|
|
|
# <<: *env_staging
|
2020-10-29 10:52:45 -04:00
|
|
|
steps:
|
2020-11-09 10:42:54 -05:00
|
|
|
- *restore_git_cache
|
2020-10-29 15:56:05 -04:00
|
|
|
- checkout
|
2020-11-09 10:42:54 -05:00
|
|
|
- *restore_npm_cache
|
2020-11-02 12:03:10 -05:00
|
|
|
- run:
|
2020-11-09 10:42:54 -05:00
|
|
|
name: "Run npm test to build"
|
|
|
|
command: |
|
2020-11-10 10:53:50 -05:00
|
|
|
echo export API_HOST=https://api.scratch.ly >> $BASH_ENV
|
|
|
|
echo export ASSET_HOST=https://assets.scratch.ly >> $BASH_ENV
|
|
|
|
echo export BACKPACK_HOST=https://backpack.scratch.ly >> $BASH_ENV
|
|
|
|
echo export CLOUDDATA_HOST=varserver2.scratch.ly >> $BASH_ENV
|
|
|
|
echo export GA_TRACKER=UA-30688952-7 >> $BASH_ENV
|
|
|
|
echo export PROJECT_HOST=https://projects.scratch.ly >> $BASH_ENV
|
|
|
|
echo export RECAPTCHA_SITE_KEY=6LfukK4UAAAAAFR44yoZMhv8fj6xh-PMiIxwryG3 >> $BASH_ENV
|
|
|
|
echo export ROOT_URL=https://scratch.ly >> $BASH_ENV
|
|
|
|
echo export S3_BUCKET_NAME=scratch-www-staging >> $BASH_ENV
|
|
|
|
echo export SCRATCH_ENV=staging >> $BASH_ENV
|
|
|
|
echo export SENTRY_DSN=https://c01014988b0a4f44bbefdf235623c456@sentry.io/1357982 >> $BASH_ENV
|
|
|
|
echo export SENTRY_PROJECT=scratch-30-staging >> $BASH_ENV
|
|
|
|
echo export STATIC_HOST=https://cdn.scratch.ly >> $BASH_ENV
|
|
|
|
echo export TEST_PROJECT_ID="1300006196" >> $BASH_ENV
|
2020-11-09 10:42:54 -05:00
|
|
|
npm --production=false ci
|
2020-11-09 15:02:55 -05:00
|
|
|
WWW_VERSION=${CIRCLE_SHA1:0:5} npm run test
|
2020-11-09 10:42:54 -05:00
|
|
|
- *save_npm_cache
|
|
|
|
- *save_git_cache
|
|
|
|
- *save_build_cache
|
2020-11-09 14:52:59 -05:00
|
|
|
build-production:
|
|
|
|
<<: *defaults
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
|
|
|
# <<: *env_production
|
|
|
|
steps:
|
|
|
|
- *restore_git_cache
|
|
|
|
- checkout
|
|
|
|
- *restore_npm_cache
|
|
|
|
- run:
|
|
|
|
name: "Run npm test to build"
|
|
|
|
command: |
|
|
|
|
npm --production=false ci
|
2020-11-09 15:02:55 -05:00
|
|
|
WWW_VERSION=${CIRCLE_SHA1:0:5} npm run test npm run test
|
2020-11-09 14:52:59 -05:00
|
|
|
- *save_npm_cache
|
|
|
|
- *save_git_cache
|
|
|
|
- *save_build_cache
|
2020-11-09 10:42:54 -05:00
|
|
|
deploy-staging:
|
|
|
|
<<: *defaults
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
2020-11-10 10:24:49 -05:00
|
|
|
# <<: *env_staging
|
2020-11-09 10:42:54 -05:00
|
|
|
steps:
|
|
|
|
- *restore_git_cache
|
|
|
|
- checkout
|
|
|
|
- *restore_npm_cache
|
|
|
|
- *restore_build_cache
|
|
|
|
- run:
|
|
|
|
name: "deploy to staging"
|
2020-11-02 12:03:10 -05:00
|
|
|
command: |
|
2020-11-10 10:53:50 -05:00
|
|
|
echo export API_HOST=https://api.scratch.ly >> $BASH_ENV
|
|
|
|
echo export ASSET_HOST=https://assets.scratch.ly >> $BASH_ENV
|
|
|
|
echo export BACKPACK_HOST=https://backpack.scratch.ly >> $BASH_ENV
|
|
|
|
echo export CLOUDDATA_HOST=varserver2.scratch.ly >> $BASH_ENV
|
|
|
|
echo export GA_TRACKER=UA-30688952-7 >> $BASH_ENV
|
|
|
|
echo export PROJECT_HOST=https://projects.scratch.ly >> $BASH_ENV
|
|
|
|
echo export RECAPTCHA_SITE_KEY=6LfukK4UAAAAAFR44yoZMhv8fj6xh-PMiIxwryG3 >> $BASH_ENV
|
|
|
|
echo export ROOT_URL=https://scratch.ly >> $BASH_ENV
|
|
|
|
echo export S3_BUCKET_NAME=scratch-www-staging >> $BASH_ENV
|
|
|
|
echo export SCRATCH_ENV=staging >> $BASH_ENV
|
|
|
|
echo export SENTRY_DSN=https://c01014988b0a4f44bbefdf235623c456@sentry.io/1357982 >> $BASH_ENV
|
|
|
|
echo export SENTRY_PROJECT=scratch-30-staging >> $BASH_ENV
|
|
|
|
echo export STATIC_HOST=https://cdn.scratch.ly >> $BASH_ENV
|
|
|
|
echo export TEST_PROJECT_ID="1300006196" >> $BASH_ENV
|
2020-11-02 12:03:10 -05:00
|
|
|
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
|
|
|
python get-pip.py
|
|
|
|
pip install -r requirements.txt
|
2020-11-09 12:00:17 -05:00
|
|
|
FASTLY_API_KEY="${FASTLY_API_KEY_STAGING}" FASTLY_SERVICE_ID="${FASTLY_SERVICE_ID_STAGING}" npm run deploy
|
2020-11-09 10:42:54 -05:00
|
|
|
deploy-production:
|
|
|
|
<<: *defaults
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
|
|
|
# <<: *env_production
|
|
|
|
steps:
|
|
|
|
- *restore_git_cache
|
|
|
|
- checkout
|
|
|
|
- *restore_npm_cache
|
|
|
|
- *restore_build_cache
|
2020-11-02 12:05:14 -05:00
|
|
|
- run:
|
2020-11-09 10:42:54 -05:00
|
|
|
name: "deploy to production"
|
2020-11-02 12:03:10 -05:00
|
|
|
command: |
|
2020-11-09 10:42:54 -05:00
|
|
|
echo "don't deploy to production until we know it works"
|
|
|
|
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
|
|
|
python get-pip.py
|
|
|
|
pip install -r requirements.txt
|
|
|
|
npm run deploy
|
|
|
|
integration-staging:
|
|
|
|
<<: *defaults
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
2020-11-10 10:24:49 -05:00
|
|
|
# <<: *env_staging
|
2020-11-09 10:42:54 -05:00
|
|
|
steps:
|
|
|
|
- *restore_git_cache
|
|
|
|
- checkout
|
|
|
|
- *restore_npm_cache
|
2020-11-02 12:03:10 -05:00
|
|
|
- run:
|
2020-11-09 10:42:54 -05:00
|
|
|
name: "integration tests"
|
2020-11-02 12:03:10 -05:00
|
|
|
command: |
|
2020-11-10 10:53:50 -05:00
|
|
|
echo export ROOT_URL=https://scratch.ly >> $BASH_ENV
|
|
|
|
echo export TEST_PROJECT_ID="1300006196" >> $BASH_ENV
|
2020-11-09 10:42:54 -05:00
|
|
|
npm run test:integration:remote
|
|
|
|
integration-production:
|
2020-10-30 17:19:09 -04:00
|
|
|
<<: *defaults
|
2020-11-09 10:42:54 -05:00
|
|
|
environment:
|
|
|
|
<<: *environment
|
|
|
|
# <<: *env_production
|
2020-10-30 17:19:09 -04:00
|
|
|
steps:
|
2020-11-09 10:42:54 -05:00
|
|
|
- *restore_git_cache
|
2020-10-30 17:19:09 -04:00
|
|
|
- checkout
|
2020-11-09 10:42:54 -05:00
|
|
|
- *restore_npm_cache
|
|
|
|
- run:
|
|
|
|
name: "integration tests"
|
|
|
|
command: |
|
|
|
|
npm run test:integration:remote
|
2020-10-29 10:52:45 -04:00
|
|
|
|
2020-10-27 14:10:50 -04:00
|
|
|
workflows:
|
2020-10-29 10:52:45 -04:00
|
|
|
build-test-deploy:
|
2020-10-27 14:10:50 -04:00
|
|
|
jobs:
|
2020-11-09 14:50:21 -05:00
|
|
|
- build-staging:
|
2020-11-09 10:42:54 -05:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- circleci-project-setup # remove this before releasing
|
2020-11-09 14:50:21 -05:00
|
|
|
- develop
|
|
|
|
- /^hotfix\/.*/
|
|
|
|
- /^release\/.*/
|
2020-11-09 10:42:54 -05:00
|
|
|
- deploy-staging:
|
|
|
|
requires:
|
2020-11-09 14:50:21 -05:00
|
|
|
- build-staging
|
2020-11-09 10:42:54 -05:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- circleci-project-setup # remove this before releasing
|
|
|
|
- develop
|
2020-11-09 14:50:21 -05:00
|
|
|
- /^hotfix\/.*/ # make sure this syntax works. may need a regex
|
|
|
|
- /^release\/.*/
|
2020-11-09 10:42:54 -05:00
|
|
|
- integration-staging:
|
|
|
|
requires:
|
|
|
|
- deploy-staging
|
2020-10-27 15:05:42 -04:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- circleci-project-setup # remove this before releasing
|
2020-11-09 10:42:54 -05:00
|
|
|
- develop
|
2020-11-09 14:50:21 -05:00
|
|
|
- /^hotfix\/.*/
|
|
|
|
- /^release\/.*/
|