ci: validate gofmt, tidy, and generated files before test (#2022)

Check

- gofmt
- go mod tidy
- generated files

before tests.
This commit is contained in:
Daniel Liu 2026-02-06 17:13:52 +08:00 committed by GitHub
parent 7e12f036cc
commit 29ad6db3bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 10 deletions

View file

@ -5,12 +5,12 @@ on:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
push: push:
branches: branches:
- '*' - "*"
tags: tags:
- '*' - "*"
env: env:
GOPROXY: https://proxy.golang.org GOPROXY: https://proxy.golang.org,direct
GO111MODULE: on GO111MODULE: on
tf_version: "1.3.0" tf_version: "1.3.0"
tf_init_cli_options: "-input=false" tf_init_cli_options: "-input=false"
@ -51,11 +51,33 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
path: ${{ env.GOPATH }}/src/XDPoSChain path: ${{ env.GOPATH }}/src/XDPoSChain
# Cache build tools to avoid downloading them each time
- uses: actions/cache@v4
with:
path: ${{ env.GOPATH }}/src/XDPoSChain/build/cache
key: ${{ runner.os }}-build-tools-cache-${{ hashFiles('**/build/checksums.txt') }}
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
cache: false cache: false
go-version: '1.25.x' go-version: "1.25.x"
- name: Check gofmt
run: |
unformatted=$(git ls-files '*.go' | xargs -r gofmt -l)
if [ -n "$unformatted" ]; then
echo "Unformatted files:"
echo "$unformatted"
exit 1
fi
echo "All Go files are properly formatted."
- name: Check go mod tidy
run: |
set -euo pipefail
go mod tidy -diff 2>&1 | sed '/^go: downloading/d'
echo "go.mod and go.sum are tidy."
- name: Validate generated files
run: |
go run build/ci.go generate
- name: Run tests - name: Run tests
run: ${{ matrix.script }} run: ${{ matrix.script }}
env: env:
@ -109,7 +131,7 @@ jobs:
- name: Set up kubectl - name: Set up kubectl
uses: azure/setup-kubectl@v4 uses: azure/setup-kubectl@v4
with: with:
version: 'v1.19.11' version: "v1.19.11"
- name: Apply new image version to Kubernetes deployments - name: Apply new image version to Kubernetes deployments
run: | run: |
mkdir -p $HOME/.kube mkdir -p $HOME/.kube

View file

@ -408,9 +408,9 @@ var (
Category: flags.APICategory, Category: flags.APICategory,
} }
RPCGlobalLogQueryLimit = &cli.IntFlag{ RPCGlobalLogQueryLimit = &cli.IntFlag{
Name: "rpc-logquerylimit", Name: "rpc-logquerylimit",
Usage: "Maximum number of alternative addresses or topics allowed per search position in eth_getLogs filter criteria (0 = no cap)", Usage: "Maximum number of alternative addresses or topics allowed per search position in eth_getLogs filter criteria (0 = no cap)",
Value: ethconfig.Defaults.LogQueryLimit, Value: ethconfig.Defaults.LogQueryLimit,
Category: flags.APICategory, Category: flags.APICategory,
} }
RPCGlobalRangeLimitFlag = &cli.Uint64Flag{ RPCGlobalRangeLimitFlag = &cli.Uint64Flag{

View file

@ -198,7 +198,7 @@ type Hooks struct {
// for tracing and reporting. // for tracing and reporting.
type BalanceChangeReason byte type BalanceChangeReason byte
//go:generate stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go //go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go
const ( const (
BalanceChangeUnspecified BalanceChangeReason = 0 BalanceChangeUnspecified BalanceChangeReason = 0

2
go.mod
View file

@ -34,6 +34,7 @@ require (
require ( require (
github.com/Microsoft/go-winio v0.6.2 github.com/Microsoft/go-winio v0.6.2
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260124092617-829590d2c921
github.com/btcsuite/btcd/btcec/v2 v2.2.0 github.com/btcsuite/btcd/btcec/v2 v2.2.0
github.com/consensys/gnark-crypto v0.10.0 github.com/consensys/gnark-crypto v0.10.0
github.com/deckarep/golang-set/v2 v2.7.0 github.com/deckarep/golang-set/v2 v2.7.0
@ -64,7 +65,6 @@ require (
) )
require ( require (
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260124092617-829590d2c921 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.5.0 // indirect github.com/bits-and-blooms/bitset v1.5.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect