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 6a54369
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 23 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ env:

jobs:

golang-lint:
project-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Run go fmt test
run: chmod +x hack/verify-gofmt.sh && hack/verify-gofmt.sh
env:
GO111MODULE: auto
- name: Run unit test
run: go test -v ./pkg/controller
run: go test -v ./pkg/controller
# bug fix: go build
- name: Build the project
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o jobflowoperator main.go
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
14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a54369

Please sign in to comment.