Build systems and CI/CD pipelines often require clean, isolated environments to ensure reproducibility and prevent dependency conflicts. Tensorlake Sandboxes allow you to spin up ephemeral containers on demand, upload source code, run tests, and retrieve artifacts. This example demonstrates a complete mini-CI pipeline that creates a dummy project, runs tests, and builds a distribution package inside a sandbox.Documentation Index
Fetch the complete documentation index at: https://docs.tensorlake.ai/llms.txt
Use this file to discover all available pages before exploring further.
TypeScript SDK starter
If your build runner is already in Node.js, the workflow is the same: stream project files into a sandbox, run each CI step, and pull artifacts back out if needed.Example: CI/CD Pipeline
The following script simulates a CI pipeline. It generates a simple Python project, uploads it to a sandbox, installs dependencies, runspytest, and builds a wheel file.
How It Works
- Environment Creation: The script instantiates a fresh sandbox. This ensures no leftover files or environment variables from previous builds affect the current run.
- File Injection: The custom
copy_to_sandboxfunction walks the local directory tree and streams files into the sandbox usingsandbox.write_file(). This simulates the βcheckoutβ phase of a CI pipeline. - Step Execution: The
run_ci_stephelper function executes shell commands (likepipandpytest) inside the sandbox usingsandbox.run(). It capturesstdout,stderr, and exit codes to determine success or failure. - Artifact Generation: The build step generates
.whland.tar.gzfiles inside the sandbox. In a real-world scenario, you would usesandbox.read_file()to download these artifacts back to your storage.
Learn More
File Operations
Learn how to efficiently move large files and directories in and out of sandboxes.
Process Management
Understand how to manage long-running processes and handle exit codes.