Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 1.68 KB

README.md

File metadata and controls

69 lines (49 loc) · 1.68 KB

drone

Jsonnet library for generating Drone CI configuration file.

Install

jb install github.com/crdsonnet/drone-libsonnet@master

Usage

// drone.jsonnet
local drone = import 'github.com/crdsonnet/drone-libsonnet/main.libsonnet';

local pipeline = drone.pipeline.docker;
local step = drone.pipeline.docker.step;

local pipelines = {
  build_pipeline:
    pipeline.new('build pipeline')
    + pipeline.withSteps([
      step.new('build', image='golang:1.19')
      + step.withCommands(['go build ./...']),
      step.new('test', image='golang:1.19')
      + step.withCommands(['go test ./...']),
    ]),
};

drone.render.getDroneObjects(pipelines)

Generate drone YAML

Install jsonnet

The suggested jsonnet version is go-jsonnet, you can get it here:

Installation instructions

Render the YAML file

drone jsonnet --stream \
              --format \
              --source <(jsonnet -J vendor/ drone.jsonnet) \
              --target .drone.yaml

Originally the intention was to render YAML with std.manifestYamlStream(), however at Grafana Labs we noticed that this function suffers from performance issues (taking 16 seconds to render a 23K LoC YAML). Its much faster to render the drone pipeline into json with drone.render.getDroneObjects() and use the drone cli tooling to do the YAML conversion. Alternatively jsonnet -y can be used, which delivers a valid YAML stream (json as valid YAML) but it might not look as nice.


Subpackages