Skip to content

Conversation

jeeyyy
Copy link
Collaborator

@jeeyyy jeeyyy commented Jul 5, 2019

This PR solves for the missing test cases html files when publishing the site. A bug was recently introduced as a part of #604, where the logic for generating the test cases was moved out of a gatsby createNode hook, into a standalone npm script namely createTestcases. This npm script was executed as a prebuild step to build > gatsby build. Although all the necessary test case files and assets were created in the public directory as expected in the script, they were being deleted by gatsby build during its preInit step as shown below. (Note: gatsby develop does not clear these files) & hence these files were missing when the site was published.

image

This PR fixes the above issue, but changing the npm script to generate the test cases to a temporary directory _data/rules-testcases. Here all the necessary files, their assets the testcases.json files are generated. This directory can then be used as a one source of truth for all test cases.

The contents of the directory are then copied across to the public directory during the preBootstrap hook of the gatsby build step. This ensures that the files are not cleaned up during the preInit step.

Refer https://www.gatsbyjs.org/docs/node-apis/#onPreInit for more information on the various API's.

Note: research was done to see if deleting html and css assets can be bypassed during the gatsby build step. But this was not a configurable option & is a core step for invalidating the .cache internally for gatsby

Closes issue(s):

  • NA

Pull Request Etiquette

When creating PR:

  • Make sure you requesting to pull a branch (right side) to the develop branch (left side).

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Close the issue that the PR resolves (and make sure the issue is referenced in the top of this comment)
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.

@jeeyyy jeeyyy requested a review from WilcoFiers July 5, 2019 10:06
@jeeyyy jeeyyy merged commit 328122d into develop Jul 9, 2019
@jeeyyy jeeyyy deleted the keep-generated-testcases branch July 9, 2019 09:58
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.

2 participants