The problem
There are some incremental build/test workflows where no snapshots are taken.
In these cases, percy exec or percy exec:start & percy exec:stop are used in conjunction with PERCY_PARTIAL_BUILD=1 but as there is no snapshot taken, the build fails.
In a more precise example, we are using Nx which has an nx affected command that only runs affected tests.
Some commits or PRs might change files that don't affect tests.
In this case, running the following command would fail as no snapshot is uploaded:
PERCY_PATIAL_BUILD=1 percy exec nx affected --target test
Solutions
- Allow empty builds when using
PERCY_PARTIAL_BUILD
- Add a
PERCY_ALLOW_EMPTY_BUILD env var that sends an allow_empty_build: true flag to the API when creating the build and mark the build as successful on finalize even if no snapshot was upload.
Workarounds
- take a placeholder snapshot no matter what (cf. https://github.com/marmicode/marmicode/blob/59412b8b1d721ba9fc461b38605f4b8bec2f3cc0/.github/workflows/test-and-deploy.yml#L96 & https://github.com/marmicode/marmicode/blob/main/tools/percy-upload-placeholder.ts)
- guess if some snapshots will be taken or not and skip starting percy (but this will not add a percy check to the PR, which might make it unmergeable if the target branch is protected)
- run all tests which defeats the whole purpose of incremental build/test tools like Nx
The problem
There are some incremental build/test workflows where no snapshots are taken.
In these cases,
percy execorpercy exec:start&percy exec:stopare used in conjunction withPERCY_PARTIAL_BUILD=1but as there is no snapshot taken, the build fails.In a more precise example, we are using Nx which has an
nx affectedcommand that only runs affected tests.Some commits or PRs might change files that don't affect tests.
In this case, running the following command would fail as no snapshot is uploaded:
Solutions
PERCY_PARTIAL_BUILDPERCY_ALLOW_EMPTY_BUILDenv var that sends anallow_empty_build: trueflag to the API when creating the build and mark the build as successful on finalize even if no snapshot was upload.Workarounds