Skip to content

Commit

Permalink
ci: restore workflow pipeline (#436)
Browse files Browse the repository at this point in the history
## What type of PR is this?

/kind ci

## What this PR does / why we need it:

- Restore workflow pipeline.
- Fix some problems of lint, unit tests.
- Debug golangci-lint problems:
```
Running error: can't run linter goanalysis_metalinter\nbuildssa: failed to load package main: could not load export data: no export data for \"k8s.io/kube-aggregator\"
```
  • Loading branch information
elliotxx authored May 22, 2024
1 parent 28681be commit ca5da5f
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 133 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Check
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
Test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: '1.19'
- name: Running go tests with coverage
env:
GO111MODULE: on
run: make cover
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out

GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: '1.19'
# NOTE: This golangci-lint action MUST be specified as v2 version, otherwise an error will be reported:
# Running error: can't run linter goanalysis_metalinter\nbuildssa: failed to load package main: could
# not load export data: no export data for \"k8s.io/kube-aggregator\"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.58.2

LicenseCheck:
name: License Check
runs-on: ubuntu-latest
env:
TERM: xterm
steps:
- uses: actions/checkout@v4
- uses: apache/skywalking-eyes@main
62 changes: 0 additions & 62 deletions .github/workflows/check.yaml.bak

This file was deleted.

File renamed without changes.
11 changes: 6 additions & 5 deletions .github/workflows/constraint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
github_token: ${{ github.token }} # Default: ${{ github.token }}
# Checks all Markdown files in repository for broken links.
# https://github.com/gaurav-nelson/github-action-markdown-link-check
# markdown-link-check:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: gaurav-nelson/github-action-markdown-link-check@v1
MarkdownLinkCheck:
name: Markdown Link Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
87 changes: 38 additions & 49 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,57 @@ on:
permissions:
contents: write
jobs:
# TODO: Remove the jobs temporarily, because it is almost over the free limit of Github Action
# Test:
# name: Unit Test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Set up Go 1.19
# uses: actions/setup-go@v2
# with:
# go-version: 1.19

# - run: go build ./...
# - run: go vet ./...

# - name: Running go tests with coverage
# env:
# GO111MODULE: on
# run: make cover
Test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Running go tests with coverage
env:
GO111MODULE: on
run: make cover

# GolangLint:
# name: Golang Lint
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Set up Go 1.19
# uses: actions/setup-go@v2
# with:
# go-version: 1.19
# - 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.52.2
GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: 1.19
# NOTE: This golangci-lint action MUST be specified as v2 version, otherwise an error will be reported:
# Running error: can't run linter goanalysis_metalinter\nbuildssa: failed to load package main: could
# not load export data: no export data for \"k8s.io/kube-aggregator\"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.58.2

# # 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
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: wagoid/commitlint-github-action@v5
CommitLint:
name: Commit Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5

# Release the artifacts, release note and images.
Release:
runs-on: ubuntu-latest
# needs: [Test, GolangLint, CommitLint]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Check if on tag
run: |
Expand Down
9 changes: 4 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
# options for analysis running
run:
timeout: 10m
skip-files:
- pkg/kubernetes/openapi/zz_generated.openapi.go
- pkg/kubernetes/internalimport/internal_import.go
go: '1.19'

linters:
disable-all: true
Expand Down Expand Up @@ -62,8 +60,6 @@ linters:

linters-settings:
gofumpt:
# Select the Go version to target. The default is `1.15`.
lang-version: "1.19"
# Choose whether or not to use the extra rules that are disabled
# by default
extra-rules: false
Expand Down Expand Up @@ -94,3 +90,6 @@ issues:
- "S1000: should use for range instead of for { select {} }"
- "SA4004: the surrounding loop is unconditionally terminated"
- "copylocks: call of c\\.Post copies lock value: kusionstack\\.io/kclvm-go/pkg/spec/gpyrpc\\.Ping_Args contains google\\.golang\\.org/protobuf/internal/impl\\.MessageState contains sync\\.Mutex"
exclude-files:
- pkg/kubernetes/openapi/zz_generated.openapi.go
- pkg/kubernetes/internalimport/internal_import.go
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Unsure where to begin contributing to Karpor codebase? Start by browsing issues

Learn [Code Conventions](./docs/conventions/code-conventions.md) and [Test Conventions](./docs/conventions/test-conventions.md) and understand what to pay attention to when writing code.

And learn the [Release Process And Cadence](./docs/contributor/release-process.md) to know when your code changes will be released.
And learn the [Release Process And Cadence](./docs/conventions/release-process.md) to know when your code changes will be released.

### Become a community member

Expand Down
9 changes: 4 additions & 5 deletions cmd/app/options/recommended.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"k8s.io/apiserver/pkg/endpoints/openapi"
"k8s.io/apiserver/pkg/features"
"k8s.io/apiserver/pkg/server"
genericapiserver "k8s.io/apiserver/pkg/server"
"k8s.io/apiserver/pkg/server/egressselector"
"k8s.io/apiserver/pkg/server/filters"
"k8s.io/apiserver/pkg/server/options"
Expand Down Expand Up @@ -126,7 +125,7 @@ func (o *RecommendedOptions) ApplyTo(config *server.RecommendedConfig) error {
return err
}

genericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(GetOpenAPIDefinitions, openapi.NewDefinitionNamer(scheme.Scheme))
genericConfig.OpenAPIConfig = server.DefaultOpenAPIConfig(GetOpenAPIDefinitions, openapi.NewDefinitionNamer(scheme.Scheme))
genericConfig.OpenAPIConfig.Info.Title = "Karpor"
genericConfig.OpenAPIConfig.Info.Version = "0.1"

Expand Down Expand Up @@ -192,11 +191,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
}

// BuildAuthorizer constructs the authorizer
func BuildAuthorizer(authz *kubeoptions.BuiltInAuthorizationOptions, EgressSelector *egressselector.EgressSelector, versionedInformers clientgoinformers.SharedInformerFactory) (authorizer.Authorizer, authorizer.RuleResolver, error) {
func BuildAuthorizer(authz *kubeoptions.BuiltInAuthorizationOptions, egressSelector *egressselector.EgressSelector, versionedInformers clientgoinformers.SharedInformerFactory) (authorizer.Authorizer, authorizer.RuleResolver, error) {
authorizationConfig := authz.ToAuthorizationConfig(versionedInformers)

if EgressSelector != nil {
egressDialer, err := EgressSelector.Lookup(egressselector.ControlPlane.AsNetworkContext())
if egressSelector != nil {
egressDialer, err := egressSelector.Lookup(egressselector.ControlPlane.AsNetworkContext())
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions docs/contributor/code-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ If the `gopath` folder does not exist, create it with `mkdir ~/gopath`. These co
<details>
<summary>Manually installing golangci-lint</summary>

You can install it manually following the [guide](https://golangci-lint.run/usage/install/#local-installation), or use the command:
You can install it manually following the [guide](https://golangci-lint.run/welcome/install), or use the command:

```
cd ~/go/ && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2
Expand Down Expand Up @@ -99,7 +99,7 @@ This document will guide you through the process of creating a [pull request](ht

### Before you begin

We know you are excited to create your first pull request. Before we get started, make sure your code follows the relevant [code conventions](../2-conventions/2-code-conventions.md).
We know you are excited to create your first pull request. Before we get started, make sure your code follows the relevant [code conventions](../conventions/code-conventions.md).

### Your First Pull Request

Expand Down
2 changes: 1 addition & 1 deletion docs/contributor/non-code-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you have ideas to improve Karpor, please submit a [feature request](https://g

## Answering Questions

If you have a question and cannot find the answer in the [documentation](https://www.kusionstack.io/docs/next/karpor/), the next step is to ask on [GitHub Discussions](https://github.com/KusionStack/karpor/discussions).
If you have a question and cannot find the answer in the [documentation](https://www.kusionstack.io/karpor/), the next step is to ask on [GitHub Discussions](https://github.com/KusionStack/karpor/discussions).

Helping these users is important to us, and we would love to have your help. You can contribute by answering [their questions](https://github.com/KusionStack/karpor/discussions) to help other Karpor users.

Expand Down
2 changes: 1 addition & 1 deletion docs/conventions/test-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestFlagParser(t *testing.T) {
It is worth noting that most mainstream IDEs have already integrated [gotests](https://github.com/cweill/gotests), enabling the automatic generation of table-driven style Go unit tests, which I believe can enhance the efficiency of writing your unit tests:

- [GoLand](https://blog.jetbrains.com/go/2020/03/13/test-driven-development-with-goland/)
- [Visual Studio Code](https://betterprogramming.pub/a-quick-way-to-generate-go-tests-in-visual-studio-code-b7c675b88dac)
- [Visual Studio Code](https://juandes.com/go-test-vsc/)

### File Naming

Expand Down
2 changes: 1 addition & 1 deletion go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COVERAGETMP ?= coverage.tmp
GOFORMATER ?= gofumpt
GOFORMATER_VERSION ?= v0.2.0
GOLINTER ?= golangci-lint
GOLINTER_VERSION ?= v1.52.2
GOLINTER_VERSION ?= v1.58.2


# To generate help information
Expand Down
1 change: 0 additions & 1 deletion pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Examples:
* https://github.com/google/gvisor/tree/master/pkg
* https://github.com/google/syzkaller/tree/master/pkg
* https://github.com/perkeep/perkeep/tree/master/pkg
* https://github.com/minio/minio/tree/master/pkg
* https://github.com/heptio/ark/tree/master/pkg
* https://github.com/argoproj/argo/tree/master/pkg
* https://github.com/heptio/sonobuoy/tree/master/pkg
Expand Down

0 comments on commit ca5da5f

Please sign in to comment.