Devsy
Developing in a Workspace

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

  1. Resolves a workspace from the current directory (or a given source).
  2. Builds and starts the devcontainer (equivalent to devsy workspace up, without launching an IDE or touching your SSH config).
  3. Runs the given command inside the running container.
  4. Deletes the workspace - always, even when the command fails - unless --keep is passed.

A non-zero exit from the command propagates as the exit code of devsy ci, so a failing test or build 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 test

Target 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 test

Select a specific devcontainer config (e.g. a named .devcontainer/<name> profile):

devsy ci --devcontainer id:ci -- make test

Keep the workspace around for debugging when the command fails:

devsy ci --keep -- ./run-integration-tests.sh

Common flags

Run devsy ci --help for the full list. The most used:

  • --keep keeps the workspace instead of deleting it.
  • --remote-env KEY=VALUE sets an environment variable in the container at run time. Repeatable.
  • --devcontainer picks the config: none, image:<ref>, id:<name>, or a path to a devcontainer.json.
  • --cache-from and --no-cache control the image build cache.
  • --platform runs the container under another platform, such as linux/amd64.
  • --secret, --env, --build-secret, and --git-token inject stored Devsy secrets and variables. See Secrets.

Pre-building and pushing images

devsy ci focuses on running a command. 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 --push

Downstream CI jobs can then reference that image via --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

On this page