Skip to content

Commit

Permalink
feat: add job to regenerate snapshots in ci (#1625)
Browse files Browse the repository at this point in the history
* feat: add job to regenerate snapshots in ci

* chore: update snapshot

* chore: add changeset
  • Loading branch information
nmerget authored Nov 1, 2024
1 parent 068be0d commit e430a68
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lemon-hornets-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

[CICD] regenerate test snapshots on fail to download them into local environment
30 changes: 30 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@ jobs:
- name: Run tests
run: yarn ci:test

test-update:
if: always() && (needs.test.result == 'failure')
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: 📥 Monorepo install
uses: ./.github/actions/yarn-nm-install
with:
cache-node-modules: true
cache-install-state: true

- name: 🏃🆙⏲️ Run test-update
run: yarn test:update

- name: 🆙 Upload snapshots
uses: actions/upload-artifact@v4
with:
name: snapshots-updates
path: ./packages/core/src/__tests__/__snapshots__
retention-days: 30

site:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ From there, you can keep iterating until the snapshots look as expected, and the
Before submitting your PR, please make sure to format the codebase and update all snapshots:

- format the codebase: from the root, run `yarn fmt:prettier`.
- update all snapshots (in core & CLI): from the root, run `yarn test:update`. This will run an Nx command that will update all the snapshots in the `core` and `cli` packages. while making sure all required dependencies are built beforehand.
- update all snapshots (in core & CLI): from the root, run `yarn test:update`. This will run a Nx command that will update all the snapshots in the `core` and `cli` packages. while making sure all required dependencies are built beforehand. If there are some difference between the generated snapshots in your local environment and GitHub Action you are able to download the correct snapshots via 'Summary' in the pipeline run. Wait until the job `test-update` is done, scroll to the bottom and download `snapshots-updates`. You should be able to copy&past the snapshots to `packages/core/src/__tests__/__snapshots__`.
- add Changeset entry: from the root, run `yarn g:changeset` and follow the CLI instructions.

#### Changeset format
Expand Down

0 comments on commit e430a68

Please sign in to comment.