Developing Garden
Once you've set up your developer environment, you're ready to hack on Garden!
Debugging
To enable setting a breakpoint in the code, run the CLI with the bin/garden-debug
binary, which adds the --inspect
flag. Developers might find it useful to alias this:
You can e.g. use the Chrome DevTools to inspect the code at the breakpoint:
Add a
debugger
statement somewhere in the code.Navigate to chrome://inspect/ in your Chrome browser.
Click the Open dedicated DevTools for Node link.
Run a CLI command that hits the breakpoint, e.g.:
You should now be able to inspect the code at run time in the Console tab of the DevTools window.
Release binaries and Docker containers
The Garden production binaries are a small Rust single application binary that extracts NodeJS binaries and the bundled Garden source code into a temporary directory, and then spawns NodeJS.
To build the production binaries you'll need the Rust toolchain and cross
, which we use for cross-compiling to different architectures and operating systems.
To install the required tools, follow the Cross getting started guide.
You can build the release binaries using the command
Use the option --cargocommand=cross
for cross-platform builds, otherwise cargo build will be the default.
You can then find the release binaries and archives under dist/
.
We release a number of Docker containers on Docker Hub.
The Docker containers meant to be used directly by the general public are defined in support/docker-bake.hcl
and listed in the DockerHub containers reference guide.
When making changes to the Dockerfile
definitions in support/
it is helpful to build the containers on your local machine.
For that, first run npm run dist
, and then run docker buildx bake
like so:
The environment variables will influence the tags that buildx bake
will create on your local machine (e.g. stable release tags, prerelease tags, version number, etc.).
To run the tests on your local machine, first run npm run dist
(if not already done so), and then run
Tests
Unit tests are run using mocha
via npm run test
from the directory of the package you want to test. To run a specific test, you can grep the test description with the -g
flag.:
ARM64 compatibility
On ARM64 platforms (like Mac machines with M1 chips) the npm run test
command may fail with the following error:
In order to fix it, the terminal must be running in the Rosetta mode, the detailed instructions can be found in this SO answer.
Integration tests are run with:
End-to-end tests are run with:
You can also run the end-to-end tests for a specific example project using:
End-to-end tests are run in CI by using Garden itself to test the project defined in ./core/test/e2e/garden.yml
. Cf. the appropriate job in circleci/config.yml
for details.
Last updated