Skip to content
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
158 changes: 44 additions & 114 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,61 @@ name: Check
on:
pull_request:
branches:
- main
- release-*
- main
- release-*
push:
branches:
- main
- release-*
- main
- release-*

env:
GO_VERSION: '1.19'
GO_VERSION: '1.23'

jobs:

# Test:
# name: Unit Test
# runs-on: ubuntu-20.04
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: true
# - name: Fetch History
# run: git fetch --prune --unshallow
# - name: Setup Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Cache Go Dependencies
# uses: actions/cache@v2
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: ${{ runner.os }}-go-
# - name: Run Unit Tests
# run: |
# make test
# git status
# # TODO: enable after public
# # - name: Publish Unit Test Coverage
# # uses: codecov/codecov-action@v3
# # with:
# # flags: unittests
# # file: cover.out
# - name: Check diff
# run: '[[ -z $(git status -s) ]] || (printf "Existing modified/untracked files.\nPlease run \"make generate manifests fmt vet\" and push again.\n"; exit 1)'
# - uses: actions/checkout@v4
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ env.GO_VERSION }}
# check-latest: true
# cache-dependency-path: "**/*.sum"
# - name: Run Unit Tests
# run: |
# make test
# git status

GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.53
args: --timeout=30m

# Lints Pull Request commits with commitlint.
#
# Rules can be referenced:
# https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
# CommitLint:
# name: Commit Lint
# runs-on: ubuntu-latest
# if: contains(fromJSON('["pull_request"]'), github.event_name)
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: wagoid/commitlint-github-action@v5

# Lints Pull Request title, because the title will be used as the
# commit message in branch main.
#
# Configuration detail can be referenced:
# https://github.com/marketplace/actions/pull-request-title-rules

# PullRequestTitleLint:
# name: Pull Request Title Lint
# runs-on: ubuntu-latest
# if: contains(fromJSON('["pull_request"]'), github.event_name)
# steps:
# - uses: deepakputhraya/action-pr-title@master
# with:
# allowed_prefixes: 'build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test' # title should start with the given prefix
# disallowed_prefixes: 'WIP,[WIP]' # title should not start with the given prefix
# prefix_case_sensitive: false # title prefix are case insensitive
# min_length: 5 # Min length of the title
# max_length: 80 # Max length of the title
# github_token: ${{ github.token }} # Default: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache-dependency-path: "**/*.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v2.0.2
args: --timeout=30m

LicenseCheck:
name: License Check
runs-on: ubuntu-latest
env:
TERM: xterm
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: apache/skywalking-eyes@main
- uses: actions/checkout@v4
- uses: apache/skywalking-eyes@main

# The TruffleHog OSS Github Action can be used to scan a range of commits for leaked credentials. The action will fail if any results are found.
# More see: https://github.com/marketplace/actions/trufflehog-oss
Expand All @@ -121,30 +67,14 @@ jobs:
name: Secret Scan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: TruffleHog OSS
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --debug --json

# TODO: Uncomment when the repository is publicly.
# DependencyReview:
# permissions:
# actions: read
# contents: read
# security-events: write
# name: Dependency Review
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: actions/dependency-review-action@v3
# with:
# fail-on-severity: critical
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: TruffleHog OSS
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --debug --json
86 changes: 77 additions & 9 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,78 @@
run:
skip-files:
- ".*_test.go"
skip-dirs:
- vendor/

version: "2"
linters:
disable:
- errcheck
- unused
default: standard
enable:
- bodyclose
- copyloopvar
- ginkgolinter
- testifylint
- misspell
- nakedret
- unconvert
- unparam
- whitespace
- gocritic
- errorlint
settings:
govet:
enable:
- shadow
misspell:
locale: US
staticcheck:
checks:
- "-QF1008"
gocritic:
enable-all: true
disabled-checks:
- emptyStringTest
- ifElseChain
- singleCaseSwitch
- hugeParam
- unnamedResult
- whyNoLint
- tooManyResultsChecker
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- unparam
path: _test.go
- linters:
- govet
text: declaration of "err" shadows declaration at line
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofumpt # drop in replacement for gofmt
- gci # format imports
settings:
gci:
custom-order: true
sections:
- standard
- blank
- dot
- default
- localmodule
gofumpt:
extra-rules: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

run:
allow-parallel-runners: true
timeout: 10m
57 changes: 27 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: fmt
fmt: golangci
$(GOLANGCI) fmt

.PHONY: lint
lint: fmt
$(GOLANGCI) run

manifests:
@bash hack/make-rules/update-manifests.sh

generate:
@bash hack/make-rules/update-codegen.sh


##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
CONTROLLER_TOOLS_VERSION ?= v0.15.0
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
CODEGEN = $(LOCALBIN)/kube-codegen

controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

manifests: controller-gen
@for dir in apps cluster; do \
mkdir -p "config/crd/$$dir"; \
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./$$dir/..." output:crd:artifacts:config="config/crd/$$dir"; \
done

generate: codegen controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
#@scripts/generate_client.sh
# $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CODEGEN) code-gen --go-header-file=./hack/boilerplate.go.txt --code-generator-version=v0.27.16 --apis-path=./ --generators=deepcopy,register

codegen: $(CODEGEN) # Download kube-codegen locally if necessary. If wrong version is installed, it will be overwritten.
$(CODEGEN):
ifeq (, $(shell command -v $(CODEGEN)))
@cd $(shell mktemp -d) && \
git clone https://github.com/zoumo/kube-codegen.git && \
cd kube-codegen && \
GOBIN=$(LOCALBIN) go install ./cmd/kube-codegen
endif

GOLANGCI ?= $(LOCALBIN)/golangci-lint

.PHONY: golangci
golangci:
@bash hack/make-rules/install-go-tools.sh golangci-lint
2 changes: 1 addition & 1 deletion apps/v1alpha1/collaset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type PersistentVolumeClaimRetentionPolicy struct {
// WhenDeleted specifies what happens to PVCs created from CollaSet
// VolumeClaimTemplates when the CollaSet is deleted. The default policy
// of `Delete` policy causes those PVCs to be deleted.
//`Retain` causes PVCs to not be affected by StatefulSet deletion. The
// `Retain` causes PVCs to not be affected by StatefulSet deletion. The
// +optional
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty"`

Expand Down
2 changes: 1 addition & 1 deletion apps/v1alpha1/podtransitionrule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ type WebhookResponse struct {
FinishedNames []string `json:"finishedNames,omitempty"`
Message string `json:"message"`
Poll bool `json:"poll"`
// Deprecated, will replace by Poll
// Deprecated: will replace by Poll
Async bool `json:"async"`
// if Async, use TraceId as TaskId
TraceId string `json:"traceId"`
Expand Down
10 changes: 5 additions & 5 deletions apps/v1alpha1/well_known_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ const (
PodPreparingDeleteLabel = "podopslifecycle.kusionstack.io/preparing-to-delete"
)

var (
WellKnownLabelPrefixesWithID = []string{PodOperatingLabelPrefix, PodOperationTypeLabelPrefix, PodPreCheckLabelPrefix, PodPreCheckedLabelPrefix,
PodPreparingLabelPrefix, PodDoneOperationTypeLabelPrefix, PodUndoOperationTypeLabelPrefix, PodOperateLabelPrefix, PodOperatedLabelPrefix, PodPostCheckLabelPrefix,
PodPostCheckedLabelPrefix, PodCompletingLabelPrefix}
)
var WellKnownLabelPrefixesWithID = []string{
PodOperatingLabelPrefix, PodOperationTypeLabelPrefix, PodPreCheckLabelPrefix, PodPreCheckedLabelPrefix,
PodPreparingLabelPrefix, PodDoneOperationTypeLabelPrefix, PodUndoOperationTypeLabelPrefix, PodOperateLabelPrefix, PodOperatedLabelPrefix, PodPostCheckLabelPrefix,
PodPostCheckedLabelPrefix, PodCompletingLabelPrefix,
}

// CollaSet labels
const (
Expand Down
Loading
Loading