This is an automated email from the ASF dual-hosted git repository.
Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 419c84a4e modernize github ci
419c84a4e is described below
commit 419c84a4eda76f452869a5bdf5623a461b0600c9
Author: alanxtl <[email protected]>
AuthorDate: Fri Aug 14 11:27:01 2026 +0800
modernize github ci
---
.github/actions/setup-go/action.yml | 12 ++++
.github/actions/setup-tools/action.yml | 11 ++++
.github/workflows/codeql-analysis.yml | 12 ++--
.github/workflows/github-actions.yml | 88 +++++++------------------
.github/workflows/riscv-build.yml | 32 ++++-----
.github/workflows/tools.yml | 107 ++++++++++++++++++++++++++++++
.gitignore | 1 +
Makefile | 117 +++++++++++++++++++++------------
8 files changed, 243 insertions(+), 137 deletions(-)
diff --git a/.github/actions/setup-go/action.yml
b/.github/actions/setup-go/action.yml
new file mode 100644
index 000000000..57908df3f
--- /dev/null
+++ b/.github/actions/setup-go/action.yml
@@ -0,0 +1,12 @@
+name: Setup Go
+description: Install the repository Go version and restore module/build caches
+
+runs:
+ using: composite
+ steps:
+ - name: Setup Go
+ uses: actions/setup-go@v6
+ with:
+ go-version-file: go.mod
+ cache-dependency-path: |
+ **/go.sum
diff --git a/.github/actions/setup-tools/action.yml
b/.github/actions/setup-tools/action.yml
new file mode 100644
index 000000000..0dc22c0e2
--- /dev/null
+++ b/.github/actions/setup-tools/action.yml
@@ -0,0 +1,11 @@
+name: Setup Go tools cache
+description: Restore cached repository-local Go development tools
+
+runs:
+ using: composite
+ steps:
+ - name: Restore Go tools
+ uses: actions/cache@v6
+ with:
+ path: .tools/bin
+ key: ${{ runner.os }}-${{ runner.arch }}-go-tools-${{
hashFiles('Makefile', 'go.mod', 'go.sum', 'tools/imports-formatter/**') }}
diff --git a/.github/workflows/codeql-analysis.yml
b/.github/workflows/codeql-analysis.yml
index a9f8628dc..a6874353a 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -23,14 +23,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v7
with:
- # We must fetch at least the immediate parents so that if this is
- # a pull request then we can checkout the head.
- fetch-depth: 2
-
- # If this run was triggered by a pull request event, then checkout
- # the head of the pull request instead of the merge commit.
- - run: git checkout HEAD^2
- if: ${{ github.event_name == 'pull_request' }}
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
+
+ - name: Setup Go
+ uses: ./.github/actions/setup-go
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
diff --git a/.github/workflows/github-actions.yml
b/.github/workflows/github-actions.yml
index ca2c8a0ce..28ed006ed 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -12,10 +12,19 @@ on:
permissions:
contents: read
+concurrency:
+ group: ci-${{ github.workflow }}-${{ github.event.pull_request.number ||
github.ref }}
+ cancel-in-progress: true
+
+defaults:
+ run:
+ shell: bash
+
jobs:
license:
name: Check License Header
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@v7
@@ -27,57 +36,25 @@ jobs:
config: .licenserc.yaml
mode: check
- CI:
- name: CI
+ unit-test:
+ name: Unit Test
runs-on: ubuntu-latest
+ timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Go
- uses: actions/setup-go@v6
- with:
- go-version-file: go.mod
-
- - name: Cache dependencies
- # ref:
https://github.com/actions/cache/blob/main/examples.md#go---module
- uses: actions/cache@v6
- 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: Install generated-project toolchain
- run: |
- sudo apt-get update
- sudo apt-get install -y protobuf-compiler
- go install -mod=readonly google.golang.org/protobuf/cmd/protoc-gen-go
- cd tools/protoc-gen-go-triple
- go install .
- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
-
- - name: Test generated CLI projects
- run: make -C tools/dubbogo-cli test-generated-projects
+ uses: ./.github/actions/setup-go
- - name: Check Code Format
- run: make check-fmt
-
- - name: Unit Test
+ - name: Run unit tests
run: make test
- - name: Lint
- run: make lint
-
- name: Codecov
uses: codecov/codecov-action@v7 #NOSONAR
with:
+ files: coverage.txt
fail_ci_if_error: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false)
@@ -85,37 +62,18 @@ jobs:
Integration-Test:
name: Integration Test
runs-on: ubuntu-latest
+ timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Go
- uses: actions/setup-go@v6
- with:
- go-version-file: go.mod
+ uses: ./.github/actions/setup-go
- - name: Cache dependencies
- # ref:
https://github.com/actions/cache/blob/main/examples.md#go---module
- uses: actions/cache@v6
- 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: Integration Test
- run: |
- if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
- ./integrate_test.sh
${{github.event.pull_request.head.repo.full_name}}
${{github.event.pull_request.head.sha}} main
- elif [ "$GITHUB_EVENT_NAME" == "push" ]; then
- ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA
$GITHUB_REF_NAME
- else
- echo "$GITHUB_EVENT_NAME is an unsupported event type."
- exit 1
- fi
+ - name: Run integration tests
+ env:
+ INTEGRATION_REPO: ${{ github.event.pull_request.head.repo.full_name
|| github.repository }}
+ INTEGRATION_SHA: ${{ github.event.pull_request.head.sha ||
github.sha }}
+ INTEGRATION_BRANCH: ${{ github.event_name == 'pull_request' &&
'main' || github.ref_name }}
+ run: ./integrate_test.sh "$INTEGRATION_REPO" "$INTEGRATION_SHA"
"$INTEGRATION_BRANCH"
diff --git a/.github/workflows/riscv-build.yml
b/.github/workflows/riscv-build.yml
index 27df86b46..9d0e4950b 100644
--- a/.github/workflows/riscv-build.yml
+++ b/.github/workflows/riscv-build.yml
@@ -13,36 +13,26 @@ on:
permissions:
contents: read
+concurrency:
+ group: riscv-${{ github.workflow }}-${{ github.event.pull_request.number ||
github.ref }}
+ cancel-in-progress: true
+
+defaults:
+ run:
+ shell: bash
+
jobs:
RISC-V-Build:
name: RISC-V Build (linux/riscv64)
runs-on: ubuntu-latest
+ timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Go
- uses: actions/setup-go@v6
- with:
- go-version-file: go.mod
-
- - name: Cache dependencies
- # ref:
https://github.com/actions/cache/blob/main/examples.md#go---module
- uses: actions/cache@v6
- with:
- # Cache, works only on Linux
- path: |
- ~/.cache/go-build
- ~/go/pkg/mod
- # Cache key
- key: ${{ runner.os }}-riscv64-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 }}-riscv64-go-
+ uses: ./.github/actions/setup-go
- name: Build for linux/riscv64
- run: |
- GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go build ./...
- cd tools/dubbogo-cli
- GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go build ./...
+ run: make build GOOS=linux GOARCH=riscv64 CGO_ENABLED=0
diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml
new file mode 100644
index 000000000..7cc9469ea
--- /dev/null
+++ b/.github/workflows/tools.yml
@@ -0,0 +1,107 @@
+name: Tools
+
+on:
+ push:
+ branches:
+ - main
+ - 'release-*'
+ - 'feature-*'
+ paths:
+ - '**/*.go'
+ - 'go.mod'
+ - 'go.sum'
+ - 'tools/**'
+ - 'Makefile'
+ - '.golangci.yml'
+ - '.github/actions/setup-go/action.yml'
+ - '.github/workflows/tools.yml'
+ pull_request:
+ branches:
+ - '**'
+ paths:
+ - '**/*.go'
+ - 'go.mod'
+ - 'go.sum'
+ - 'tools/**'
+ - 'Makefile'
+ - '.golangci.yml'
+ - '.github/actions/setup-go/action.yml'
+ - '.github/workflows/tools.yml'
+
+permissions:
+ contents: read
+
+concurrency:
+ group: tools-${{ github.workflow }}-${{ github.event.pull_request.number ||
github.ref }}
+ cancel-in-progress: true
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ format:
+ name: Format
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+
+ - name: Setup Go
+ uses: ./.github/actions/setup-go
+
+ - name: Restore Go tools
+ uses: ./.github/actions/setup-tools
+
+ - name: Apply formatters
+ run: make fmt
+
+ - name: Verify formatter output
+ run: git diff --exit-code -- '*.go'
+
+ lint:
+ name: Lint
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+
+ - name: Setup Go
+ uses: ./.github/actions/setup-go
+
+ - name: Restore Go tools
+ uses: ./.github/actions/setup-tools
+
+ - name: Run lint
+ run: make lint
+
+ generated-projects:
+ name: Generated CLI Projects
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+
+ - name: Setup Go
+ uses: ./.github/actions/setup-go
+
+ - name: Install protobuf compiler
+ run: |
+ sudo apt-get update
+ sudo apt-get install --no-install-recommends -y protobuf-compiler
+
+ - name: Install generated-project toolchain
+ env:
+ GOBIN: ${{ runner.temp }}/bin
+ run: |
+ mkdir -p "$GOBIN"
+ go install -mod=readonly google.golang.org/protobuf/cmd/protoc-gen-go
+ cd tools/protoc-gen-go-triple
+ go install .
+ echo "$GOBIN" >> "$GITHUB_PATH"
+
+ - name: Test generated CLI projects
+ run: make -C tools/dubbogo-cli test-generated-projects
diff --git a/.gitignore b/.gitignore
index 6e7064789..f9309d955 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ metadata/report/zookeeper/zookeeper-4unittest/
.*.sw?
/license-header-checker-linux/
/license-header-checker-linux.zip
+/.tools/
# macOS
.DS_Store
diff --git a/Makefile b/Makefile
index 771234ae8..5a49ce83d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,52 +26,83 @@ MAKEFLAGS += --no-print-directory
CLI_DIR = tools/dubbogo-cli
IMPORTS_FORMATTER_DIR = tools/imports-formatter
-.PHONY: help test fmt clean lint check-fmt
-
-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
- GOTOOLCHAIN=go1.25.0+auto go test ./... -coverprofile=coverage.txt
-covermode=atomic
- cd $(CLI_DIR) && GOTOOLCHAIN=go1.25.0+auto go test ./...
-
-fmt: install-imports-formatter
- # replace interface{} with any
- go run
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/[email protected] -fix
-test ./...
- go fmt ./... && GOROOT=$(shell go env GOROOT) imports-formatter
- cd $(CLI_DIR) && go fmt ./...
-
-# This command is used in CI to verify that code formatting is correct
-check-fmt:
- @echo "Checking code format..."
- @$(MAKE) fmt
- @if ! git diff --exit-code --quiet; then \
- echo "Error: The following files have formatting changes:"; \
- git diff --name-only; \
- echo ""; \
- echo "Formatting diff:"; \
- git --no-pager diff --; \
- echo ""; \
- echo "Please run 'make fmt' to fix formatting issues and commit
the changes."; \
+GO ?= go
+TOOLS_DIR ?= .tools
+TOOLS_BIN := $(TOOLS_DIR)/bin
+COVERAGE_FILE ?= coverage.txt
+
+GOLANGCI_LINT_VERSION ?= v2.7.2
+MODERNIZE_VERSION ?= v0.21.1
+
+ifeq ($(OS),Windows_NT)
+BIN_EXT := .exe
+else
+BIN_EXT :=
+endif
+
+GOLANGCI_LINT := $(TOOLS_BIN)/golangci-lint$(BIN_EXT)
+IMPORTS_FORMATTER := $(TOOLS_BIN)/imports-formatter$(BIN_EXT)
+MODERNIZE := $(TOOLS_BIN)/modernize$(BIN_EXT)
+GOLANGCI_LINT_STAMP := $(TOOLS_BIN)/.golangci-lint-$(GOLANGCI_LINT_VERSION)
+IMPORTS_FORMATTER_STAMP := $(TOOLS_BIN)/.imports-formatter
+MODERNIZE_STAMP := $(TOOLS_BIN)/.modernize-$(MODERNIZE_VERSION)
+
+# Pass cross-compilation settings to every Go command without changing the
host environment.
+GO_ENV := $(strip $(if $(GOOS),GOOS=$(GOOS)) $(if $(GOARCH),GOARCH=$(GOARCH))
$(if $(CGO_ENABLED),CGO_ENABLED=$(CGO_ENABLED)))
+GO_RUN = $(GO_ENV) $(GO)
+
+.PHONY: help build test test-race fmt check-fmt clean lint tools
+
+help: ## Show available commands
+ @awk 'BEGIN {FS = ":.*##"; printf "Usage: make <target>\n\nTargets:\n"}
/^[a-zA-Z0-9_.-]+:.*##/ {printf " %-22s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
+
+build: ## Build the root module and the CLI
+ $(GO_RUN) build ./...
+ cd $(CLI_DIR) && $(GO_RUN) build ./...
+
+test: clean ## Run unit tests and write the root coverage profile
+ $(GO_RUN) test ./... -coverprofile=$(CURDIR)/$(COVERAGE_FILE)
-covermode=atomic
+ cd $(CLI_DIR) && $(GO_RUN) test ./...
+
+test-race: clean ## Run unit tests with the race detector
+ $(GO_RUN) test ./... -race -coverprofile=$(CURDIR)/$(COVERAGE_FILE)
-covermode=atomic
+ cd $(CLI_DIR) && $(GO_RUN) test ./... -race
+
+fmt: $(MODERNIZE_STAMP) $(IMPORTS_FORMATTER_STAMP) ## Format Go code and
modernize syntax
+ # Replace interface{} with any and apply the repository's import
grouping rules.
+ $(MODERNIZE) -fix -test ./...
+ $(GO_RUN) fmt ./...
+ GOROOT=$$($(GO) env GOROOT) $(IMPORTS_FORMATTER)
+ cd $(CLI_DIR) && $(GO_RUN) fmt ./...
+
+check-fmt: ## Check gofmt output without modifying files
+ @unformatted="$$(git ls-files '*.go' | xargs gofmt -l)"; \
+ if [ -n "$$unformatted" ]; then \
+ echo "Error: gofmt changes are required:"; \
+ echo "$$unformatted"; \
+ echo "Run 'make fmt' and commit the result."; \
exit 1; \
fi
-# Clean test generate files
-clean:
- rm -rf coverage.txt
+clean: ## Remove generated test artifacts
+ rm -f $(COVERAGE_FILE)
+
+lint: $(GOLANGCI_LINT_STAMP) ## Run the configured golangci-lint checks
+ $(GOLANGCI_LINT) run ./... --timeout=10m
+
+tools: $(GOLANGCI_LINT_STAMP) $(IMPORTS_FORMATTER_STAMP) $(MODERNIZE_STAMP) ##
Install pinned development tools locally
+
+$(TOOLS_BIN):
+ mkdir -p $@
-# Run golangci-lint
-lint: install-golangci-lint
- go vet ./...
- golangci-lint run ./... --timeout=10m
+$(GOLANGCI_LINT_STAMP): | $(TOOLS_BIN)
+ GOBIN=$(abspath $(TOOLS_BIN)) $(GO) install
github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
+ touch $@
-install-golangci-lint:
- go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
+$(IMPORTS_FORMATTER_STAMP): | $(TOOLS_BIN)
+ cd $(IMPORTS_FORMATTER_DIR) && GOBIN=$(abspath $(TOOLS_BIN)) $(GO)
install .
+ touch $@
-install-imports-formatter:
- cd $(IMPORTS_FORMATTER_DIR) && go install
+$(MODERNIZE_STAMP): | $(TOOLS_BIN)
+ GOBIN=$(abspath $(TOOLS_BIN)) $(GO) install
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@$(MODERNIZE_VERSION)
+ touch $@