From 0e73c1ed15de28ac9b3577d043d89586d4d58e89 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Wed, 10 Jan 2024 01:41:54 +0000 Subject: [PATCH] ci: update for pkgs --- .github/workflows/go-test.yml | 6 ++-- .github/workflows/golangci-lint.yml | 28 +---------------- .goreleaser.yaml | 48 +++++++++++++++++++++++++++++ Makefile | 12 +++++--- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 89587db7..b690301d 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -20,8 +20,10 @@ jobs: with: go-version: '1.20' - name: Run coverage - run: make init-test && make test-all + run: make init-test && make test-unit +# run: make init-test && make test-all - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./coverage-unit.out,./coverage-goc.out + files: ./coverage-unit.out +# files: ./coverage-unit.out,./coverage-goc.out diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 75b712ba..b8e414fd 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,30 +21,4 @@ jobs: go-version: '1.20' - uses: actions/checkout@v4 - 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.55.2 - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: --fix --timeout 5m - - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true - - # Optional: if set to true then the all caching functionality will be complete disabled, - # takes precedence over all other caching options. - # skip-cache: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true -# - name: Apply Changes -# uses: stefanzweifel/git-auto-commit-action@v4 -# with: -# commit_message: 'chore: apply linter fixes' + run: make init-lint && make lint diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 41f3a0f7..0177ac2c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -42,6 +42,54 @@ builds: ldflags: - -s -w -X main.name={{.ProjectName}} -X main.version={{.Summary}} -X main.date={{.Date}} -X main.protoVersion={{.Env.PROTO_VERSION}} #buildmode: c-archive + - id: porter-rss + main: ./pkg/porter-rss/cmd/porter-rss + binary: porter-rss + goos: + - darwin + - windows + - linux + goarch: + - amd64 + - arm64 + goamd64: + - v1 + flags: + - -tags=release + ldflags: + - -s -w -X main.version={{.Summary}} + - id: porter-steam + main: ./pkg/porter-steam/cmd/porter-steam + binary: porter-steam + goos: + - darwin + - windows + - linux + goarch: + - amd64 + - arm64 + goamd64: + - v1 + flags: + - -tags=release + ldflags: + - -s -w -X main.version={{.Summary}} + - id: porter-telegram + main: ./pkg/porter-telegram/cmd/porter-telegram + binary: porter-telegram + goos: + - darwin + - windows + - linux + goarch: + - amd64 + - arm64 + goamd64: + - v1 + flags: + - -tags=release + ldflags: + - -s -w -X main.version={{.Summary}} archives: - format: tar.gz diff --git a/Makefile b/Makefile index a5dd50d4..319d1404 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,12 @@ endif .PHONY: init # init env -init: +init: init-lint go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest go install github.com/go-kratos/kratos/cmd/kratos/v2@latest + +init-lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 init-test: @@ -48,8 +50,8 @@ lint: lint-pkgs lint-root lint-root: @echo "linting root package" - @golangci-lint run --fix - @golangci-lint run # re-run to make sure fixes are valid, useful in some condition + @golangci-lint run --fix --timeout 5m + @golangci-lint run --timeout 5m # re-run to make sure fixes are valid, useful in some condition lint-pkgs: @for d in pkg/*; do \ @@ -57,8 +59,8 @@ lint-pkgs: cd $$d; \ echo "linting $$d"; \ go mod tidy; \ - golangci-lint run -c ../../.golangci.yml --fix; \ - golangci-lint run -c ../../.golangci.yml; \ + golangci-lint run -c ../../.golangci.yml --fix --timeout 5m; \ + golangci-lint run -c ../../.golangci.yml --timeout 5m; \ cd ../../; \ fi \ done