Skip to content

Commit

Permalink
Merge pull request #125 from go-atomci/v1.5.0-feat-app-refactor
Browse files Browse the repository at this point in the history
release 1.5.0
  • Loading branch information
colynn committed Apr 29, 2022
2 parents 3318260 + 1fb237a commit 64f5607
Show file tree
Hide file tree
Showing 100 changed files with 3,312 additions and 1,975 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/codecov.yml
@@ -0,0 +1,20 @@
name: Test and coverage

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Go Module Downloads
run: go mod tidy
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions .github/workflows/sync-to-gitee.yml
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- v1.5.0-feat-app-refactor
jobs:
sync:
runs-on: ubuntu-latest
Expand Down
36 changes: 33 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -32,10 +32,40 @@
# use the pull.rebase config option to change the behavior for every git pull (instead of only newly-created branches)
git config pull.rebase true
```
3. 如果您提交的代码涉及到数据迁移,请在`internal/migrations`目录下添加迁移脚本,并在`migration.go`中注册该脚本
```go
type MigrationXXXXX struct {
}

func (m MigrationXXXXX) GetCreateAt() time.Time{
//时间请设定为提交代码的当前时间,以便于系统自动记录迁移历史
return time.Date(2022, 1, 1, 0, 0, 0, 0, time.Local)
}
func (m Migration20220101) Upgrade(ormer orm.Ormer) error{
//样例代码如下,err不为nil时,会自动回滚所有操作
/*
err := ormer.Raw(xxxx).Exec()
return err
*/

}

3. Create a pull request to the main repository on GitHub.
4. When the reviewer makes some comments, address any feedback that comes and update the pull request.
5. When your contribution is accepted, your pull request will be approved and merged to the main branch.
```

```go
//在migrations.go中
func InitMigration() {
migrationTypes := MigrationTypes{
//注册
new(MigrationXXXXX),
//...
}

}
```
4. Create a pull request to the main repository on GitHub.
5. When the reviewer makes some comments, address any feedback that comes and update the pull request.
6. When your contribution is accepted, your pull request will be approved and merged to the main branch.

### 2. 文档贡献

Expand Down
6 changes: 4 additions & 2 deletions README.md
@@ -1,5 +1,9 @@
# atomci

<a href="https://goreportcard.com/report/github.com/go-atomci/atomci"><img src="https://goreportcard.com/badge/github.com/go-atomci/atomci" alt="A+"></a>
[![codecov](https://codecov.io/gh/go-atomci/atomci/branch/master/graph/badge.svg?token=VPJGT3405P)](https://codecov.io/gh/go-atomci/atomci)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/go-atomci/atomci/blob/master/LICENSE)

AtomCI 致力于让中小企业快速落地Kubernetes,代码均已开源, __您的star__ 是我们开源的动力,非常感谢(:

* github: https://github.com/go-atomci/atomci
Expand Down Expand Up @@ -180,7 +184,5 @@ __AtomCI__ 因你而变。
|`ldap::baseDN`| OU=Xxx,DC=xx,DC=com | |
| JWT 配置 <br/>|
|`jwt::secret`| changemeforsecurity | jwt的加密使用的字段,建议修改 |
| K8s配置 <br/> |
|`k8s::configPath`| ./conf/k8sconfig | k8s 配置文件存放路径,不建议修改|
|<br/>|
|`atomci::url`| http://localhost:8080 | AtomCI 回调地址 |
16 changes: 9 additions & 7 deletions cmd/atomci/main.go
Expand Up @@ -22,18 +22,20 @@ import (
"github.com/astaxie/beego"
_ "github.com/go-sql-driver/mysql" // import your used driver

"github.com/go-atomci/atomci/internal/initialize"
"github.com/go-atomci/atomci/internal/migrations"
"github.com/go-atomci/atomci/internal/models"

"github.com/go-atomci/atomci/internal/cronjob"
_ "github.com/go-atomci/atomci/internal/initialize"
_ "github.com/go-atomci/atomci/internal/models"
"github.com/go-atomci/atomci/internal/routers"
"github.com/go-atomci/atomci/pkg/kube"
)

func init() {
kube.Init()
}

func main() {
models.InitDB()
migrations.Migrate()
// TODO: resource items migrate later
initialize.Init()

cronjob.RunPublishJobServer()
beego.Info("Beego version:", beego.VERSION)

Expand Down
3 changes: 0 additions & 3 deletions conf/app.conf
Expand Up @@ -36,9 +36,6 @@ baseDN = OU=Xxx,DC=xx,DC=com
[jwt]
secret = changemeforsecurity

[k8s]
configPath = ./conf/k8sconfig

# build/deploy callback
[atomci]
url = http://localhost:8080
Expand Down
57 changes: 57 additions & 0 deletions conf/app.conf.template
@@ -0,0 +1,57 @@
## 模板配置,承载完整最新的配置内容
[default]
appname = atomci
# 默认监听端口
httpport = 8080
runmode = dev
copyrequestbody = true

[log]
logfile = "log/atomci.log"
## log level
# 0: LevelEmergency = iota
# 1: LevelAlert
# 2: LevelCritical
# 3: LevelError
# 4: LevelWarning
# 5: LevelNotice
# 6: LevelInformational
# 7: LevelDebug
level = 7
separate = ["error"]

[DB]
# 数据库相关配置,目前仅支持mysql5.7+
url = root:root@tcp(127.0.0.1:3306)/atomci?charset=utf8mb4&loc=Local
debug = false
rowsLimit = 5000
maxIdelConns = 100
maxOpenConns = 200

[ldap]
# 支持配置LDAP
host = ldap.xxx.com
port = 389
bindDN = ldap@xx.com
bindPassword = Xxx..,
userFilter = (samaccountname=%s)
baseDN = OU=Xxx,DC=xx,DC=com

[jwt]
secret = changemeforsecurity

[atomci]
# atomci后端服务地址,用于k8s/jenkins进行回调,因此请确保地址是可以被k8s集群(jenkins agent)访问到
url = http://localhost:8080

# 通知配置
[notification]
# 钉钉通知
dingEnable = 1
ding = "https://oapi.dingtalk.com/robot/send?access_token=faketoken"
# 邮件通知
mailEnable = 1
smtpHost = "smtp.host"
smtpPort = 465
smtpAccount = "fake@mail.com"
smtpPassword = "pwd"
15 changes: 15 additions & 0 deletions constant/const.go
Expand Up @@ -54,3 +54,18 @@ const (
// HelmDeployType helm 部署
HelmDeployType = "helm"
)

// integrate type
const (
SCMGitlab = "gitlab"
SCMGithub = "github"
SCMGitea = "gitea"
SCMGitee = "gitee"
SCMGogs = "gogs"
IntegrateKubernetes = "kubernetes"
IntegrateJenkins = "jenkins"
IntegrateRegistry = "registry"
)

var Integratetypes = []string{IntegrateKubernetes, IntegrateJenkins, IntegrateRegistry}
var ScmIntegratetypes = []string{SCMGitlab, SCMGithub, SCMGitea, SCMGitee, SCMGogs}
3 changes: 0 additions & 3 deletions deploy/docker-compose/conf/app.conf
Expand Up @@ -36,9 +36,6 @@ baseDN = OU=Xxx,DC=xx,DC=com
[jwt]
secret = changemeforsecurity

[k8s]
configPath = ./conf/k8sconfig

# build/deploy callback
[atomci]
url = http://localhost:8080
11 changes: 0 additions & 11 deletions deploy/docker-compose/init.sh
Expand Up @@ -30,16 +30,5 @@ then
echo "$NOT_UP restart failed, please check docker log use 'docker-compose logs [docker-name]'"
fi

MYSQL_DB=$(grep "MYSQL_DATABASE" docker-compose.yml | awk -F':' '{print $2}')
MYSQL_DB_STRIP=`echo ${MYSQL_DB} | sed 's/ //g'`

MYSQL_PASSWORD=$(grep "MYSQL_ROOT_PASSWORD" docker-compose.yml | awk -F':' '{print $2}')
MYSQL_PASSWORD_STRIP=$(echo $MYSQL_PASSWORD | sed 's/ //g')

echo "mysql database: $MYSQL_DB"
echo "root password: $MYSQL_PASSWORD_STRIP"

docker exec mysql mysql -uroot -p$MYSQL_PASSWORD_STRIP $MYSQL_DB_STRIP < mysql/sql/v1.3.2_00.sql

# init result verify
[ $? -eq 0 ] && echo -e "AtomCI 初始化成功(:\n\n访问atomci: http://localhost:8090 \n" || echo -e "AtomCI 初始化失败, 请确认atomci 容器日志,\n或是 https://github.com/go-atomci/atomci-press/issues/new 反馈你的问题(:"
26 changes: 0 additions & 26 deletions deploy/release/sql/v1.3.2_00.sql

This file was deleted.

12 changes: 7 additions & 5 deletions go.mod
Expand Up @@ -32,29 +32,31 @@ replace (

require (
github.com/astaxie/beego v1.12.1
github.com/casbin/beego-orm-adapter/v2 v2.0.2 // indirect
github.com/casbin/beego-orm-adapter/v3 v3.0.2
github.com/casbin/casbin/v2 v2.37.4
github.com/colynn/go-ldap-client/v3 v3.0.0-20201016034829-4c1455a490de
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/drone/go-scm v1.19.0
github.com/drone/go-scm v1.20.0
github.com/ghodss/yaml v1.0.0
github.com/go-atomci/workflow v0.0.0-20211126090842-208f180b47ab
github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2
github.com/isbrick/tools v0.0.0-20211027093338-a3a0ded37175
github.com/jarcoal/httpmock v1.1.0
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pborman/uuid v1.2.0
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013 // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
Expand Down

0 comments on commit 64f5607

Please sign in to comment.