From 88364061efa5bc0ebec8286c1d8522bf05d5b5e8 Mon Sep 17 00:00:00 2001 From: Sumanth Chinthagunta Date: Sat, 20 Jun 2020 00:00:55 -0700 Subject: [PATCH] refactor(config): polish --- .github/linters/.eslintrc.yml | 0 .../linters/.golangci.yml | 2 +- .github/linters/.markdown-lint.yml | 0 .github/workflows/linter.yml | 49 +++++++++++++++++++ .github/workflows/pr.yml | 16 +----- .github/workflows/push.yml | 16 +----- .vscode/settings.json | 3 +- Makefile | 4 +- config/base/service/account/service.yaml | 3 +- config/base/service/emailer/service.yaml | 1 + .../service/greeter/service-headless.yaml | 14 ++++++ config/base/service/greeter/service.yaml | 1 + config/base/service/recorder/service.yaml | 1 + docs/introduction/prerequisites.md | 10 ++++ 14 files changed, 87 insertions(+), 33 deletions(-) create mode 100644 .github/linters/.eslintrc.yml rename .golangci.yml => .github/linters/.golangci.yml (96%) create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/workflows/linter.yml create mode 100644 config/base/service/greeter/service-headless.yaml diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml new file mode 100644 index 00000000..e69de29b diff --git a/.golangci.yml b/.github/linters/.golangci.yml similarity index 96% rename from .golangci.yml rename to .github/linters/.golangci.yml index 9112ff9d..60cf8ddf 100644 --- a/.golangci.yml +++ b/.github/linters/.golangci.yml @@ -5,7 +5,7 @@ run: # which dirs to skip: they won't be analyzed; skip-dirs: - - service/account/proto + - mkit skip-files: - lib/bad.go diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..df7a84d1 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,49 @@ +--- +########################### +########################### +## Linter GitHub Actions ## +########################### +########################### +name: Lint Code Base + +# +# Documentation: +# https://help.github.com/en/articles/workflow-syntax-for-github-actions +# + +############################# +# Start the job on all push # +############################# +on: + push: + branches-ignore: + - 'master' + +############### +# Set the Job # +############### +jobs: + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest + + ################## + # Load all steps # + ################## + steps: + ########################## + # Checkout the code base # + ########################## + - name: Checkout Code + uses: actions/checkout@v2 + + ################################ + # Run Linter against code base # + ################################ + - name: Lint Code Base + uses: docker://github/super-linter:v2.1.0 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: develop diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 92d7c5c4..ba36d47b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,8 +3,8 @@ on: pull_request: types: [assigned] jobs: - lint-test: - name: Lint and Test + test: + name: Test runs-on: ubuntu-latest if: | contains(github.event.commits[0].message, '[skip ci]') == false && @@ -15,12 +15,6 @@ jobs: with: go-version: 1.14 id: go - - name: Setup Tools - env: - GO111MODULE: off - run: | - go get github.com/golangci/golangci-lint/cmd/golangci-lint - GO111MODULE=on go get github.com/bufbuild/buf/cmd/buf - name: Check out Code uses: actions/checkout@v1 - name: Cache go modules @@ -34,12 +28,6 @@ jobs: - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: go mod download - - name: Lint - run: | - make lint - # export PATH=$PATH:$(go env GOPATH)/bin - # golangci-lint run - # buf check lint - name: Unit Test run: make test-unit - name: Integration Test diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1a50bbeb..1e12451d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,8 +5,8 @@ on: # - "v*.*.*" paths-ignore: ["*.md", "docs", "deploy", "config", ".github", "scripts"] jobs: - lint-test: - name: Lint and Test + test: + name: Test runs-on: ubuntu-latest if: | contains(github.event.commits[0].message, '[skip ci]') == false && @@ -17,12 +17,6 @@ jobs: with: go-version: 1.14 id: go - - name: Setup Tools - env: - GO111MODULE: off - run: | - go get github.com/golangci/golangci-lint/cmd/golangci-lint - GO111MODULE=on go get github.com/bufbuild/buf/cmd/buf - name: Check out Code uses: actions/checkout@v1 - name: Cache go modules @@ -36,12 +30,6 @@ jobs: - name: Install Dependencies if: steps.cache.outputs.cache-hit != 'true' run: go mod download - - name: Lint - run: | - make lint - # export PATH=$PATH:$(go env GOPATH)/bin - # golangci-lint run - # buf check lint - name: Unit Test run: make test-unit - name: Coverage Test diff --git a/.vscode/settings.json b/.vscode/settings.json index fac1ba58..395f7212 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -78,7 +78,8 @@ "go.useLanguageServer": true, "go.lintTool": "golangci-lint", "go.lintFlags": [ - "--fast" + "--fast", + "--config=.github/linters/.golangci.yml" ], // Proto "clang-format.style": "google", diff --git a/Makefile b/Makefile index 86f6e462..997a0818 100644 --- a/Makefile +++ b/Makefile @@ -131,10 +131,10 @@ gomod_lint: lint lint-%: @if [ -z $(TARGET) ]; then \ echo "Linting all go"; \ - ${GOPATH}/bin/golangci-lint run ./... --deadline=5m; \ + ${GOPATH}/bin/golangci-lint run ./... --deadline=5m --config=.github/linters/.golangci.yml; \ else \ echo "Linting go in ${TARGET}-${TYPE}..."; \ - ${GOPATH}/bin/golangci-lint run ./${TYPE}/${TARGET}/... ; \ + ${GOPATH}/bin/golangci-lint run ./${TYPE}/${TARGET}/... --config=.github/linters/.golangci.yml; \ fi # @clang-format -i $(shell find . -type f -name '*.proto') diff --git a/config/base/service/account/service.yaml b/config/base/service/account/service.yaml index a59aaecc..41ae3925 100644 --- a/config/base/service/account/service.yaml +++ b/config/base/service/account/service.yaml @@ -7,7 +7,8 @@ spec: # We want the servers to become available even if they're not ready publishNotReadyAddresses: true ports: - - name: grpc-port + - name: grpc-web + appProtocol: grpc-web port: 8080 protocol: TCP targetPort: grpc-port diff --git a/config/base/service/emailer/service.yaml b/config/base/service/emailer/service.yaml index a59aaecc..b92ead29 100644 --- a/config/base/service/emailer/service.yaml +++ b/config/base/service/emailer/service.yaml @@ -8,6 +8,7 @@ spec: publishNotReadyAddresses: true ports: - name: grpc-port + appProtocol: grpc port: 8080 protocol: TCP targetPort: grpc-port diff --git a/config/base/service/greeter/service-headless.yaml b/config/base/service/greeter/service-headless.yaml new file mode 100644 index 00000000..a3d54895 --- /dev/null +++ b/config/base/service/greeter/service-headless.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: service-headless +spec: + clusterIP: None + # We want the servers to become available even if they're not ready + publishNotReadyAddresses: true + ports: + - name: grpc-port + appProtocol: grpc + port: 8080 + protocol: TCP + targetPort: grpc-port diff --git a/config/base/service/greeter/service.yaml b/config/base/service/greeter/service.yaml index a59aaecc..b92ead29 100644 --- a/config/base/service/greeter/service.yaml +++ b/config/base/service/greeter/service.yaml @@ -8,6 +8,7 @@ spec: publishNotReadyAddresses: true ports: - name: grpc-port + appProtocol: grpc port: 8080 protocol: TCP targetPort: grpc-port diff --git a/config/base/service/recorder/service.yaml b/config/base/service/recorder/service.yaml index a59aaecc..b92ead29 100644 --- a/config/base/service/recorder/service.yaml +++ b/config/base/service/recorder/service.yaml @@ -8,6 +8,7 @@ spec: publishNotReadyAddresses: true ports: - name: grpc-port + appProtocol: grpc port: 8080 protocol: TCP targetPort: grpc-port diff --git a/docs/introduction/prerequisites.md b/docs/introduction/prerequisites.md index 6b3504fc..0e9543b4 100644 --- a/docs/introduction/prerequisites.md +++ b/docs/introduction/prerequisites.md @@ -50,6 +50,8 @@ GO111MODULE=off go get github.com/golangci/golangci-lint/cmd/golangci-lint # linter and tool for proto files # (if you use brew to install buf, skip next line) GO111MODULE=on go get github.com/bufbuild/buf/cmd/buf +# prototool make it eazy to use protoc plugins +GO111MODULE=on go get github.com/uber/prototool/cmd/prototool@dev # kind - kubernetes in docker (optional) GO111MODULE=on go get sigs.k8s.io/kind # go lang build/publish/deploy tool (optional) @@ -61,8 +63,16 @@ go install github.com/markbates/pkger/cmd/pkger # fetch protoc plugins into $GOPATH GO111MODULE=off go get github.com/golang/protobuf/{proto,protoc-gen-go} +# (or) get latest +go install github.com/golang/protobuf/protoc-gen-go + GO111MODULE=on go get github.com/micro/micro/v2/cmd/protoc-gen-micro@master + GO111MODULE=on go get github.com/gogo/protobuf/protoc-gen-gofast +GO111MODULE=on go get github.com/gogo/protobuf/protoc-gen-gogofast +GO111MODULE=on go get github.com/gogo/protobuf/protoc-gen-gogofaster +GO111MODULE=on go get github.com/gogo/protobuf/protoc-gen-gogoslick + # GO111MODULE=off go get -u github.com/envoyproxy/protoc-gen-validate # GO111MODULE=off go get -u github.com/infobloxopen/protoc-gen-gorm # getting official micro cli