Skip to content

Commit

Permalink
Merge pull request #33 from LuBingtan/dev
Browse files Browse the repository at this point in the history
docs: Update readme
  • Loading branch information
kuilei-bot[bot] authored Mar 1, 2023
2 parents 230fe53 + e92cd5d commit 58c3759
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 27 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
ARG GOPROXY
RUN go env -w GOPROXY=$GOPROXY && go mod download
RUN go env -w GOPROXY=${GOPROXY:-https://proxy.golang.org,direct} && \
go mod download

# Copy the go source
COPY . .
Expand All @@ -20,7 +21,7 @@ COPY . .
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -o kuilei github.com/airconduct/kuilei/cmd/kuilei
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -o kuilei github.com/airconduct/kuilei/cmd/kuilei

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ release:
docker buildx build --platform=linux/amd64,linux/arm64 \
--label=${VERSION} \
--build-arg GOPROXY=${GOPROXY} \
-t ${IMAGE_REGISTRY}:${VERSION} --push .
-t ${IMAGE_REGISTRY}:${VERSION} \
-t ${IMAGE_REGISTRY}:latest --push .

# kind-setup:
# kind create cluster --config hack/kind.yaml
Expand Down
112 changes: 88 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,108 @@
# Kuilei
<h1>Kuilei</h1>

This project is inspired by [Prow](https://github.com/kubernetes/test-infra/tree/master/prow), and implements chat-ops, automatic PR merging in a form of [Probot](https://github.com/probot/probot) Github App
> Prow is a Kubernetes based CI/CD system. Jobs can be triggered by various types of events and report their status to many different services. In addition to job execution, Prow provides GitHub automation in the form of policy enforcement, chat-ops via /foo style commands, and automatic PR merging.

## About the name Kuilei
- [About](#about)
- [Features](#features)
- [Chat-Ops](#chat-ops)
- [CI/CD Pipeline](#cicd-pipeline)
- [Automatic Pull Requests Merging](#automatic-pull-requests-merging)
- [Automatic notification](#automatic-notification)
- [Mulitple Git Server Backend](#mulitple-git-server-backend)
- [Quick start](#quick-start)
- [Create GitHub App](#create-github-app)
- [Using docker to start hook server](#using-docker-to-start-hook-server)
- [Build From Source](#build-from-source)
- [Contributing](#contributing)
- [License](#license)

## About
> Kuilei(傀儡) is a kind of wooden puppet in ancient China, usually controlled from above using wires or strings depending on regional variations, and is often used in puppetry.
>
> There are also some masters who are proficient in mechanics who can make puppets that can move automatically, similar to robots today. The two most famous of them are [Mo Zi](https://en.wikipedia.org/wiki/Mozi) and [Lu Ban](https://en.wikipedia.org/wiki/Lu_Ban), who lived in the early portion of the Warring States period in Chinese history.
## Features

Commands:
- `/lgtm`: add `lgtm` label
- `/approve`: add `approved` label
- `/hold`: add `do-not-merge/hold` label
- `/kind bug`: add `kind/bug` label

Automatic PR merging:
- Merge the PR when label `lgtm` and `approved` both exist
- Do not merge the PR when label `do-not-merge/hold` exist

## Setup
### Chat-Ops
Slash commands (commands with `/` as prefix):
- **Labels**
- [x] `/lgtm [cancel]`: Add/Remove `lgtm` label to a pull request or issue.
- [x] `/approve [cancel]`: Add/Remove `approved` label to a pull request or issue.
- [x] `/[remove-]label xxx`: Add/Remove arbitrary label to a pull request or issue.
- [ ] `/hold [cancel]`: Add/Remove `do-not-merge/hold` label to a pull request or issue.
- **Issue/PR management**
- [ ] `/assign` Assign
- [ ] `/close` Close
- [ ] `/milestone`

Natural language parsing:
> *TODO*
### CI/CD Pipeline
Supported pipeline configuration:
- [ ] GitHub style pipeline configuration

Supported pipeline backend:
- [ ] Tekton pipeline
- [ ] Kubeflow pipeline (MLOps specific)
- [ ] Argo workflow
- [ ] Raw kubernetes
- [ ] Raw docker

### Automatic Pull Requests Merging
Just like `tide` in prow:
- [x] Merge pull requests with required labels
- e.g. merge pull requests with labels `lgtm` and `approved`
- [x] Keep pull requests with certain labels from merging
- e.g. hold pull requests with label `do-not-merge/hold`
- [ ] Reset mandatory CI job before merging
- [ ] Using merge-pool to manage multiple pull requests

### Automatic notification

- [ ] E-mail notification
- [ ] Slack notification
- [ ] WeCom notification
- [ ] DingTalk notification
- [ ] WeChat notification

### Mulitple Git Server Backend

- [x] GitHub
- [ ] GitLab
- [ ] Raw SSH Git Server
- [ ] Gerrit

## Quick start
### Create GitHub App
Follow the [official document](https://docs.github.com/en/apps/creating-github-apps/creating-github-apps/creating-a-github-app) to create your GitHub App.

Then go to the App settings page
- Get the `App ID`
- Set in the `webhook secret` blank and save it in local file `.env/web_secret`
- Generate a `priviate key` and save it in local file `.env/private.pem`
- Set the `Webhook URL` to `http://<IP>:7771/hook`
### Using docker to start hook server

```sh
# Build
make build-local

# Run the bot
./bin/kuilei -h
# Set App ID
APP_ID=
# Pull latest docker image
docker run -d --name kuilei --restart=always \
-v `pwd`/.env:/etc/kuilei \
-p 7771:7771 airconduct/kuilei hook \
--github.appid ${APP_ID} \
--github.hmac-token-file /etc/kuilei/web_secret \
--github.private-key-file /etc/kuilei/private.pem \
--address="0.0.0.0"
```

## Docker

## Build From Source
```sh
# 1. Build docker image
# Build docker image
docker build -t kuilei .

# 2. Start container
docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> kuilei
```

## Contributing
Expand Down
1 change: 1 addition & 0 deletions pkg/plugins/internal/lgtm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var _ = Describe("Plugin lgtm", func() {
}
return plugins.OwnersConfiguration{Reviewers: []string{"foouser"}}, nil
}),
LoggerClient: mock.FakeLoggerClient(),
}, []string{"--allow-author=true"}...)

It("Should not add lgtm", func() {
Expand Down

0 comments on commit 58c3759

Please sign in to comment.