duci

command module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 8 Imported by: 0

README

duci

Language GitHub release GoDoc Build Status Coverage Status Go Report Card codebeat badge MIT License

duci [zushi] (Docker Under Continuous Integration) is a small ci server.

DSL is Unnecessary For CI

Let's define the task in the task runner.
Let's define the necessary infrastructure for the task in the Dockerfile.
duci just only execute the task in docker container.

Features

  • Execute the task in Docker container
  • Execute the task triggered by GitHub pull request comment or push
  • Execute tasks asynchronously
  • Create GitHub commit status
  • Store and Show logs

How to use

Target Repository

The target repository must have Dockerfile in repository root or .duci/Dockerfile.
If there is .duci/Dockerfile, duci read it preferentially.

In Dockerfile, I suggest to use ENTRYPOINT.

e.g.

ENTRYPOINT ["mvn"]
CMD ["compile"]
ENTRYPOINT ["fastlane"]
CMD ["build"]

When push to github, duci execute mvn compile / fastlane build.
And when comment ci test on github pull request, execute mvn test / fastlane test.

Using Volumes

You can use volumes options for external dependency, cache and etc.
Set configurations in .duci/config.yml

volumes:
  - '/path/to/host/dir:/path/to/container/dir'

Server Settings

Install Server

If you have already set $GOPATH, you can install it with the following command.

$ go get -u github.com/duck8823/duci
Setting SSH (optional)

If target repository is private, You can use SSH key to clone repository from github.com.
Please set the public key of the pair at https://github.com/settings/keys.

Add Webhooks to Your GitHub repository

duci start to listen webhook with port 8080 (default) and endpoint /.
Add endpoint of duci to target repository.
https://github.com/<owner>/<repository>/settings/hooks

Run Server
$ duci server
Server Configuration file

You can specify configuration file with -c option. The configuration file must be yaml format. Possible values ​​are as follows.

server:
  workdir: '/path/to/tmp/duci'
  port: 8080
  database_path: '$HOME/.duci/db'
github:
  # (optional) You can use SSH key to clone. ex. '${HOME}/.ssh/id_rsa'
  ssh_key_path: ''
  # For create commit status. You can also use environment variable
  api_token: ${GITHUB_API_TOKEN}
job:
  timeout: 600
  concurrency: 4 # default is number of cpu

You can check the default value.

$ duci server -h

Using Docker

You can use Docker to run server.

$ docker run -p 8080:8080 \
             -e GITHUB_API_TOKEN=<your toekn> \
             -v /var/run/docker.sock:/var/run/docker.sock \
             -v ~/.ssh:/root/.ssh:ro \ 
             duck8823/duci

Read job log

GitHub send payload as webhook including X-GitHub-Delivery header.
You can read job log with the X-GitHub-Delivery value formatted UUID.

$ curl -XGET http://localhost:8080/logs/{X-GitHub-Delivery}

The endpoint returns NDJSON (Newline Delimited JSON) formatted log.

{"time":"2018-09-21T22:19:42.572879+09:00","message":"Step 1/10 : FROM golang:1.11-alpine"}
{"time":"2018-09-21T22:19:42.573093+09:00","message":"\n"}
{"time":"2018-09-21T22:19:42.573494+09:00","message":" ---\u003e 233ed4ed14bf\n"}
{"time":"2018-09-21T22:19:42.573616+09:00","message":"Step 2/10 : MAINTAINER shunsuke maeda \u003cduck8823@gmail.com\u003e"}
{"time":"2018-09-21T22:19:42.573734+09:00","message":"\n"}
...

License

MIT License

Copyright (c) 2018 Shunsuke Maeda

See LICENSE file

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
service/docker/mock_docker
Package mock_docker is a generated GoMock package.
Package mock_docker is a generated GoMock package.
service/git/mock_git
Package mock_git is a generated GoMock package.
Package mock_git is a generated GoMock package.
service/github/mock_github
Package mock_github is a generated GoMock package.
Package mock_github is a generated GoMock package.
service/logstore/mock_logstore
Package mock_logstore is a generated GoMock package.
Package mock_logstore is a generated GoMock package.
service/runner/mock_runner
Package mock_runner is a generated GoMock package.
Package mock_runner is a generated GoMock package.
data
infrastructure
docker/mock_docker
Package mock_docker is a generated GoMock package.
Package mock_docker is a generated GoMock package.
store/mock_store
Package mock_store is a generated GoMock package.
Package mock_store is a generated GoMock package.
presentation

Jump to

Keyboard shortcuts

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