Skip to content

Commit

Permalink
chore: update various files and configurations
Browse files Browse the repository at this point in the history
- Add pre-commit hook for running checks on golang files before committing
- Update the GO_VERSION environment variable in the lint.yml workflow file from "1.20" to "1.21"
- Update the GO_VERSION environment variable in the golangci.yml file from "1.20" to "1.21"
- Update the .go-header.txt file with a new copyright year, changing "2023, easysoft" to "2024, zentao"
- Update the .golangci.yml file to add a template path for the goheader linter
- Add a launch.json file in the .vscode directory
- Add an entry for "launch package" in the configurations section of the launch.json file
- Update the OWNERS file, removing "zhengyuansheng" from the approvers and reviewers lists
- Update the README.md file, changing the supported ZenTao version from "18.3" to "18.11"
- Update the default GO_VERSION environment variable in the Taskfile.yml file from "1.20" to "1.21"
- Update the docker-compose.yaml file, changing the image tag for the "zentao" service from "18.7" to "18.11"
- Remove the okteto.yml file

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Mar 5, 2024
1 parent f5171c2 commit 694f796
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 107 deletions.
29 changes: 29 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env sh

set -e

command_exists() {
command -v "$@" > /dev/null 2>&1
}

echo Running pre-commit hook

if ! command_exists task
then
echo "task could not be found - install task before running pre-commit: https://taskfile.dev/installation/"
exit 1
fi

# Run pre-commit, this checks if we changed any golang files and runs the checks.
# The files are then git-added
FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep .go | sed 's| |\\ |g')
if [ -n "$FILES" ]; then
if ! task fmt; then
echo "Error running make check - please fix before committing"
echo "if this is a mistake you can skip the checks with 'git commit --no-verify'"
exit 1
fi
echo "$FILES" | xargs git add
fi

exit 0
18 changes: 9 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: check

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
TZ: Asia/Shanghai

permissions: write-all
Expand Down Expand Up @@ -32,11 +32,10 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: ${{ env.GO_VERSION }}
- name: install task
run: |
echo "install task"
go install github.com/go-task/task/v3/cmd/task@latest
- name: Install Task
uses: arduino/setup-task@v2
- name: Run Check License
run: |
task gencopyright
Expand All @@ -59,10 +58,9 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install task
run: |
echo "install task"
go install github.com/go-task/task/v3/cmd/task@latest
check-latest: true
- name: Install Task
uses: arduino/setup-task@v2
- name: Run Linter
run: |
task lint
Expand All @@ -86,6 +84,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
- name: Lint package
uses: golangci/golangci-lint-action@v4
with:
Expand All @@ -103,6 +102,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
- name: Test package
run: |
go test -v ./... -coverprofile=coverage.txt -covermode count
Expand Down
2 changes: 1 addition & 1 deletion .go-header.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright 2023, easysoft
Copyright 2024, zentao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
21 changes: 10 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ linters-settings:
misspell:
locale: US
ignore-words:
- noteable
unused:
# Treat code as a program (not a library) and report unused exported identifiers
check-exported: false
- noteable

goheader:
template-path: .go-header.txt

linters:
enable:
Expand All @@ -33,9 +33,10 @@ linters:
- errorlint
- exportloopref
- goconst
- revive
- gosimple
- govet
- goheader
- gomnd
- ineffassign
- megacheck
- misspell
Expand All @@ -45,13 +46,11 @@ linters:
- unconvert
- unused
- whitespace
- goheader
disable-all: true
fast: false

issues:
# Maximum issues count per one linter (set to 0 to disable)
max-issues-per-linter: 0

# Maximum count of issues with the same text (set to 0 to disable)
max-same-issues: 0
exclude-rules:
- linters:
- goheader
text: "Copyright"
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
2 changes: 0 additions & 2 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
approvers:
- ysicing
- zhengyuansheng
reviewers:
- ysicing
- zhengyuansheng
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Zentao API client enabling Go programs to interact with Zentao in a simple and u

## NOTE

基于ZenTao最新开源版本 [`18.3`](https://github.com/quicklyon/zentao-docker), 即将适配最新版本`20.dev`
基于ZenTao最新开源版本 [`18.11`](https://github.com/quicklyon/zentao-docker), 即将适配最新版本`20`

## 支持

Expand Down Expand Up @@ -114,18 +114,13 @@ Zentao API client enabling Go programs to interact with Zentao in a simple and u
> 推荐本地部署
```bash
# 部署方式: okteto up -f hack/okteto.yml --deploy
地址: https://zentao-easysoft.cloud.okteto.net
账号: admin/jaege1ugh4ooYip7
# 部署方式: docker compose -f hack/zentao.yml up -d
地址: https://zentao.demo.qucheng.cc
账号: demo/quickon4You
```

## TODO

- [ ] 优化代码 & 添加单元测试
- [ ] 支持二次开发API

### 已知问题

> 将在`20`版本优化
- [ ] 部分字段接口返回有时候是结构体有时候是字符串
22 changes: 20 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# https://taskfile.dev

version: '3'
version: "3"

vars:
GOPROXY: 'https://goproxy.cn,direct'
GOPROXY: "https://goproxy.cn,direct"
GOSUMDB: sum.golang.google.cn

tasks:
Expand Down Expand Up @@ -41,13 +41,31 @@ tasks:
- task: gofmt
- task: golint

initgithooks:
desc: pre dev init githooks
run: once
cmds:
- git config core.hooksPath .githooks

dev:
desc: dev
cmds:
- docker compose -f hack/docker-compose.yml up -d

clean:
desc: clean
cmds:
- docker compose -f hack/docker-compose.yml down -v

fmt:
cmds:
- task: initgithooks
- task: gomod
- task: gencopyright
- task: gofmt
- task: golint

default:
cmds:
- task: initgithooks
- task: fmt
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8=
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand All @@ -32,7 +29,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -67,10 +63,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
32 changes: 17 additions & 15 deletions hack/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2022, easysoft
# Copyright 2024, Zentao
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,35 +17,37 @@
version: '3.8'
services:

# mysql service for zentao
zentao-mysql:
image: bitnami/mysql:8.1
container_name: zentao-mysql
# db service for zentao
zentao-db:
image: bitnami/mariadb:10.6
container_name: zentao-db
restart: always
volumes:
- 'zentao_db:/bitnami/mysql/data'
- 'zentao_db:/bitnami/mariadb'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=pass4Zentao
- MYSQL_DATABASE=zentao
- MARIADB_ROOT_PASSWORD=pass4Zentao
- MARIADB_DATABASE=zentao
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATION=utf8mb4_unicode_ci

# zentao service
zentao:
image: easysoft/zentao:18.7
image: easysoft/zentao:18.11
container_name: zentao
restart: always
ports:
- '80:80'
volumes:
- 'zentao_data:/data'
depends_on:
- zentao-mysql
- zentao-db
environment:
- MYSQL_HOST=zentao-mysql
- MYSQL_PORT=3306
- MYSQL_USER=root
- MYSQL_PASSWORD=pass4Zentao
- MYSQL_DB=zentao
- ZT_MYSQL_HOST=zentao-db
- ZT_MYSQL_PORT=3306
- ZT_MYSQL_USER=root
- ZT_MYSQL_PASSWORD=pass4Zentao
- ZT_MYSQL_DB=zentao
- EASYSOFT_DEBUG=true
- DEBUG=1
- IS_CONTAINER=true
Expand Down
52 changes: 0 additions & 52 deletions hack/okteto.yml

This file was deleted.

0 comments on commit 694f796

Please sign in to comment.