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

[CI] Update CI workflows #127

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
114 changes: 0 additions & 114 deletions .github/workflows/ci.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/golang-ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Meshery-App Mesh Workflow
on:
push:
branches:
- "*"
tags:
- "v*"
pull_request:
branches:
- master
jobs:
tests:
name: Tests
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@main
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@main
with:
go-version: 1.19
check-latest: true
cache: true
- name: Create cluster using KinD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acald-creator Why does running the unit tests require a kind cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Revolyssup From the original file at https://github.com/meshery/meshery-app-mesh/blob/master/.github/workflows/ci.yml this is already there. The only difference I did was removed the other checks such as errcheck, vet and gosec because golangci-lint already does this.

This is the same test done through all the adapters repo. Does this section need to be revised or removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is reflected in the Makefile as well

## Run Golang tests
test: dep-check
	export CURRENTCONTEXT="$(kubectl config current-context)" 
	echo "current-context:" ${CURRENTCONTEXT} 
	export KUBECONFIG="${HOME}/.kube/config"
	echo "environment-kubeconfig:" ${KUBECONFIG}
	GOPROXY=direct GOSUMDB=off GO111MODULE=on go test -v ./...

uses: helm/[email protected]
- run: |
export CURRENTCONTEXT="$(kubectl config current-context)"
echo "current-context:" ${CURRENTCONTEXT}
export KUBECONFIG="${HOME}/.kube/config"
echo "environment-kubeconfig:" ${KUBECONFIG}
GOPROXY=direct GOSUMDB=off GO111MODULE=on go test ./...
32 changes: 32 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Golangci-Lint CI Workflow
on:
push:
branches:
- "*"
tags:
- "v*"
pull_request:
branches:
- master
permissions:
contents: read

jobs:
golangci:
strategy:
matrix:
go: [1.19]
os: [ubuntu-latest, windows-latest]
name: golangci-lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
check-latest: true
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m --verbose
144 changes: 144 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
funlen:
lines: 100
statements: 50
gci:
local-prefixes: github.com/golangci/golangci-lint
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
gosec:
settings:
exclude: -G204
govet:
check-shadowing: false
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 950
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
# https://golangci-lint.run/usage/linters/
disable-all: true
enable:
# TODO: consider continuously if more should be enabled.
# Can also be useful to run with more strict settings before commit locally, i.e. to test for TODOs (godox)
# - bodyclose
# - deadcode
- dogsled
# - dupl
- errcheck
# - exhaustive
# - funlen
# - goconst
# - gocritic
# - gocyclo
- gofmt
- goimports
# - golint
- gomodguard
- gosec
# - gomnd
# - goprintffuncname
- gosimple
- govet
- ineffassign
# - interfacer
- lll
- misspell
# - nakedret
# - nolintlint
# - rowserrcheck
# - scopelint
- staticcheck
# - structcheck
- stylecheck
- typecheck
# - unconvert
# - unparam
- unused
# - varcheck
- whitespace
- asciicheck
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - maligned
# - nestif
# - prealloc
# - testpackage
# - wsl

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd

# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"

run:
skip-dirs:
- test/testdata_etc
- internal/cache
- internal/renameio
- internal/robustio
timeout: 5m
4 changes: 1 addition & 3 deletions appmesh/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patches []string, helmChartURL string, kubeconfigs []string) (string, error) {

st := status.Installing

if del {
Expand All @@ -24,9 +23,8 @@ func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patche
var errs []error
var errMx sync.Mutex


for _, config := range kubeconfigs {
wg.Add(1);
wg.Add(1)
go func(config string) {
defer wg.Done()
kClient, err := kubernetes.New([]byte(config))
Expand Down
10 changes: 4 additions & 6 deletions appmesh/app_mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat
operation = "removed"
}
if err != nil {
summary := fmt.Sprintf("Error while labelling %s", opReq.Namespace)
summary := fmt.Sprintf("Error while labeling %s", opReq.Namespace)
hh.streamErr(summary, e, err)
return
}
Expand All @@ -107,8 +107,8 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat
hh.streamErr(summary, e, err)
return
}
ee.Summary = fmt.Sprintf("Succesfully %sed %s", operation, opReq.OperationName)
ee.Details = fmt.Sprintf("Succesfully %sed %s from the %s namespace", operation, opReq.OperationName, opReq.Namespace)
ee.Summary = fmt.Sprintf("Successfully %sed %s", operation, opReq.OperationName)
ee.Details = fmt.Sprintf("Successfully %sed %s from the %s namespace", operation, opReq.OperationName, opReq.Namespace)
hh.StreamInfo(e)
}(appMesh, e)
case common.BookInfoOperation, common.HTTPBinOperation, common.ImageHubOperation, common.EmojiVotoOperation:
Expand Down Expand Up @@ -139,12 +139,11 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat
}(appMesh, e)
default:
appMesh.streamErr("Invalid operation", e, ErrOpInvalid)

}
return nil
}

//CreateKubeconfigs creates and writes passed kubeconfig onto the filesystem
// CreateKubeconfigs creates and writes passed kubeconfig onto the filesystem
func (appMesh *AppMesh) CreateKubeconfigs(kubeconfigs []string) error {
var errs = make([]error, 0)
for _, kubeconfig := range kubeconfigs {
Expand Down Expand Up @@ -191,7 +190,6 @@ func (appMesh *AppMesh) CreateKubeconfigs(kubeconfigs []string) error {

// ProcessOAM handles the grpc invocation for handling OAM objects
func (appMesh *AppMesh) ProcessOAM(ctx context.Context, oamReq adapter.OAMRequest) (string, error) {

err := appMesh.CreateKubeconfigs(oamReq.K8sConfigs)
if err != nil {
return "", err
Expand Down
Loading