This is an automated email from the ASF dual-hosted git repository. robocanic pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git
The following commit(s) were added to refs/heads/develop by this push: new 5e5230df ci(makefile): add makefile for ci (#1322) 5e5230df is described below commit 5e5230df6b29486997bd6be0413e05677fccfa31 Author: marsevilspirit <marsevilspi...@gmail.com> AuthorDate: Sun Sep 14 19:52:21 2025 +0800 ci(makefile): add makefile for ci (#1322) * ci(makefile): add makefile for ci * style(ci): rename dubbo-admin ci --- .github/workflows/ci.yml | 89 +++++++++++++++++++++++++----------------------- Makefile | 40 ++++++++++++++++++---- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8f4af5b..d735411c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Continues Integration +name: dubbo-admin ci on: push: @@ -24,59 +24,62 @@ on: - develop jobs: - unit-test: - name: Go Test - runs-on: ubuntu-latest - if: github.repository == 'apache/dubbo-admin' - steps: - - uses: actions/checkout@v4 - - name: Set up Go 1.x - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Download dependencies - run: | - go mod download - - name: Go Test - run: | - go test ./... -gcflags=-l -coverprofile=coverage.txt -covermode=atomic - - name: "Upload test result" - if: always() - uses: actions/upload-artifact@v4 - with: - name: test-coverage - path: "**/coverage.txt" - - name: Coverage - run: bash <(curl -s https://codecov.io/bash) - license-check: - name: License Check - Go + name: License Check runs-on: ubuntu-latest if: github.repository == 'apache/dubbo-admin' steps: - uses: actions/checkout@v4 - - name: Set up Go 1.x - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Check License Header uses: apache/skywalking-eyes/header@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config: .licenserc.yaml + mode: check - go-fmt: - name: Go fmt - runs-on: ubuntu-latest + CI: + name: CI (${{ matrix.os }} - Go ${{ matrix.go_version }}) + runs-on: ${{ matrix.os }} + strategy: + # If you want to matrix build , you can append the following list. + matrix: + go_version: + - "1.24" + - "1.23" + os: + - ubuntu-latest if: github.repository == 'apache/dubbo-admin' steps: - uses: actions/checkout@v4 - - name: Set up Go 1.x + - name: Setup Go ${{ matrix.go_version }} uses: actions/setup-go@v5 with: go-version-file: go.mod - - name: Download dependencies - run: | - go mod download - - name: Go Fmt - run: | - go fmt ./... && git status && [[ -z `git status -s` ]] - # diff -u <(echo -n) <(gofmt -d -s .) + - name: Cache dependencies + # ref: https://github.com/actions/cache/blob/main/examples.md#go---module + uses: actions/cache@v4 + with: + # Cache, works only on Linux + path: | + ~/.cache/go-build + ~/go/pkg/mod + # Cache key + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # An ordered list of keys to use for restoring the cache if no cache hit occurred for key + restore-keys: | + ${{ runner.os }}-go- + - name: Check Code Format + run: make fmt && git status && [[ -z `git status -s` ]] + - name: Run Unit Test + run: make test + # TODO(marsevilspirit): add lint + - name: Upload test result + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-coverage + path: "**/coverage.txt" + - name: Coverage + # TODO(marsevilspirit): fix coverage + run: bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 63c2127e..7db582a0 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -SHELL := /usr/bin/env bash +SHELL := bash +.DELETE_ON_ERROR: +.DEFAULT_GOAL := help +.SHELLFLAGS := -eu -o pipefail -c +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-print-directory -.PHONY: build-dubbo-admin -build-dubbo-admin: - CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build \ - -ldflags "-X github.com/apache/dubbo-admin/pkg/version.gitTag=$(GIT_VERSION)" \ - -o bin/dubbo-admin app/dubbo-main/main.go && cp app/dubbo-admin/dubbo-admin.yaml bin/ \ No newline at end of file +.PHONY: help test fmt clean lint + +help: + @echo "Available commands:" + @echo " test - Run unit tests" + @echo " clean - Clean test generate files" + @echo " fmt - Format code" + @echo " lint - Run golangci-lint" + +# Run unit tests +test: clean + go test ./... -gcflags=-l -coverprofile=coverage.txt -covermode=atomic + +fmt: + go fmt ./... + +# Clean test generate files +clean: + rm -rf coverage.txt + +# Run golangci-lint +lint: install-golangci-lint + go vet ./... + golangci-lint run ./... --timeout=10m + +install-golangci-lint: + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0