Continuous Integration
devsy ci builds an ephemeral devcontainer, runs a command in it, and deletes the workspace afterwards. Use it to check that your devcontainer.json still builds and your tests pass inside it.
How it works
- Resolves a workspace from the current directory (or a given source).
- Builds and starts the devcontainer, like
devsy workspace upwithout an IDE or SSH config changes. - Runs the command inside the container.
- Deletes the workspace, even when the command fails, unless you pass
--keep.
The command's exit code becomes the exit code of devsy ci, so a failing test fails the CI job.
Usage
devsy ci [flags] [workspace-path|workspace-name] -- <cmd> [args...]Run the test suite inside the devcontainer for the current project:
devsy ci -- make testTarget a specific project folder and pass environment variables:
devsy ci ./service -- npm test
devsy ci --remote-env CI=true --remote-env NODE_ENV=test -- npm testSelect a specific devcontainer config (e.g. a named .devcontainer/<name> profile):
devsy ci --devcontainer id:ci -- make testKeep the workspace around for debugging when the command fails:
devsy ci --keep -- ./run-integration-tests.shCommon flags
Run devsy ci --help for the full list. The most used:
--keepkeeps the workspace instead of deleting it.--remote-env KEY=VALUEsets an environment variable in the container at run time. Repeatable.--devcontainerpicks the config:none,image:<ref>,id:<name>, or a path to adevcontainer.json.--cache-fromand--no-cachecontrol the image build cache.--platformruns the container under another platform, such aslinux/amd64.--secret,--env,--build-secret, and--git-tokeninject stored Devsy secrets and variables. See Secrets.
Control progress output
Use --no-status to hide Devsy's live progress messages. It does not filter
diagnostics or the command's own output.
| Output | Effect of --no-status |
|---|---|
| Devsy progress | Hidden, including progress from the nested workspace command |
| Devsy diagnostics | Still controlled by --quiet, --log-level, and diagnostic format |
| Command stdout and stderr | Preserved on their original streams |
| Recorded events | Still recorded where the command already records them |
For example, keep warnings and errors while hiding progress:
devsy ci --no-status --result-format=plain --log-level=warn . -- bash .tools/test.shTo show errors while hiding warnings, use --quiet instead. Quiet mode takes
precedence over --log-level=warn and suppresses warnings too:
devsy ci --no-status --result-format=plain --quiet . -- bash .tools/test.shWhen stdout is redirected, use --result-format=plain to keep the nested
workspace command's success result JSON off stderr. Use
--result-format=json when the caller needs the structured result; child
stdout and stderr remain separate from Devsy diagnostics.
Setup history after cleanup
devsy ci deletes the workspace, but the history of its build and lifecycle hooks stays in the local store. Read it by run ID after the job ends, or from an artifact step that runs on the same machine:
devsy workspace logs --source setup --list
devsy workspace logs --source setup --run RUN_ID --context CONTEXT --result-format=plainRetention is bounded. See Setup history. The history covers the build and the lifecycle hooks. The stdout and stderr of your own command after -- stay on their normal streams and are not archived. Hooks still running when the command ends are not waited for.
Pre-building and pushing images
To pre-build and publish a devcontainer image for reuse as a build cache, use devsy workspace build:
devsy workspace build --repository ghcr.io/my-org/my-devcontainer --tag latest --pushLater CI jobs can pass that image to --cache-from to speed up builds.
GitHub Actions
Install the CLI, configure the docker provider, then run devsy ci:
name: Devcontainer CI
on:
push:
branches: [main]
pull_request:
jobs:
devcontainer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Devsy
run: |
sudo curl -fsSL https://github.com/devsy-org/devsy/releases/latest/download/devsy-linux-amd64 -o /usr/local/bin/devsy
sudo chmod +x /usr/local/bin/devsy
- name: Run CI in devcontainer
run: |
devsy provider add docker && devsy provider use docker
devsy ci -- make test