Git Product home page Git Product logo

micro-ci's Introduction

micro-ci

Hello, thanks for checking out micro-ci.

micro-ci is a tiny continuous integration server, that tries to do very little. By this, we mean off loading as much logic as possible to other systems. In particular, this continuous integration server only supports GitHub and Nix.

This project is in its infancy, but if you'd like to play along at home, here's how.

Example

Getting Started

  1. Get an OAuth token.

    Navigate to https://github.com/settings/tokens and generate a new OAuth token. It only needs the repo:status permission.

  2. Add the webhook.

    Go to https://github.com/$YOUR_NAME/$YOUR_REPO/settings/hooks, changing $YOUR_NAME and $YOUR_REPO appropriately. Add a webhook with a URL of the format: http://$PUBLIC_HOST:8080/github/web-hook, where $PUBLIC_HOST is the publically accessible host of the server that will be running your builds.

    Set:

    • Content type: application/json
    • Secret: (anything you want)
    • Which events: at least "pull request", but you can also just use "everything".
  3. Configure the server.

    In the directory you plan to run micro-ci from, you'll need a config.dhall file. A template is:

    {
      repoRoot = "repositories",
      secret = ...,
      oauth = ...
    }

    Fill in oauth and secret according to values previously retrieved/entered.

  4. Run the server.

    On the machine that will run the builds, run

    nix-build ci.nix -A micro-ci
    ./result/bin/micro-ci
    
  5. Add a ci.nix file to your project.

    Finally, write a ci.nix file in your project. This Nix expression should evaluate to an attribute-set of derivations.

    For example, a Haskell project could use:

    with (import <nixpkgs> {});
    {
      cabal-build = haskellPackages.callPackage ./default.nix {};
    }

    But you can be as clever as you want. All that micro-ci cares about is if the derivation can be evaluated.

  6. Optional: Add status checks

    Open a pull request to check that everything works. If it looks good, you can enforce micro-ci to pass all jobs. Head to https://github.com/$YOUR_NAME/$YOUR_REPO/settings/branches and set up a protected branch and add the ci.nix statuses.

micro-ci's People

Contributors

ocharles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

micro-ci's Issues

Optionally build repo on push event

Have a configuration setting to allow building the repo on the push event and setting the commit status. This is useful for those of us who fly by the seat of our pants and push directly to master =P

This is the model of nix-simple-ci, but I'd rather consolidate these two projects than have two different projects, each with fewer features. Does that sound like a good idea to you? I'd be happy to open a PR to merge these and close this issue.

jobs.nix is unnecessary and restrictive

nix-instantiate can handle nix expressions that are attribute sets of other derivations just fine, so ci.nix can just be passed directly instead of preprocessing it with jobs.nix. This is nice because the user can organize their ci.nix however they want; e.g. they can have it return a list or just a single derivation, and nix-instantiate will handle it fine.

The problem is recursive attribute sets. jobs.nix handles this currently, but it's a little ad-hoc and gross. The more proper way to support this is to just require them to use recurseIntoAttrs if they want a nested ci.nix:

with import <nixpkgs> {}; {
  a = drv1;
  b = recurseIntoAttrs {
    c = drv2;
    d = recurseIntoAttrs {
      e = drv3;
    };
  };
}

This works with nix-instantiate out of the box. No jobs.nix required.

Use callCabal2nix?

I may be wrong, but this technique breaks down if the replacement version has a different set of dependencies than the one in super. You can use self.callCabal2nix "github" (...) instead to get the desired behavior.

Run more than one Nix process at a time

Currently we just fork three threads:

  1. main.
  2. A thread to turn a pull request into jobs.
  3. A thread to run jobs.

Obviously on large machines this is sub-optimal.

We could fork as many work threads as build-max-jobs as a start.

Long running persistency?

Currently we are persisting logs between runs, because we just write logs to files. However, we forget what jobs we have to run.

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.