This repository has been archived by the owner on Sep 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(.circleci): show alternative deploy with success including s…
…etting NODE_OPTIONS
- Loading branch information
1 parent
862d708
commit 61ebaf4
Showing
1 changed file
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
node: circleci/[email protected] | ||
sls: circleci/[email protected] | ||
aws-cli: circleci/[email protected] | ||
|
||
|
||
commands: | ||
jobs: | ||
serverless_deploy: | ||
description: 'Deploy using the ServerlessFramework Orb' | ||
parameters: | ||
stage: | ||
type: string | ||
default: 'development' | ||
use-serverless-framework-orb: | ||
type: boolean | ||
default: true | ||
node-options: | ||
description: 'value to set for NODE_OPTIONS environment variable' | ||
type: string | ||
default: '' | ||
# NOTE: this is essentially cimg/python:3.8-node currently (as of Oct 21, 2021). | ||
# See https://circleci.com/developer/orbs/orb/circleci/serverless-framework#executors-default | ||
# We can just declare the specific docker image as well. | ||
executor: sls/default | ||
steps: | ||
- checkout | ||
- sls/setup | ||
- run: &sls_check | ||
name: checking Serverless tool | ||
- when: | ||
condition: << parameters.use-serverless-framework-orb >> | ||
steps: | ||
- sls/setup | ||
- when: | ||
condition: | ||
not: << parameters.use-serverless-framework-orb >> | ||
steps: | ||
- run: | ||
name: Install Serverless via NPM | ||
command: | | ||
sudo npm install -g serverless | ||
# Install AWS CLI, and set up our AWS credentials. | ||
# This is the same step taken by the ServerlessFramework orb for AWS deployments | ||
- aws-cli/setup | ||
- run: | ||
name: verify ServerlessFramework CLI tool | ||
command: | | ||
command -v sls | ||
command -v serverless | ||
- run: &sls_print_default | ||
name: print Serverles project config | ||
command: | | ||
cd src/services/core | ||
SLS_DEBUG=* sls print --stage << parameters.stage >> | ||
- run: &sls_print_nodeoptions | ||
# Interestingly, setting "max-old-space-size" via NODE_OPTIONS env var causes `sls` to exit 4, | ||
# even for `sls print` command, before we even discuss about deployment. | ||
- run: | ||
environment: | ||
# max-old-space-size: 2GB | ||
# trace-exit: allows us to print the Node/V8 error stacktrace | ||
NODE_OPTIONS: '--max-old-space-size=2048 --trace-exit' | ||
name: print Serverles project config again, with NODE_OPTIONS env var | ||
NODE_OPTIONS: '<< parameters.node-options >>' | ||
SLS_DEBUG: '*' | ||
name: verify ServerlessFramework project | ||
command: | | ||
cd src/services/core | ||
SLS_DEBUG=* sls print --stage << parameters.stage >> | ||
serverless_deploy_without_orb: | ||
description: 'Deploy without the ServerlessFramework Orb' | ||
parameters: | ||
stage: | ||
type: string | ||
default: 'development' | ||
steps: | ||
- checkout | ||
sls print --stage << parameters.stage >> | ||
- run: | ||
name: Install Serverless via NPM | ||
environment: | ||
NODE_OPTIONS: '<< parameters.node-options >>' | ||
SLS_DEBUG: '*' | ||
name: Deploy ServerlessFramework project | ||
command: | | ||
sudo npm install -g serverless | ||
- run: | ||
<<: *sls_check | ||
- run: | ||
<<: *sls_print_default | ||
- run: | ||
<<: *sls_print_nodeoptions | ||
|
||
jobs: | ||
deploy_development_with_orb: | ||
executor: sls/default | ||
steps: | ||
- serverless_deploy: | ||
stage: 'development' | ||
deploy_development_without_orb: | ||
executor: sls/default | ||
steps: | ||
- serverless_deploy_without_orb: | ||
stage: 'development' | ||
cd src/services/core | ||
sls deploy --stage << parameters.stage >> | ||
workflows: | ||
main: | ||
jobs: | ||
- deploy_development_with_orb | ||
# We expect this to fail due to odd behaviour (exit 4) when setting max-old-space-size for sls binary. | ||
# Interestingly, setting "max-old-space-size" via NODE_OPTIONS env var causes `sls` to exit 4, | ||
- # even for `sls print` command, before we even discuss about deployment. | ||
- serverless_deploy: | ||
use-serverless-framework-orb: true | ||
node-options: '--max-old-space-size=4096 --trace-exit' | ||
alternative: | ||
jobs: | ||
- deploy_development_without_orb | ||
# We expect this to pass with max-old-space-size set via NODE_OPTIONS env var going through | ||
- serverless_deploy: | ||
use-serverless-framework-orb: false | ||
node-options: '--max-old-space-size=4096 --trace-exit' |