Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging env fallback for tests #91

Merged
merged 1 commit into from
Oct 11, 2019

Conversation

rioam2
Copy link
Owner

@rioam2 rioam2 commented Oct 11, 2019

Resolves #90

@rioam2 rioam2 self-assigned this Oct 11, 2019
@@ -19,6 +19,7 @@ const { exec } = require('child_process');
const mergedEnv = { ...dotenv.parsed, ...process.env };
const command = process.argv
.slice(2)
.map((arg) => (arg.includes(' ') && `'${arg}'`) || arg)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed as multi-word arguments with quotes are passed into node as a single array element with a space in between. The existence of a space means the argument needs to be re-quoted.

May have some adverse side-effects based on if the argument actually contains its own single quotes...

# Continuous Deployment for staging/production
if [[ $TRAVIS_BRANCH == 'master' ]]; then
if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then
if [[ ! -z $STATIC_PROD_PROJECT ]] && [[ ! -z $STATIC_DEPLOY_KEY ]]; then
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks are more granular and therefore preferred over the general $TRAVIS_SECURE_ENV_VARS check removed above.

@@ -19,7 +19,7 @@
"preview:staging": "cross-env NODE_ENV=production yarn loadenv ./scripts/preview.sh",
"setup": "./scripts/setup.js",
"test": "yarn test:unit && yarn test:cypress",
"test:cypress": "start-server-and-test 'yarn preview:staging > /dev/null' 3000 'cypress run'",
"test:cypress": "yarn loadenv yarn start-server-and-test '[ -z %STATIC_STAGE_PROJECT ] && yarn preview:production > /dev/null || yarn preview:staging > /dev/null' 3000 'cypress run'",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is a little messy right now. May be best to migrate into scripts/ as a separate file later on...

@rioam2 rioam2 merged commit 3f0313b into master Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Projects without a staging environment fail on CI/CD
1 participant