Skip to content

Commit

Permalink
ci: update for pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Jan 10, 2024
1 parent 9116b6b commit 0e73c1e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 34 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 1 addition & 27 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

init-test:
Expand All @@ -48,17 +50,17 @@ 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 \
if [ -d "$$d" ]; then \
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
Expand Down

0 comments on commit 0e73c1e

Please sign in to comment.