Coder Social home page Coder Social logo

caye's Introduction

Caye: Code-configured CI

Disclaimer: Still a heavy work in progress. I'm a huge fan of this idea and plan to continue to expand it. Don't expect anything in here at the moment to be production ready. Ideas and contributions are always welcome!

Configuration based CI

Benefits

  • Approachable
  • Easy to read

Problems

  • Configuration is unclear (Requires browsing the docs like a chump)
  • Inflexible

Code configured CI

  • Import CI libraries as a dependency
  • Communicate with Caye server using Caye library (which is mostly a wrapper around the gRPC client).
  • Use within any "runner" system

Compare

Here's a basic example from a CI system that's "configuration-first", or expects a yaml configuration.

Some problems that a user and a developer may encounter:

  • The schema is unclear.
    • What keys are available where?
    • What types are expected?
    • What values are acceptable?
  • As a user, how do I run this without creating and pushing a new commit?
  • Reusability relies on the very uncommon, often unsupported yaml pointer syntax

Configuration-first

defaults: &defaults
  working_directory: ~/repo
  docker:
    - image: circleci/golang:1.13

version: 2
jobs:
  test:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Run tests
          command: go test ./...
  build:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Build
          command: go build -o ./bin/app ./cmd/app 
      - persist_to_workspace: root: ~/repo
          paths: [ bin ]
workflows:
  version: 2
  test:
    jobs:
      - test
      - build:
          requires: [ test ]

Code-first

This is a Go project. It's only natural that the definition for testing & building this project is another Go program.

package main

import "github.com/kminehart/caye"

func main() {
  client := caye.Default()
  defer client.Done()

  golang := client.Languages().Go()

  if err := golang.Test("./..."); err != nil {
    client.Fatal(err)
  }

  err := golang.Build(&caye.BuildOptions{
    Target: "./cmd/app",
    Output: "./bin/app",
  })

  if err != nil {
    client.Fatal(err)
  }
}

Benefits of this approach:

  • It's clear what options are available to the developer.
    • The developer likely already has tools (Autocompletion, definition jumping, native documentation from comments) for discovering available options
  • Running this is completely isolated. A user simply has to run this application like they would any other one.
  • This can be used with any CI system like Circle.
  • Reusability is achieved through the languages standard paradigms.

caye's People

Contributors

kminehart avatar

Stargazers

 avatar Bryan A. S. avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.