Skip to content

Commit

Permalink
ci: add ci.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
googs1025 committed Mar 25, 2024
1 parent 4f0e5a0 commit 2d9f773
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Run go fmt test
run: sudo hack/verify-gofmt.sh
env:
GO111MODULE: auto

- name: Run unit test
run: go test -v ./pkg/controller
run: go test -v ./pkg/controller

- name: Build the project
run: go build -v ./...
5 changes: 5 additions & 0 deletions hack/update-gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set -o nounset
set -o errexit
set -o pipefail

find . -name "*.go" | grep -v vendor | xargs gofmt -s -w
24 changes: 24 additions & 0 deletions hack/verify-gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set -o errexit
set -o nounset
set -o pipefail

HELM_ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${HELM_ROOT}"

find_files() {
find . -not \( \
\( \
-wholename './output' \
-o -wholename '*/vendor/*' \
\) -prune \
\) -name '*.go'
}

GOFMT="gofmt -s"

bad_files=$(find_files | xargs $GOFMT -l)
if [[ -n "${bad_files}" ]]; then
echo "Please run hack/update-gofmt.sh to fix the following files:"
echo "${bad_files}"
exit 1
fi
9 changes: 6 additions & 3 deletions pkg/apis/daemonjob/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ type DaemonJob struct {
}

type DaemonJobSpec struct {
// GlobalParameters 全局参数
GlobalParams GlobalParams `json:"globalParams,omitempty"`
ExcludeNodeList string `json:"excludeNodeList,omitempty"`
// GlobalParams 全局参数
GlobalParams GlobalParams `json:"globalParams,omitempty"`
// ExcludeNodeList 过滤出不需运行的 node List, ex: 如果 node3 node4 不需要
// 运行 DaemonJob ,则填入: "node3,node4"
ExcludeNodeList string `json:"excludeNodeList,omitempty"`
v1.JobSpec
}

Expand All @@ -43,6 +45,7 @@ type DaemonJobStatus struct {
// 用于存储 map 是 name/namespace 进行存储
JobStatusList map[string]v1.JobStatus `json:"jobStatusList,omitempty"`
// 记录 JobFlow 状态
// TODO: 使用特定类型封装
State string `json:"state,omitempty"`
}

Expand Down
11 changes: 9 additions & 2 deletions pkg/apis/jobflow/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ type GlobalParams struct {
type ErrorHandler struct {
// 用于赋值 job 模版
corev1.PodSpec

// JobTemplate 用于赋值 job 模版
JobTemplate v1.JobSpec `json:"jobTemplate,omitempty"`
// JobTemplateRef 模版实例对象 JobTemplate
// 如果 JobTemplateRef 不为空,会优先使用此对象,
// 自动忽略 JobTemplate 字段内容
JobTemplateRef string `json:"jobTemplateRef,omitempty"`
// 支持脚本命令
Script string `json:"script,omitempty"`
}
Expand All @@ -56,16 +60,19 @@ type Flow struct {
// JobTemplate 用于赋值 job 模版
JobTemplate v1.JobSpec `json:"jobTemplate,omitempty"`
// JobTemplateRef 模版实例对象 JobTemplate
// 如果 JobTemplateRef 不为空,会优先使用此对象,
// 自动忽略 JobTemplate 字段内容
JobTemplateRef string `json:"jobTemplateRef,omitempty"`
// Dependencies 依赖项,其中可以填写多个 依赖的 job name
// ex: 如果 job3 依赖 job1 and job2, 就能
// ex: 如果 job3 依赖 job1 and job2, 就在列表中放入 ["job1", "job2"]
Dependencies []string `json:"dependencies"`
}

type JobFlowStatus struct {
// 用于存储 map 是 name/namespace 进行存储
JobStatusList map[string]v1.JobStatus `json:"jobStatusList,omitempty"`
// 记录 JobFlow 状态
// TODO: 使用特定类型封装
State string `json:"state,omitempty"`
}

Expand Down

0 comments on commit 2d9f773

Please sign in to comment.