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

Initial code commit #2

Merged
merged 1 commit into from
Oct 7, 2020
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
125 changes: 4 additions & 121 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name:
name: Meshery Adapter Library

on:
push:
branches:
- 'master'
- '**'
Copy link
Member

Choose a reason for hiding this comment

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

Is this mean of all the PR would run the CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means that the CI runs on any branch one pushes to, especially also any branch in personal forks.

Copy link
Member

Choose a reason for hiding this comment

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

If I remember right, Github decreased the number of CI of the repo, can these make 0 effect to us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't thought about that (but heard about it too). As most branches exist in personal forks, I think it would not contribute to the Layer5 budget. Let's keep an eye on it. Would be interested to see whether there is a count somewhere that shows usage...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tags:
- 'v*'
pull_request:
Expand All @@ -19,7 +20,7 @@ jobs:
uses: golangci/golangci-lint-action@v1
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
version: v1.31

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand All @@ -29,121 +30,3 @@ jobs:

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
server-tests:
needs: [tests-ui, golangci, build-backend, build-ui]
name: Server tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- name: Setup Cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go test -tags draft ./...
build-backend:
name: Backend build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- name: Setup Cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go build -tags draft ./cmd/main.go
build-ui:
name: UI build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: ${{ secrets.NODE_VERSION }}
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: |
cd ui
npm i
npm run build && npm run export
cd ..
cd provider-ui
npm i
npm run build && npm run export
tests-ui:
name: UI tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: ${{ secrets.NODE_VERSION }}
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: |
cd ui
npm i
npm test
cd ..
cd provider-ui
npm i
npm test
cd ..
mesheryctl_build:
name: Mesheryctl build & release
runs-on: macos-latest
needs: [server-tests]
steps:
- name: Check out code
uses: actions/checkout@master
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- name: Setup Cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: goreleaser WITHOUT tag
uses: goreleaser/goreleaser-action@v1
if: success() && startsWith(github.ref, 'refs/tags/') == false
with:
version: latest
args: release --snapshot --skip-publish --rm-dist
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
meshops.proto

# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
Expand All @@ -13,3 +19,9 @@

# Dependency directories (remove the comment below to include it)
# vendor/

### Go Patch ###
/vendor/
/Godeps/

# End of https://www.toptal.com/developers/gitignore/api/go
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
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
check:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can add go mod tidy/verify to the Makefile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion 👍
What about a target called verify with go mod verify?
And a target called tidy that does go mod tidy, gofmt -w ., goimports -w .

Copy link
Member

Choose a reason for hiding this comment

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

Yep, we can add tidy verify golang-ci at local test

Copy link
Contributor Author

@mgfeller mgfeller Oct 10, 2020

Choose a reason for hiding this comment

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

Created #5

golangci-lint run

check-clean-cache:
golangci-lint cache clean

protoc-setup:
wget -P meshes https://raw.githubusercontent.com/layer5io/meshery/master/meshes/meshops.proto

proto:
protoc -I meshes/ meshes/meshops.proto --go_out=plugins=grpc:./meshes/
Loading