2020-01-15 20:27:27 +05:30
|
|
|
variables:
|
2021-07-14 01:09:19 +05:30
|
|
|
NODE_IMAGE: node:14-alpine
|
|
|
|
NODE_E2E_IMAGE: circleci/node:14-buster-browsers
|
2020-01-15 21:27:20 +05:30
|
|
|
DEPLOY_IMAGE: docksal/ssh-agent:1.3
|
2020-01-15 20:27:27 +05:30
|
|
|
# To cache both npm modules and Cypress binary we use environment variables
|
|
|
|
# to point at the folders we can list as paths in "cache" job settings
|
|
|
|
YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/yarn"
|
|
|
|
CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/cypress"
|
|
|
|
|
2020-07-22 20:41:44 +05:30
|
|
|
GIT_DEPTH: 10
|
|
|
|
|
2020-01-15 20:27:27 +05:30
|
|
|
stages:
|
|
|
|
- prepare
|
|
|
|
- test
|
|
|
|
- build
|
|
|
|
- deploy
|
|
|
|
|
|
|
|
# GitLab don't support bash syntax in the "variables" definitions,
|
|
|
|
# so we use a custom step to define all necessary environment variables
|
|
|
|
.defineVars: &defineVars |-
|
|
|
|
export VERSION="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
|
|
|
|
|
|
|
|
.installSentry: &installSentry |-
|
2020-01-15 21:27:20 +05:30
|
|
|
apk add curl
|
2020-01-15 20:27:27 +05:30
|
|
|
curl -sL https://sentry.io/get-cli/ | bash
|
|
|
|
|
|
|
|
.setupSSH: &setupSSH |-
|
|
|
|
mkdir ~/.ssh
|
|
|
|
echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
|
|
|
|
eval $(ssh-agent -s)
|
|
|
|
echo "$SSH_DEPLOY_KEY" | tr -d '\r' | ssh-add -
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Steps to extend #
|
|
|
|
###################
|
|
|
|
|
|
|
|
.yarnCache:
|
|
|
|
cache:
|
|
|
|
key: yarn-cache
|
|
|
|
paths:
|
|
|
|
- node_modules
|
|
|
|
- packages/*/node_modules
|
2020-01-15 23:02:04 +05:30
|
|
|
- tests-e2e/node_modules # Keep this node_modules because it's one of workspaces
|
2020-01-15 20:27:27 +05:30
|
|
|
policy: pull
|
|
|
|
|
|
|
|
#################
|
|
|
|
# Prepare stage #
|
|
|
|
#################
|
|
|
|
|
|
|
|
Yarn:
|
|
|
|
stage: prepare
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $NODE_IMAGE
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
cache:
|
|
|
|
policy: pull-push
|
|
|
|
variables:
|
|
|
|
CYPRESS_INSTALL_BINARY: 0 # Don't install binary to increase caching performance between jobs
|
2020-06-05 21:18:32 +05:30
|
|
|
before_script:
|
|
|
|
- apk add git
|
2020-01-15 20:27:27 +05:30
|
|
|
script:
|
2020-01-15 23:02:04 +05:30
|
|
|
- yarn install --frozen-lockfile
|
2020-01-15 20:27:27 +05:30
|
|
|
|
|
|
|
#################
|
|
|
|
# Testing stage #
|
|
|
|
#################
|
|
|
|
|
|
|
|
Lint:
|
|
|
|
stage: test
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $NODE_IMAGE
|
|
|
|
needs:
|
|
|
|
- Yarn
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
script:
|
|
|
|
- yarn lint:check
|
|
|
|
|
|
|
|
TypeScript:
|
|
|
|
stage: test
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $NODE_IMAGE
|
|
|
|
needs:
|
|
|
|
- Yarn
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
script:
|
|
|
|
- yarn ts:check
|
|
|
|
|
|
|
|
Jest:
|
|
|
|
stage: test
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $NODE_IMAGE
|
|
|
|
needs:
|
|
|
|
- Yarn
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
script:
|
|
|
|
- yarn test
|
|
|
|
|
2020-06-10 03:03:42 +05:30
|
|
|
Crowdin:
|
2020-06-09 23:42:43 +05:30
|
|
|
stage: test
|
|
|
|
image: $NODE_IMAGE
|
|
|
|
needs:
|
|
|
|
- Yarn
|
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
script:
|
|
|
|
- yarn i18n:extract
|
2020-06-10 00:32:41 +05:30
|
|
|
- yarn i18n:push
|
2020-06-10 03:03:42 +05:30
|
|
|
- yarn i18n:pull
|
2020-06-09 23:42:43 +05:30
|
|
|
artifacts:
|
2020-06-10 03:03:42 +05:30
|
|
|
name: "i18n for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA"
|
2020-06-09 23:42:43 +05:30
|
|
|
paths:
|
2020-06-10 03:03:42 +05:30
|
|
|
- packages/app/i18n/*.json
|
|
|
|
- packages/app/i18n/index.js
|
2020-06-09 23:42:43 +05:30
|
|
|
expire_in: 1 week
|
|
|
|
|
2020-01-15 20:27:27 +05:30
|
|
|
###############
|
|
|
|
# Build stage #
|
|
|
|
###############
|
|
|
|
|
|
|
|
Build:
|
|
|
|
stage: build
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $NODE_IMAGE
|
2020-01-15 20:27:27 +05:30
|
|
|
needs:
|
|
|
|
- Lint
|
|
|
|
- TypeScript
|
|
|
|
- Jest
|
2020-06-10 03:03:42 +05:30
|
|
|
- Crowdin
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
before_script:
|
|
|
|
- *defineVars
|
|
|
|
script:
|
|
|
|
- yarn build
|
|
|
|
# Remove unneeded files
|
|
|
|
- rm -rf build/*.css.map
|
|
|
|
# Move all source maps to its own directory
|
|
|
|
- mkdir -p source-maps
|
|
|
|
- cd build
|
|
|
|
- find . -name '*.js.map' | cpio -pdm ../source-maps/
|
|
|
|
- rm -rf *.js.map
|
|
|
|
- find . -name '*.js' | cpio -pdm ../source-maps/
|
|
|
|
- cd ..
|
2020-07-21 18:42:21 +05:30
|
|
|
# Cleanup source maps for unimportant bundles
|
2020-07-21 23:58:39 +05:30
|
|
|
- rm -f source-maps/runtime.js
|
|
|
|
- rm -f source-maps/intl-polyfills.js
|
2020-07-21 18:42:21 +05:30
|
|
|
- rm -rf source-maps/locale-*
|
2020-01-15 20:27:27 +05:30
|
|
|
artifacts:
|
|
|
|
name: "Production build for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA"
|
|
|
|
paths:
|
|
|
|
- build
|
|
|
|
- source-maps
|
|
|
|
expire_in: 1 week
|
|
|
|
|
2020-01-16 21:03:05 +05:30
|
|
|
Storybook:
|
|
|
|
stage: build
|
|
|
|
image: $NODE_IMAGE
|
|
|
|
needs:
|
|
|
|
- Yarn
|
2020-06-10 03:03:42 +05:30
|
|
|
- Crowdin
|
2020-01-16 21:03:05 +05:30
|
|
|
extends:
|
|
|
|
- .yarnCache
|
|
|
|
script:
|
|
|
|
- yarn sb:build --quiet
|
|
|
|
artifacts:
|
|
|
|
name: "Storybook for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA"
|
|
|
|
paths:
|
|
|
|
- storybook-static
|
|
|
|
expire_in: 1 day
|
|
|
|
|
2020-01-15 20:27:27 +05:30
|
|
|
################
|
|
|
|
# Deploy stage #
|
|
|
|
################
|
|
|
|
|
|
|
|
.deployJob:
|
|
|
|
stage: deploy
|
2020-01-15 21:27:20 +05:30
|
|
|
image: $DEPLOY_IMAGE
|
2020-01-16 21:03:05 +05:30
|
|
|
needs:
|
|
|
|
- Build
|
2020-01-15 20:27:27 +05:30
|
|
|
before_script:
|
|
|
|
- *defineVars
|
|
|
|
- *installSentry
|
|
|
|
- *setupSSH
|
2020-01-15 21:27:20 +05:30
|
|
|
- apk add rsync
|
2020-01-15 20:27:27 +05:30
|
|
|
script:
|
|
|
|
# Send release to the Sentry
|
|
|
|
- sentry-cli releases new $VERSION
|
|
|
|
- sentry-cli releases set-commits --commit "elyby/accounts-frontend@${CI_COMMIT_SHA}" $VERSION
|
|
|
|
- sentry-cli releases files $VERSION upload-sourcemaps source-maps
|
|
|
|
- rsync -v -a -r --delete-after -e "ssh -J deploy@ely.by:4534 -p 722" build/ "root@${VM_HOST_NAME}:${VM_DEPLOY_PATH}"
|
|
|
|
# Finalize Sentry's release
|
|
|
|
- sentry-cli releases deploys $VERSION new -e $CI_ENVIRONMENT_NAME
|
|
|
|
- sentry-cli releases finalize $VERSION
|
|
|
|
|
2020-08-21 20:51:09 +05:30
|
|
|
Dev:
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .deployJob
|
|
|
|
environment:
|
|
|
|
name: Development
|
|
|
|
variables:
|
|
|
|
VM_HOST_NAME: playground.ely.local
|
|
|
|
VM_DEPLOY_PATH: /srv/dev.account.ely.by/frontend
|
2020-08-21 20:51:09 +05:30
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_BRANCH == "master"'
|
|
|
|
when: on_success
|
|
|
|
- if: '$CI_COMMIT_MESSAGE =~ /\[deploy dev\]/'
|
|
|
|
when: on_success
|
|
|
|
# Default:
|
|
|
|
- when: never
|
2020-01-15 20:27:27 +05:30
|
|
|
|
2020-08-21 20:51:09 +05:30
|
|
|
Prod:
|
2020-01-15 20:27:27 +05:30
|
|
|
extends:
|
|
|
|
- .deployJob
|
|
|
|
stage: deploy
|
|
|
|
environment:
|
|
|
|
name: Production
|
|
|
|
variables:
|
|
|
|
VM_HOST_NAME: accounts.ely.local
|
|
|
|
VM_DEPLOY_PATH: /srv/frontend
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_BRANCH != "master"'
|
|
|
|
when: never
|
|
|
|
- if: '$CI_COMMIT_MESSAGE =~ /\[deploy\]/'
|
|
|
|
when: on_success
|
2020-08-21 20:51:09 +05:30
|
|
|
# Default:
|
2020-01-15 20:27:27 +05:30
|
|
|
- when: manual
|