eternagame / workspace-helpers

Helper packages for JS projects
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

feat(nx-plugin): Cypress generator CI setup and improve caching in CI #191

Closed luxaritas closed 1 year ago

luxaritas commented 2 years ago

Resolves #183

luxaritas commented 1 year ago

Sure. Technically this does two things. One of them is fixing how we cache node_modules, which is based on the additional reading I did around cypress caching (plus noticing I was using some bogus values in the cache keys).

The other part of this is inserting the relevant steps for Cypress in the GitHub Actions CI workflow when Cypress is added - notice the updateGitHubActions call in both Cypress generators. What that does is insert three steps in the appropriate sections of the workflow: 1) Caching the cypress binary 2) Installing OS dependencies for cypress 3) Configuring X server manually to prevent against intermittent test failures

Inserting these steps require parsing the existing CI yaml file and inserting the steps in the correct locations (ie to keep the cache steps together, the install steps together, and making sure everything happens before the e2e tests are actually run). The yaml utils I created help manage that logic - we're able to pass in the step we want to insert, what step we want to insert it relative to, and whether we want to insert it before/after said step. I should probably add docstrings to those functions (and maybe some additional comments in the actions update function to summarize).