Giter Club home page Giter Club logo

hello-cd's Introduction

Try it out:

Set up a local Continuous Integration pipeline, running in docker

Steps:

  1. Install Docker.

  2. Run the following commands in order (let each script finish before running the next):

git clone https://github.com/helmesjo/hello-cd.git
cd hello-cd
./docker/start-registry.sh
./gocd/start-server.sh
./gocd/start-agent.sh

Note: It might take a while the first time, since no image-layers are present locally and must be downloaded.

This will:

  • Start a registry, where artifacts are stored as docker images.
  • Start a GoCD server, which polls the local repo for changes (commits) which kicks off the pipeline.
  • Start a GoCD agent with "docker-in-docker", inspired by the official dind image. It connects to the local server and gets delegated the individual tasks defined by the pipeline.

When all is done, you can run docker ps to verify that three containers are up and running (gocd server+agent & docker registry):

Within a minute when the server has spun up, go to localhost and you should see the pipeline:

Each run can be inspected, and stuff like code coverage can be viewed in custom tabs:

Current status, what works so far:

Building & Testing

  • Trivial one-step scripts, scripts/build.sh & scripts/analyze-coverage.sh (minimal, using CMake).
  • Requires only a C++ compiler to be present (cross-platform with docker = easy). Coverage-steps ignored if not GCC & Lcov installed.
  • No dependancies on anything else = Docker, GoCD or whatever is optional/easily replaceable.
  • All output/artifacts is relative to the install path, which can be passed from the command line (artifacts include libs, docs, code-coverage, test results etc, all in one place.).

Docker

  • Two, again trivial, scripts (docker/build.sh & docker/analyze-coverage.sh) doing nothing more than starting a container, passing the above build/analyze-coverage scripts as argument.
  • Dependencies like CMake & C++ compiler is managed in the docker image = very flexible.
  • The containers pass artifacts using private registry (docker commit/pull), currently pointing to "localhost:5000" (which is easily configurable if hosting registry remotely). Alternatively gocd publish/fetch artifact tasks can be used, but they are less storage efficient (docker reuses layers).
  • "Artifacts" are the whole build for that commit (source + compiled +docs etc.).

GoCD

  • Server & agents running in docker containers.
  • Agents using "docker in docker" (through socket-binding, not pure "dind").
  • All logic for the building & testing is in the repo, so starting new server instances is trivial.
  • Basic, ready to go scripts to fire up server & registry, automatically connecting agents to the server. (this should be replaced by docker-compose, but currently there is some host-setup needed which isn't trivial with docker-compose).
  • Pipeline configuration is kept in repository (server is thus minimal, basically contains nothing more than a "load remote config"-config).
  • Jobs are minimal, not caring about artifacts etc. (this is managed by the docker build-scripts). Jobs just run "build.sh" & "runtests.sh", keeping the "heavy" logic out of the server.

TODO

  • Consider moving over to python & behave for end-to-end tests. See this.
  • Fix docker-compose for GoCD setup, including registry.
  • Add test-result output (tests passed/failed, details of failes etc), perferably in HTML-friendly format.
  • Add support for test coverage, result perferably in HTML-friendly format.
  • Add support for static analysis, result perferably in HTML-friendly format.
  • Host local gitrepo on docker http server (nginx) and reference this from server & agents using the overlay network driver.
  • Do above as separate "pipeline steps", so that they can be easily moved around in the pipeline config depending on their importance/time consumption etc.

hello-cd's People

Contributors

helmesjo avatar

Watchers

James Cloos 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.