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

test(integration/gatsby-cli): use sandboxed directory to "globally" install gatsby-cli #27056

Merged
merged 2 commits into from
Oct 1, 2020

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Sep 25, 2020

Relies on #27055

This installs gatsby-cli in some /tmp directory and let tests use that installation to invoke global gatsby-cli commands.

Those changes are looking to catch problems like #26919 which was not caught by any automatic testing (it worked on CI because executed gatsby-cli was in nested monorepo directory so it had access to all node_modules which did hide some problems)


This is part of PR series:

  1. feat(gatsby-dev-cli): install deps if there are no gatsby deps but --forceInstall was used
  2. test(integration/gatsby-cli): use sandboxed directory to "globally" install gatsby-cli (THIS PR)
  3. chore(gatsby-recipes): bundle dependencies
  4. chore(gatsby-cli): bundle dependencies

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 25, 2020
scripts/e2e-test.sh Outdated Show resolved Hide resolved
@pieh pieh added topic: cli Related to the Gatsby CLI type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Sep 25, 2020
@pieh pieh changed the base branch from chore/bundle-cli-and-recipes/gatsby-dev-cli to master September 28, 2020 12:38
@laurieontech
Copy link
Contributor

Looks good so far. Using a tmp dir is definitely prefered.

@pieh pieh force-pushed the chore/bundle-cli-and-recipes/sandbox-cli-tests branch from e197fee to 9c48758 Compare September 30, 2020 09:52
@@ -1,15 +1,22 @@
#!/bin/bash
set -e # bail on errors
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dropped chaining commands with && in favour of this so the script fails when any command fails (with exception to if statement conditions in this case)

check https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html for set command (and -e flag in particular) explanation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to showcase that this continue to fail tests properly - https://app.circleci.com/pipelines/github/gatsbyjs/gatsby/50132/workflows/a257b5b7-1e8c-4de1-9854-77c7e530725b is the intentionally not passing jest test ( from temporary draft PR just to test that - #27182 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(and reason for dropping chaining is that becomes unreadable with conditional commands - like the chmod that is only done if the file actually exists that I added in this PR)

@gatsby-cloud
Copy link

gatsby-cloud bot commented Sep 30, 2020

Gatsby Cloud Build Report

gatsby

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 4m

Copy link
Contributor

@laurieontech laurieontech left a comment

Choose a reason for hiding this comment

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

I'd recommend @wardpeet as a second set of eyes on this. It seems reasonable to me.

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@wardpeet
Copy link
Contributor

wardpeet commented Oct 1, 2020

I've tested on windows and it all work

@pieh pieh merged commit 3858de1 into master Oct 1, 2020
@delete-merged-branch delete-merged-branch bot deleted the chore/bundle-cli-and-recipes/sandbox-cli-tests branch October 1, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cli Related to the Gatsby CLI type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants