jig

package module
v0.0.0-...-abaeddd Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

If it runs in Kubernetes, jig it locally before you ship it.

Declare a Kubernetes environment and the checks that prove it correct.

CI Go Reference License

A jig is one YAML file: a Kubernetes environment, and the checks that prove it correct. jig provides the cluster, builds and loads the images, installs what the workload depends on, deploys it, checks that it behaves, tears everything down, and always writes a report.

A jig holds the workpiece steady while the tool works on it, so every repeat comes out the same. jig holds the cluster, the images and the dependencies steady while the workload is checked: an operator, a Helm chart, raw manifests or an application image.

Why

Services that run on Kubernetes are mostly developed against Docker Compose. It's quick to start, but it isn't what production runs: no operators, no Helm charts, a hand-made Postgres in place of the one the platform provides. "It works with Compose" says little about the cluster, and CI rarely runs the Compose file at all.

jig puts the real environment in the repository instead. The platform team, or the developer, writes one jig.yaml: the services built from source, the data services from the same operators production uses, the official Helm charts, and the checks both sides care about, down to the log lines that say a service is healthy. Then:

  • The developer runs jig it in the repository, on a laptop, against a throwaway cluster that jig creates and removes.
  • CI runs the same file, so the jig the developer ran is the one the pipeline runs. Images and charts are signed and published only when it passes.

One file, the same run in both places, and no environment that only exists on someone's machine.

Install

curl -sSL https://raw.githubusercontent.com/intentd/jig/main/install.sh | bash

The script installs the latest release into ~/.jig/bin and adds it to your PATH. It checks every archive against the release's checksums.txt, and that file's cosign signature when cosign is installed. JIG_VERSION pins a release and JIG_INSTALL_DIR changes the directory.

With Homebrew:

brew install intentd/tap/jig

From source, with Go: make build (see Building).

The model

A complete jig is a Kubernetes environment plus the assertions that prove it correct. Every run has four phases, in order.

Phase Question Where
Environment What world does the jig run in? environment
Prepare What is deployed before, and between, the checks? prepare
Assert Is the thing under test behaving? expect
Report What was the result? always written

The environment, the prepare steps in order, the expectations after the environment, after a step or after prepare, then the report, always written

onFailure and finally run side effects (commands, kubectl, external calls) when something fails and when a run or an expectation ends. Checks can also ask what only a running cluster can show: that something stays true for a while (stays), that an object stopped changing (settles), that things happened in order (order), and that nothing warned or restarted during the run (guards).

A jig

name: shop-api
description: The shop API chart, and an order through it

env:
  API_URL: http://shop-api.shop.svc:8080

environment:
  cluster:
    provider: kind          # kind (default) | none
    name: shop-e2e
  images:
    - image: shop-api:dev
      build: { context: ., dockerfile: Dockerfile }
    - image: shop-worker:dev     # already built: loaded as is
  apply:
    - ./e2e/namespaces.yaml

prepare:
  - name: chart
    helm: { chart: ./charts/shop, namespace: shop, values: { image.tag: dev } }
    wait:
      - { kind: Deployment, name: shop-api, namespace: shop, ready: true }
  - name: order
    apply: ./e2e/order.yaml

expect:
  - name: the API is up
    after: chart
    timeout: 60s
    resources:
      - { kind: Deployment, name: shop-api, namespace: shop, ready: true }
  - name: the order is accepted
    after: order
    timeout: 30s
    commands:
      - run: curl -fsS $API_URL/orders/1

finally:
  kubectl:
    logs:
      - { labelSelector: app=shop-api, namespace: shop }

imports:
  - ./e2e/upgrade.yaml

Like a GitHub Actions workflow, the file has no apiVersion or kind: the keys are the document. They are name, description, env, functions, environment, prepare, expect, onFailure, finally and imports. The parser is strict: an unknown key is an error, and validation reports every problem at once.

Save it as jig.yaml and:

jig validate      # check it offline and see what a run will do
jig it            # run it (jig run, if you prefer)

Every command and flag is in docs/cli.md.

Examples

Each is a real reason to reach for jig, and runs as it is:

Example Use case Shows
commands A CLI or script, no cluster provider: none, a step's commands, exit codes and output assertions, the env forms, checks split into nested includes
app-image CI for an application image: build it and prove it serves before it is pushed images.build, deploy, a port-forward HTTP check, onFailure diagnostics
helm-chart A chart and its upgrade helm install, then an upgrade with new values and a restart, with expectations after each
manifests A migration Job that must complete, then be gone environment.apply, kubectl.get and logs checks, a delete step and a cleanup check
stack Several services, the Docker Compose case an image from a remote repository (git), two built here from one entry (forEach, build args, from an include file), deployed in needs order; match and expr: checks
ecosystem A workload and the data services it uses Postgres and Redis from their operators, a job reaching both through the envFrom Secret jig writes, ${{ ecosystem.… }}
examples itself One cluster for several tests: the suite of the four imports, wait, freshCluster
jig validate examples              # the suite
jig run examples/commands          # no cluster: runs anywhere
jig run examples/helm-chart        # creates a kind cluster, deletes it after

make test reads and checks every example, and runs commands. make validate-examples prints each one's plan; make examples builds jig and runs the suite.

Documentation

Writing a jig The environment and images (git, needs, forEach, build args), prepare steps and keep, expectations, match and expr:, over time and across the run (capture, stays, settles, snapshot, order, repeat, guards), includes, env, imports
Ecosystem Data services: Postgres, MariaDB, RabbitMQ, Redis, Kafka; their Secrets and ${{ ecosystem.… }}
The command line Commands and flags, ./..., the report (Markdown, JSON, JUnit)
As a library jig.Run, FromFile, Plan, and running your own format through jig

Building

make build              # → ~/.jig/bin/jig, stamped with the git version
make test
make validate-examples  # every example checked offline, with its plan
make examples           # the examples suite, on kind

jig builds on tools, KEL and kind.

Documentation

Overview

Package jig declares a Kubernetes environment and the checks that prove it correct. A jig is one YAML file: the cluster and its images and dependencies (environment), the steps that deploy and act on the workload (prepare), the checks (expect), and what to run on failure and at the end.

A run has four phases: Environment, Prepare, Assert, Report. Expectations run after the environment, after a named prepare step, or after the last one.

decl, err := jig.FromFile("jig.yaml")
errs := jig.Validate(d)
result, err := jig.Run(ctx, decl, jig.Options{})

Index

Constants

View Source
const (
	AfterEnvironment = spec.AfterEnvironment
	AfterPrepare     = spec.AfterPrepare
	ProviderKind     = spec.ProviderKind
	ProviderNone     = spec.ProviderNone
	LogsPodsAny      = spec.LogsPodsAny
	LogsPodsAll      = spec.LogsPodsAll
)
View Source
const FileName = "jig.yaml"

FileName is the file jig reads in a directory, and finds in discovery.

Variables

View Source
var ValidLogsPodsValues = spec.ValidLogsPodsValues

ValidLogsPodsValues are kubectl.logs' pods values.

Functions

func Discover

func Discover(root string, skip []string) ([]string, error)

Discover returns every jig.yaml under root, sorted, as absolute paths, leaving out the ones that only import (a suite runs its imports, which discovery finds on their own) and those whose path matches a skip pattern.

func IsExpectIncludeDoc

func IsExpectIncludeDoc(path string) (bool, error)

IsExpectIncludeDoc reports whether the file is an expect include.

func IsExternalIncludeDoc

func IsExternalIncludeDoc(path string) (bool, error)

IsExternalIncludeDoc reports whether the file is an external check include.

func Plan

func Plan(w io.Writer, d *Declaration)

Plan prints what a run of t does, in order: the cluster, the environment and its images, the steps, the imports, each expectation with when it runs, and the env names nothing sets. jig validate and jig run --dry-run print it; a caller validating its own format prints it for the jig.

func ValidClusterProviders

func ValidClusterProviders() []string

ValidClusterProviders returns the supported providers, in display order.

func Validate

func Validate(d *Declaration) []error

Validate returns every problem with s.

func ValidateExternal

func ValidateExternal(expects Expectations) []error

ValidateExternal returns every problem with the expectations' external checks.

func ValidateExternalCalls

func ValidateExternalCalls(loc string, calls []ExternalCheck) []error

ValidateExternalCalls returns every problem with the external calls at loc.

func ValidateKubectl

func ValidateKubectl(expects Expectations, baseDir string) []error

ValidateKubectl returns every problem with the expectations' kubectl checks; relative paths resolve against baseDir.

func ValidateKubectlBlock

func ValidateKubectlBlock(loc string, k *Kubectl, baseDir string, post bool) []error

ValidateKubectlBlock returns every problem with one kubectl block at loc; post is set for onFailure and finally.

func ValidateWith

func ValidateWith(d *Declaration, funcs template.FuncMap) []error

ValidateWith is Validate for a caller that runs with its own template functions (Options.Functions): templates are checked against funcs.

Types

type After

type After = spec.After

Expectations and the checks in them.

type ApplyEntries

type ApplyEntries = spec.ApplyEntries

A jig's vocabulary, for callers: they import jig, not its packages.

func ApplyShorthand

func ApplyShorthand(value *yaml.Node) ApplyEntries

ApplyShorthand reads an apply written as a path or a list of paths; nil when it is neither.

type ApplyEntry

type ApplyEntry = spec.ApplyEntry

A jig's vocabulary, for callers: they import jig, not its packages.

type ApplyInclude

type ApplyInclude = spec.ApplyInclude

A jig's vocabulary, for callers: they import jig, not its packages.

type Cluster

type Cluster = spec.Cluster

A jig's vocabulary, for callers: they import jig, not its packages.

type ClusterProvider

type ClusterProvider = spec.ClusterProvider

A jig's vocabulary, for callers: they import jig, not its packages.

type Command

type Command = spec.Command

A jig's vocabulary, for callers: they import jig, not its packages.

type Commands

type Commands = spec.Commands

A jig's vocabulary, for callers: they import jig, not its packages.

type DataService

type DataService = spec.DataService

A jig's vocabulary, for callers: they import jig, not its packages.

type Declaration

type Declaration = spec.Declaration

Declaration is a jig: a jig.yaml.

func FromFile

func FromFile(path string) (*Declaration, error)

FromFile reads and checks the jig at path: includes expanded, relative paths resolved from its directory. An error lists every problem.

func Suite

func Suite(name string, paths []string, wait string) *Declaration

Suite is a jig that imports paths in order, sharing one cluster, with wait between them (not before the first): what jig run ./... runs.

type Ecosystem

type Ecosystem = spec.Ecosystem

The ecosystem.

type EcosystemDefine

type EcosystemDefine = spec.EcosystemDefine

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemExport

type EcosystemExport = spec.EcosystemExport

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemKafka

type EcosystemKafka = spec.EcosystemKafka

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemMariadb

type EcosystemMariadb = spec.EcosystemMariadb

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemPostgres

type EcosystemPostgres = spec.EcosystemPostgres

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemRabbitmq

type EcosystemRabbitmq = spec.EcosystemRabbitmq

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemRedis

type EcosystemRedis = spec.EcosystemRedis

A jig's vocabulary, for callers: they import jig, not its packages.

type EcosystemSecrets

type EcosystemSecrets = spec.EcosystemSecrets

A jig's vocabulary, for callers: they import jig, not its packages.

type Environment

type Environment = spec.Environment

The environment.

type ExpectInclude

type ExpectInclude = spec.ExpectInclude

A jig's vocabulary, for callers: they import jig, not its packages.

type Expectation

type Expectation = spec.Expectation

A jig's vocabulary, for callers: they import jig, not its packages.

type ExpectationScope

type ExpectationScope = spec.ExpectationScope

A jig's vocabulary, for callers: they import jig, not its packages.

type Expectations

type Expectations = spec.Expectations

A jig's vocabulary, for callers: they import jig, not its packages.

type ExternalCheck

type ExternalCheck = spec.ExternalCheck

A jig's vocabulary, for callers: they import jig, not its packages.

type ExternalChecks

type ExternalChecks = spec.ExternalChecks

A jig's vocabulary, for callers: they import jig, not its packages.

type ExternalInclude

type ExternalInclude = spec.ExternalInclude

A jig's vocabulary, for callers: they import jig, not its packages.

type Finally

type Finally = spec.Finally

A jig's vocabulary, for callers: they import jig, not its packages.

type Function

type Function = spec.Function

A jig's vocabulary, for callers: they import jig, not its packages.

type Functions

type Functions = spec.Functions

A jig's vocabulary, for callers: they import jig, not its packages.

type HelmInclude

type HelmInclude = spec.HelmInclude

A jig's vocabulary, for callers: they import jig, not its packages.

type HelmInstall

type HelmInstall = spec.HelmInstall

A jig's vocabulary, for callers: they import jig, not its packages.

type HelmInstalls

type HelmInstalls = spec.HelmInstalls

A jig's vocabulary, for callers: they import jig, not its packages.

type ImagesInclude

type ImagesInclude = spec.ImagesInclude

ImagesInclude, ApplyInclude and HelmInclude are the files an include: entry in an images, apply or helm list names.

type Import

type Import = spec.Import

A jig's vocabulary, for callers: they import jig, not its packages.

type Kubectl

type Kubectl = spec.Kubectl

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlApply

type KubectlApply = spec.KubectlApply

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlAuth

type KubectlAuth = spec.KubectlAuth

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlCp

type KubectlCp = spec.KubectlCp

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlDelete

type KubectlDelete = spec.KubectlDelete

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlDescribe

type KubectlDescribe = spec.KubectlDescribe

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlEvents

type KubectlEvents = spec.KubectlEvents

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlExec

type KubectlExec = spec.KubectlExec

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlGet

type KubectlGet = spec.KubectlGet

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlLeaderElection

type KubectlLeaderElection = spec.KubectlLeaderElection

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlLogs

type KubectlLogs = spec.KubectlLogs

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlPatch

type KubectlPatch = spec.KubectlPatch

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlPortForward

type KubectlPortForward = spec.KubectlPortForward

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlRestart

type KubectlRestart = spec.KubectlRestart

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlScale

type KubectlScale = spec.KubectlScale

A jig's vocabulary, for callers: they import jig, not its packages.

type KubectlTop

type KubectlTop = spec.KubectlTop

A jig's vocabulary, for callers: they import jig, not its packages.

type LogsPods

type LogsPods = spec.LogsPods

A jig's vocabulary, for callers: they import jig, not its packages.

type OnFailure

type OnFailure = spec.OnFailure

Side effects.

type Options

type Options = runner.Options

Options configure a run.

type Paths

type Paths = spec.Paths

A jig's vocabulary, for callers: they import jig, not its packages.

type Provision

type Provision = spec.Provision

A jig's vocabulary, for callers: they import jig, not its packages.

type ResourceCheck

type ResourceCheck = spec.ResourceCheck

A jig's vocabulary, for callers: they import jig, not its packages.

type Restart

type Restart = spec.Restart

A jig's vocabulary, for callers: they import jig, not its packages.

type Restarts

type Restarts = spec.Restarts

A jig's vocabulary, for callers: they import jig, not its packages.

type Result

type Result = expect.Result

Result is a run's result, as the report shows it.

func Run

func Run(ctx context.Context, d *Declaration, o Options) (*Result, error)

Run runs d: the cluster, its images and environment, the prepare steps in order with the expectations after each, the imports, teardown, and the report. The error is set when the run could not complete or an expectation failed.

type SideEffects

type SideEffects = spec.SideEffects

A jig's vocabulary, for callers: they import jig, not its packages.

type Step

type Step = spec.Step

The test and its steps.

type Steps

type Steps = spec.Steps

A jig's vocabulary, for callers: they import jig, not its packages.

type Wait

type Wait = spec.Wait

A jig's vocabulary, for callers: they import jig, not its packages.

type Waits

type Waits = spec.Waits

A jig's vocabulary, for callers: they import jig, not its packages.

Directories

Path Synopsis
cmd
cli
Package cli is the jig command line: validate a jig, run it, clean up what a run kept, and print the version.
Package cli is the jig command line: validate a jig, run it, clean up what a run kept, and print the version.
jig command
Command jig runs declarative Kubernetes tests (see package cli).
Command jig runs declarative Kubernetes tests (see package cli).
pkg
check
Package check is the whole check of a jig, offline: its shape (spec), what a test without a cluster can't do, the files it names, its kubectl blocks and external calls, its side effects, and its images.
Package check is the whole check of a jig, offline: its shape (spec), what a test without a cluster can't do, the files it names, its kubectl blocks and external calls, its side effects, and its images.
ecosystem
Package ecosystem installs the data services a jig declares (environment.ecosystem): the operators they need, the data-services chart with values built from the declaration, and the Secrets that carry each service's connection details to the workload.
Package ecosystem installs the data services a jig declares (environment.ecosystem): the operators they need, the data-services chart with values built from the declaration, and the Secrets that carry each service's connection details to the workload.
ecosystem/operator
Package operator installs the Kubernetes operators jig's data services need: each a Helm chart or a release manifest, pinned per jig release.
Package operator installs the Kubernetes operators jig's data services need: each a Helm chart or a release manifest, pinned per jig release.
expect
Package expect provides E2E expectation execution and result types.
Package expect provides E2E expectation execution and result types.
expect/report
Package report renders jig results as Markdown, JSON and JUnit XML reports.
Package report renders jig results as Markdown, JSON and JUnit XML reports.
gitsource
Package gitsource checks out the repository an image is built from (environment.images[].git): a remote one, cloned once into a cache and fetched as git.pull says, or a local one, used as it is.
Package gitsource checks out the repository an image is built from (environment.images[].git): a remote one, cloned once into a cache and fetched as git.pull says, or a local one, used as it is.
kubectl
Package kubectl provides helpers for interacting with Kubernetes through kubectl.
Package kubectl provides helpers for interacting with Kubernetes through kubectl.
post
Package post tears a jig run down: what it applied and installed, removed in reverse once its expectations and imports have run.
Package post tears a jig run down: what it applied and installed, removed in reverse once its expectations and imports have run.
runner
Package runner runs a jig: it provides the cluster, loads the images, provisions the environment, runs the prepare steps in order with the expectations that follow each, runs the imports, tears down what it did, and writes the report.
Package runner runs a jig: it provides the cluster, loads the images, provisions the environment, runs the prepare steps in order with the expectations that follow each, runs the imports, tears down what it did, and writes the report.
spec
Package spec is the jig document: the environment, the prepare steps, the expectations and what runs on failure and at the end, as a jig.yaml declares them, with FromFile to read one and Validate to check it.
Package spec is the jig document: the environment, the prepare steps, the expectations and what runs on failure and at the end, as a jig.yaml declares them, with FromFile to read one and Validate to check it.

Jump to

Keyboard shortcuts

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