Skip to content

Commit

Permalink
Merge branch 'main' into fix-argo-lint-offline-issue-on-multi-documen…
Browse files Browse the repository at this point in the history
…ts-yaml-file
  • Loading branch information
wang-wayne authored Aug 30, 2024
2 parents ddc5c3b + 3d41fb2 commit 693db02
Show file tree
Hide file tree
Showing 377 changed files with 14,279 additions and 11,931 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ jobs:
- test: test-python-sdk
profile: minimal
- test: test-executor
install_k3s_version: v1.26.15+k3s1
install_k3s_version: v1.28.11+k3s1
profile: minimal
- test: test-corefunctional
install_k3s_version: v1.26.15+k3s1
install_k3s_version: v1.28.11+k3s1
profile: minimal
- test: test-functional
install_k3s_version: v1.26.15+k3s1
install_k3s_version: v1.28.11+k3s1
profile: minimal
steps:
- name: Install socat (needed by Kubernetes)
Expand All @@ -247,7 +247,7 @@ jobs:
- name: Install and start K3S
run: |
if ! echo "${{ matrix.install_k3s_version }}" | egrep '^v[0-9]+\.[0-9]+\.[0-9]+\+k3s1$'; then
export INSTALL_K3S_VERSION=v1.29.3+k3s1
export INSTALL_K3S_VERSION=v1.30.2+k3s1
else
export INSTALL_K3S_VERSION=${{ matrix.install_k3s_version }}
fi
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- testifylint
- typecheck
- unparam
- unused
Expand Down
4 changes: 4 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CRDs
CloudSQL
ClusterRoleBinding
ClusterRoles
ClusterWorkflowTemplate
Codespaces
ConfigMap
ConfigMaps
Expand Down Expand Up @@ -92,6 +93,7 @@ OAuth
OAuth2
Okta
OpenAPI
OpenTelemetry
PDBs
PProf
PVCs
Expand Down Expand Up @@ -203,6 +205,7 @@ sandboxed
shortcodes
stateful
stderr
temporality
triaged
un-reconciled
v1
Expand Down Expand Up @@ -247,4 +250,5 @@ webHDFS
webhook
webhooks
workflow-controller-configmap
workqueue
yaml
5,040 changes: 5,040 additions & 0 deletions CHANGELOG-2-x-x.md

Large diffs are not rendered by default.

5,111 changes: 77 additions & 5,034 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ ARG GIT_TREE_STATE=unknown

FROM golang:1.22-alpine3.19 as builder

# libc-dev to build openapi-gen
RUN apk update && apk add --no-cache \
git \
make \
ca-certificates \
wget \
curl \
gcc \
libc-dev \
bash \
mailcap

Expand Down
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ ifndef $(GOPATH)
endif

# -- file lists
ARGOEXEC_PKGS := $(shell echo cmd/argoexec && go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
CLI_PKGS := $(shell echo cmd/argo && go list -f '{{ join .Deps "\n" }}' ./cmd/argo/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
CONTROLLER_PKGS := $(shell echo cmd/workflow-controller && go list -f '{{ join .Deps "\n" }}' ./cmd/workflow-controller/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
ARGOEXEC_PKG_FILES := $(shell go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo-workflows/v3/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
CLI_PKG_FILES := $(shell go list -f '{{ join .Deps "\n" }}' ./cmd/argo/ | grep 'argoproj/argo-workflows/v3/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
CONTROLLER_PKG_FILES := $(shell go list -f '{{ join .Deps "\n" }}' ./cmd/workflow-controller/ | grep 'argoproj/argo-workflows/v3/' | xargs go list -f '{{ range $$file := .GoFiles }}{{ print $$.ImportPath "/" $$file "\n" }}{{ end }}' | cut -c 39-)
TYPES := $(shell find pkg/apis/workflow/v1alpha1 -type f -name '*.go' -not -name openapi_generated.go -not -name '*generated*' -not -name '*test.go')
CRDS := $(shell find manifests/base/crds -type f -name 'argoproj.io_*.yaml')
SWAGGER_FILES := pkg/apiclient/_.primary.swagger.json \
Expand Down Expand Up @@ -183,16 +183,16 @@ dist/argo-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64
dist/argo-windows-%.gz: dist/argo-windows-%
gzip --force --keep dist/argo-windows-$*.exe

dist/argo-windows-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-windows-%: server/static/files.go $(CLI_PKG_FILES) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@.exe ./cmd/argo

dist/argo-%.gz: dist/argo-%
gzip --force --keep dist/argo-$*

dist/argo-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-%: server/static/files.go $(CLI_PKG_FILES) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argo

dist/argo: server/static/files.go $(CLI_PKGS) go.sum
dist/argo: server/static/files.go $(CLI_PKG_FILES) go.sum
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS}' -o $@ ./cmd/argo
Expand All @@ -210,7 +210,7 @@ clis: dist/argo-linux-amd64.gz dist/argo-linux-arm64.gz dist/argo-linux-ppc64le.
.PHONY: controller
controller: dist/workflow-controller

dist/workflow-controller: $(CONTROLLER_PKGS) go.sum
dist/workflow-controller: $(CONTROLLER_PKG_FILES) go.sum
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS}' -o $@ ./cmd/workflow-controller
Expand All @@ -222,7 +222,7 @@ workflow-controller-image:

# argoexec

dist/argoexec: $(ARGOEXEC_PKGS) go.sum
dist/argoexec: $(ARGOEXEC_PKG_FILES) go.sum
ifeq ($(shell uname -s),Darwin)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags '${GCFLAGS}' -v -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argoexec
else
Expand Down Expand Up @@ -283,7 +283,7 @@ swagger: \
$(GOPATH)/bin/mockery:
# update this in Nix when upgrading it here
ifneq ($(USE_NIX), true)
go install github.com/vektra/mockery/[email protected].0
go install github.com/vektra/mockery/[email protected].2
endif
$(GOPATH)/bin/controller-gen:
# update this in Nix when upgrading it here
Expand Down Expand Up @@ -434,7 +434,7 @@ dist/manifests/%: manifests/%
# lint/test/etc

$(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.55.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.59.1

.PHONY: lint
lint: server/static/files.go $(GOPATH)/bin/golangci-lint
Expand Down Expand Up @@ -605,6 +605,8 @@ pkg/apis/workflow/v1alpha1/openapi_generated.go: $(GOPATH)/bin/openapi-gen $(TYP
--input-dirs github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
--output-package github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1 \
--report-filename pkg/apis/api-rules/violation_exceptions.list
# Force the timestamp to be up to date
touch $@
# Delete the link
[ -e ./v3 ] && rm -rf v3

Expand All @@ -618,6 +620,8 @@ pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go: $(TYPES)
github.com/argoproj/argo-workflows/v3/pkg/client github.com/argoproj/argo-workflows/v3/pkg/apis \
workflow:v1alpha1 \
--go-header-file ./hack/custom-boilerplate.go.txt
# Force the timestamp to be up to date
touch $@
# Delete the link
[ -e ./v3 ] && rm -rf v3

Expand Down Expand Up @@ -663,7 +667,7 @@ docs/fields.md: api/openapi-spec/swagger.json $(shell find examples -type f) hac
env ARGO_SECURE=false ARGO_INSECURE_SKIP_VERIFY=false ARGO_SERVER= ARGO_INSTANCEID= go run ./hack/docs fields

# generates several other files
docs/cli/argo.md: $(CLI_PKGS) go.sum server/static/files.go hack/docs/cli.go
docs/cli/argo.md: $(CLI_PKG_FILES) go.sum server/static/files.go hack/docs/cli.go
go run ./hack/docs cli

# docs
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

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

4 changes: 2 additions & 2 deletions api/openapi-spec/swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func TestSwagger(t *testing.T) {
assert.Contains(t, required, "image")
assert.NotContains(t, required, "name")
})
// this test makes sure we can deal with an instance where we are wrong vs Kuberenetes
// this test makes sure we can deal with an instance where we are wrong vs Kubernetes
t.Run("io.k8s.api.core.v1.SecretKeySelector", func(t *testing.T) {
definition := definitions["io.k8s.api.core.v1.SecretKeySelector"].(obj)
properties := definition["properties"]
assert.Contains(t, properties, "name")
})
// this test makes sure we can deal with an instance where we are wrong vs Kuberenetes
// this test makes sure we can deal with an instance where we are wrong vs Kubernetes
t.Run("io.k8s.api.core.v1.Volume", func(t *testing.T) {
definition := definitions["io.k8s.api.core.v1.Volume"].(obj)
properties := definition["properties"]
Expand Down
6 changes: 3 additions & 3 deletions cmd/argo/commands/clustertemplate/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const cwfts = `
Expand Down Expand Up @@ -40,7 +41,6 @@ spec:

func TestUnmarshalCWFT(t *testing.T) {
clusterwfts, err := unmarshalClusterWorkflowTemplates([]byte(cwfts), false)
if assert.NoError(t, err) {
assert.Equal(t, 2, len(clusterwfts))
}
require.NoError(t, err)
assert.Len(t, clusterwfts, 2)
}
3 changes: 2 additions & 1 deletion cmd/argo/commands/common/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -41,7 +42,7 @@ func testPrintNodeImpl(t *testing.T, expected string, node wfv1.NodeStatus, getA
printNode(w, node, workflowName, "", getArgs, util.GetPodNameVersion())
}
err := w.Flush()
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, expected, result.String())
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/common/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/argoproj/argo-workflows/v3/workflow/common"
)

// cliSubmitOpts holds submission options specific to CLI submission (e.g. controlling output)
// CliSubmitOpts holds submission options specific to CLI submission (e.g. controlling output)
type CliSubmitOpts struct {
Output string // --output
Wait bool // --wait
Expand Down
15 changes: 7 additions & 8 deletions cmd/argo/commands/cron/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
)
Expand Down Expand Up @@ -62,10 +63,9 @@ func TestPrintCronWorkflow(t *testing.T) {
func TestNextRuntime(t *testing.T) {
var cronWf = v1alpha1.MustUnmarshalCronWorkflow(invalidCwf)
next, err := GetNextRuntime(cronWf)
if assert.NoError(t, err) {
assert.LessOrEqual(t, next.Unix(), time.Now().Add(1*time.Minute).Unix())
assert.Greater(t, next.Unix(), time.Now().Unix())
}
require.NoError(t, err)
assert.LessOrEqual(t, next.Unix(), time.Now().Add(1*time.Minute).Unix())
assert.Greater(t, next.Unix(), time.Now().Unix())
}

var cronMultipleSchedules = `
Expand Down Expand Up @@ -95,8 +95,7 @@ spec:
func TestNextRuntimeWithMultipleSchedules(t *testing.T) {
var cronWf = v1alpha1.MustUnmarshalCronWorkflow(cronMultipleSchedules)
next, err := GetNextRuntime(cronWf)
if assert.NoError(t, err) {
assert.LessOrEqual(t, next.Unix(), time.Now().Add(1*time.Minute).Unix())
assert.Greater(t, next.Unix(), time.Now().Unix())
}
require.NoError(t, err)
assert.LessOrEqual(t, next.Unix(), time.Now().Add(1*time.Minute).Unix())
assert.Greater(t, next.Unix(), time.Now().Unix())
}
64 changes: 27 additions & 37 deletions cmd/argo/commands/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/argoproj/argo-workflows/v3/pkg/apiclient/workflow"
Expand All @@ -18,73 +19,62 @@ import (
func Test_listWorkflows(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
workflows, err := listEmpty(&metav1.ListOptions{}, listFlags{})
if assert.NoError(t, err) {
assert.Len(t, workflows, 0)
}
require.NoError(t, err)
assert.Empty(t, workflows)
})
t.Run("Nothing", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{}, listFlags{})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Status", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/phase in (Pending,Running)"}, listFlags{status: []string{"Running", "Pending"}})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Completed", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed=true"}, listFlags{completed: true})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Running", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed!=true"}, listFlags{running: true})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Resubmitted", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: common.LabelKeyPreviousWorkflowName}, listFlags{resubmitted: true})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Labels", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "foo"}, listFlags{labels: "foo"})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
require.NoError(t, err)
assert.NotNil(t, workflows)
})
t.Run("Prefix", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{}, listFlags{prefix: "foo-"})
if assert.NoError(t, err) {
assert.Len(t, workflows, 1)
}
require.NoError(t, err)
assert.Len(t, workflows, 1)
})
t.Run("Since", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{}, listFlags{createdSince: "1h"})
if assert.NoError(t, err) {
assert.Len(t, workflows, 1)
}
require.NoError(t, err)
assert.Len(t, workflows, 1)
})
t.Run("Older", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{}, listFlags{finishedBefore: "1h"})
if assert.NoError(t, err) {
assert.Len(t, workflows, 1)
}
require.NoError(t, err)
assert.Len(t, workflows, 1)
})
t.Run("Names", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{FieldSelector: nameFields}, listFlags{fields: nameFields})
if assert.NoError(t, err) {
assert.Len(t, workflows, 3)
// most recent workflow will be shown first
assert.Equal(t, "bar-", workflows[0].Name)
assert.Equal(t, "baz-", workflows[1].Name)
assert.Equal(t, "foo-", workflows[2].Name)
}
require.NoError(t, err)
assert.Len(t, workflows, 3)
// most recent workflow will be shown first
assert.Equal(t, "bar-", workflows[0].Name)
assert.Equal(t, "baz-", workflows[1].Name)
assert.Equal(t, "foo-", workflows[2].Name)
})
}

Expand Down
Loading

0 comments on commit 693db02

Please sign in to comment.