Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git workflow for golang linters and unittests #15

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
push:
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Lint
uses: golangci/golangci-lint-action@v5
with:
version: 'v1.58.0'
args: -v --timeout 5m
skip-cache: true

- name: vet
run:
make vet

- name: fmt
run:
test -z "$(go fmt ./...)"

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Test
run: go test -v ./...

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build
run: make build
5 changes: 4 additions & 1 deletion pkg/engine/check_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (task *CheckObjTask) Exec(ctx context.Context) error {
done := make(chan struct{})
defer close(done)

informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
_, err = informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
resource := obj.(*unstructured.Unstructured)
task.log.V(4).Info("Informer added", "resource", info.GVR.Resource, "name", resource.GetName())
Expand All @@ -101,6 +101,9 @@ func (task *CheckObjTask) Exec(ctx context.Context) error {
task.checkStateAsync(ctx, resource.GetName(), info, nameMap, done)
},
})
if err != nil {
return err
}

stopCh := make(chan struct{})
go informer.Run(stopCh)
Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/submit_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,8 @@ func (task *SubmitObjTask) Exec(ctx context.Context) error {
}
}

task.setter.SetObjInfo(task.taskID,
return task.setter.SetObjInfo(task.taskID,
NewObjInfo([]string{task.obj[0].Metadata.Name}, task.obj[0].Metadata.Namespace, gvr, task.Pods.Names()...))

return nil
}

func (obj *GenericObject) UnmarshalYAML(unmarshal func(interface{}) error) error {
Expand Down
Loading