How to run your test suite in a clean microVM with sandscale sandbox run
Sometimes you want to know whether your tests pass on a clean machine, not on the laptop that has accumulated three years of global packages. Or you are about to run a test suite an agent changed and would rather it did not run next to your SSH keys. The Sandscale CLI has one command for this: sandscale sandbox run . It sends a folder to a fresh sandbox, runs a command there, streams the output…
To ensure your test suite runs in a clean environment, utilize the sandscale sandbox run command. This command sends a folder to a new sandbox, executes a command within it, streams the output, and exits with the command's exit code. The sandscale sandbox reference outlines installation and usage instructions for macOS and Linux systems.
To initiate the process, simply execute sandscale sandbox run --sync . -- make test. The --sync . flag copies the current folder to the sandbox's /workspace directory and runs the provided command. The command's exit code dictates the overall exit status, allowing seamless integration with scripts and CI/CD pipelines.
When configuring the sandbox, users can specify a template and options using the --template and --options flags. Templates are contingent upon the organization's configuration, while options include TTL, network settings, memory allocation, CPU count, and labels. The --ttl flag determines the sandbox's lifespan, while the --network flag dictates outbound network access, which may require inclusion in the organization's egress allowlist.
The sandscale sandbox run command excludes files designated in the .gitignore file, as well as .git, node_modules, and symbolic links. Secret and environment files, including .env* files, keys, credentials, cloud and registry tokens, and Terraform state files, are also excluded. Users can verify what gets sent and what does not by employing the --dry-run flag.
To preserve the sandbox for further inspection upon failure, the --keep flag can be utilized. This allows users to access the sandbox's contents using the sandcale sandbox connect and sandcale sandbox logs commands. Should the user wish to reuse the same sandbox, the --sandbox flag can be leveraged, enabling further commands, such as pytest -q, to be executed within the established sandbox.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to