Skip to content
Snippets Groups Projects
Commit 41296a96 authored by rschamp's avatar rschamp
Browse files

Optimize

parent 3dbfebe9
No related branches found
No related tags found
No related merge requests found
version: 2.1 version: 2.1
aliases: aliases:
- &step_restore_git_cache - &persist
restore_cache: persist_to_workspace:
keys: root: .
- v1-git-{{ .Revision }} paths: .
- v1-git- - &restore
- &step_save_git_cache attach_workspace:
save_cache: at: ~/repo
paths: - &defaults
- .git
key: v1-git-{{ .Revision }}
- &step_restore_dependency_cache
restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
- v1-dependencies-
- &step_save_dependency_cache
save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- &step_save_build_cache
save_cache:
paths:
- build
key: v1-build-{{ .Revision }}
- &step_restore_build_cache
restore_cache:
keys:
- v1-build-{{ .Revision }}
- &step_save_dist_cache
save_cache:
paths:
- dist
key: v1-dist-{{ .Revision }}
- &step_restore_dist_cache
restore_cache:
keys:
- v1-dist-{{ .Revision }}
- &config_job_environment
docker: docker:
- image: circleci/node:8.16-browsers - image: circleci/node:8.16-browsers
working_directory: ~/repo working_directory: ~/repo
jobs: jobs:
setup: setup:
<<: *config_job_environment <<: *defaults
steps: steps:
- *step_restore_git_cache - restore_cache:
keys:
- v1-git-{{ .Revision }}
- v1-git-
- checkout - checkout
- *step_save_git_cache - save_cache:
paths:
- .git
key: v1-git-{{ .Revision }}
- run: npm ci - run: npm ci
- *step_save_dependency_cache - *persist
lint: lint:
<<: *config_job_environment <<: *defaults
steps: steps:
- *step_restore_git_cache - *restore
- checkout
- *step_restore_dependency_cache
- run: - run:
name: Lint name: Lint
command: npm run test:lint -- --quiet --output-file test-results/eslint/results.xml --format junit command: npm run test:lint -- --quiet --output-file test-results/eslint/results.xml --format junit
- store_test_results: - store_test_results:
path: test-results path: test-results
unit: unit:
<<: *config_job_environment <<: *defaults
environment: environment:
JEST_JUNIT_OUTPUT_NAME: results.xml JEST_JUNIT_OUTPUT_NAME: results.xml
steps: steps:
- *step_restore_git_cache - *restore
- checkout
- *step_restore_dependency_cache
- run: - run:
name: Unit name: Unit
environment: environment:
...@@ -81,32 +52,34 @@ jobs: ...@@ -81,32 +52,34 @@ jobs:
- store_test_results: - store_test_results:
path: test-results path: test-results
build: build:
<<: *config_job_environment <<: *defaults
environment: environment:
NODE_ENV: production NODE_ENV: production
NODE_OPTIONS: --max-old-space-size=4000 NODE_OPTIONS: --max-old-space-size=4000
steps: steps:
- *step_restore_git_cache - *restore
- checkout
- *step_restore_dependency_cache
- run: - run:
name: Build name: Build
command: npm run build command: npm run build
- *persist
store_build:
<<: *defaults
steps:
- *restore
- store_artifacts: - store_artifacts:
path: build path: build
store_dist:
<<: *defaults
steps:
- *restore
- store_artifacts: - store_artifacts:
path: dist path: dist
- *step_save_build_cache
- *step_save_dist_cache
integration: integration:
<<: *config_job_environment <<: *defaults
environment: environment:
JEST_JUNIT_OUTPUT_NAME: results.txt JEST_JUNIT_OUTPUT_NAME: results.txt
steps: steps:
- *step_restore_git_cache - *restore
- checkout
- *step_restore_dependency_cache
- *step_restore_build_cache
- run: - run:
name: Integration name: Integration
environment: environment:
...@@ -116,10 +89,11 @@ jobs: ...@@ -116,10 +89,11 @@ jobs:
path: test-results path: test-results
deploy-npm: deploy-npm:
<<: *config_job_environment <<: *defaults
environment: environment:
NODE_OPTIONS: --max-old-space-size=4000 NODE_OPTIONS: --max-old-space-size=4000
steps: steps:
- *restore
- run: | - run: |
echo export RELEASE_VERSION="0.1.0-prerelease.$(date +'%Y%m%d%H%M%S')" >> $BASH_ENV echo export RELEASE_VERSION="0.1.0-prerelease.$(date +'%Y%m%d%H%M%S')" >> $BASH_ENV
echo export NPM_TAG=circlelatest >> $BASH_ENV echo export NPM_TAG=circlelatest >> $BASH_ENV
...@@ -129,9 +103,6 @@ jobs: ...@@ -129,9 +103,6 @@ jobs:
if [[ "$CIRCLE_BRANCH" == hotfix/* ]] # double brackets are important for matching the wildcard if [[ "$CIRCLE_BRANCH" == hotfix/* ]] # double brackets are important for matching the wildcard
then echo export NPM_TAG=circlehotfix >> $BASH_ENV then echo export NPM_TAG=circlehotfix >> $BASH_ENV
fi fi
- *step_restore_git_cache
- checkout
- *step_restore_dist_cache
- run: npm version --no-git-tag-version $RELEASE_VERSION - run: npm version --no-git-tag-version $RELEASE_VERSION
- run: | - run: |
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
...@@ -140,15 +111,12 @@ jobs: ...@@ -140,15 +111,12 @@ jobs:
- run: git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION - run: git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION
deploy-gh-pages: deploy-gh-pages:
<<: *config_job_environment <<: *defaults
steps: steps:
- *step_restore_git_cache - *restore
- checkout
- run: | - run: |
git config --global user.email $(git log --pretty=format:"%ae" -n1) git config --global user.email $(git log --pretty=format:"%ae" -n1)
git config --global user.name $(git log --pretty=format:"%an" -n1) git config --global user.name $(git log --pretty=format:"%an" -n1)
- *step_restore_build_cache
- *step_restore_dependency_cache
- run: npm run deploy -- -e $CIRCLE_BRANCH - run: npm run deploy -- -e $CIRCLE_BRANCH
workflows: workflows:
...@@ -168,6 +136,12 @@ workflows: ...@@ -168,6 +136,12 @@ workflows:
- integration: - integration:
requires: requires:
- build - build
- store_build:
requires:
- build
- store_dist:
requires:
- build
- deploy-npm: - deploy-npm:
requires: requires:
- lint - lint
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment