devsonnet

command module
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

README

devsonnet

A Swiss Army knife of small, focused tools for working with Jsonnet. Each one handles a single task, mostly aimed at making CI workflows or local development easier.

Available tools:

  • test: runs table-driven tests for Jsonnet code
  • build: builds inlined Jsonnet code and package README
  • push: pushes Jsonnet code to a separate GitHub repository

Installation

To install devsonnet, first ensure you have Go installed on your system. Then, run:

go install github.com/marcbran/devsonnet@latest

This command will fetch and install the latest version of devsonnet.

Tools

Below is an explanation of each tool.

test

Runs table-driven tests for Jsonnet code.

Motivation

Writing more Jsonnet code made it clear that having a way to test things was becoming important. Since Jsonnet is side-effect free, it's a great match for table-driven tests, which are also common in Go. Tests like these started showing up across a few different projects, often using similar scripts to run them. This test tool is just a Go-based version of those scripts — built to make things more stable, consistent, and easier to use.

Usage
  1. Write your Jsonnet code tests in the expected test-table format. You can see examples of this format in the ./examples/test folder.

  2. Put these tests into files of the format *_tests.libsonnet.

  3. Run the test command.

    # Runs the tests in the current folder
    $ devsonnet test
    
    # Runs the tests in the specified folder
    $ devsonnet test ./examples/tests
    
    # Runs the tests with JSON output
    $ devsonnet test --json
    

    If all the tests are passing, the test command exits with 0 and just outputs the number of passed tests:

    Passed: 7/7
    

    If some of the tests are failing, the test command exits with 1 and also outputs details about the failing tests:

        Name: main_tests.libsonnet/romanNum/4
      Actual: IIII
    Expected: IV
    
        Name: main_tests.libsonnet/romanNum/5
      Actual: IIIII
    Expected: V
    
      Passed: 3/5
    

    When provided the --json flag, the command will output everything as machine-readable JSON. This is useful in case some of the test values are to be used for other tests such as integration tests.

build
Motivation

TODO

Usage

TODO

push
Motivation

TODO

Usage

TODO

License

devsonnet is licensed under the Apache License 2.0. See the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
pkg
internal
pkg
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL