Skip to content

Commit 44bb1ea

Browse files
authored
[Sync] Update project files from source repository (c5b3708) (#250)
* sync(ci): update mage-x and tool versions in workflows * refactor(address): optimize byte slice allocation in address generation Replace inefficient make+append pattern with properly pre-allocated slice and copy operation. This eliminates the makezero lint warning and improves performance by avoiding unnecessary allocations.
1 parent 12c8cf9 commit 44bb1ea

File tree

8 files changed

+140
-20
lines changed

8 files changed

+140
-20
lines changed

.github/.env.base

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ REDIS_CACHE_FORCE_PULL=false # Force pull Redis images even when cache
235235
# 🪄 MAGE-X CONFIGURATION
236236
# ================================================================================================
237237

238-
MAGE_X_VERSION=v1.14.1 # https://github.com/mrz1836/mage-x/releases
238+
MAGE_X_VERSION=v1.15.5 # https://github.com/mrz1836/mage-x/releases
239239
MAGE_X_USE_LOCAL=false # Use local version for development
240240
MAGE_X_CI_SKIP_STEP_SUMMARY=true # Skip duplicate test results in step summary (already in test validation summary)
241241
MAGE_X_AUTO_DISCOVER_BUILD_TAGS=true # Enable auto-discovery of build tags
242242
MAGE_X_AUTO_DISCOVER_BUILD_TAGS_EXCLUDE=race,custom # Comma-separated list of tags to exclude
243243
MAGE_X_FORMAT_EXCLUDE_PATHS=vendor,node_modules,.git,.idea # Format exclusion paths (comma-separated directories to exclude from formatting)
244244
MAGE_X_GITLEAKS_VERSION=8.30.0 # https://github.com/gitleaks/gitleaks/releases
245245
MAGE_X_GOFUMPT_VERSION=v0.9.2 # https://github.com/mvdan/gofumpt/releases
246-
MAGE_X_GOLANGCI_LINT_VERSION=v2.7.2 # https://github.com/golangci/golangci-lint/releases
246+
MAGE_X_GOLANGCI_LINT_VERSION=v2.8.0 # https://github.com/golangci/golangci-lint/releases
247247
MAGE_X_GORELEASER_VERSION=v2.13.2 # https://github.com/goreleaser/goreleaser/releases
248248
MAGE_X_GOVULNCHECK_VERSION=v1.1.4 # https://go.googlesource.com/vuln/+refs
249249
MAGE_X_GO_SECONDARY_VERSION=1.24.x # Secondary Go version for MAGE-X (also our secondary)
@@ -252,7 +252,7 @@ MAGE_X_MOCKGEN_VERSION=v0.6.0 # https://github.c
252252
MAGE_X_NANCY_VERSION=v1.0.52 # https://github.com/sonatype-nexus-community/nancy/releases
253253
MAGE_X_STATICCHECK_VERSION=2025.1.1 # https://github.com/dominikh/go-tools/releases
254254
MAGE_X_SWAG_VERSION=v1.16.6 # https://github.com/swaggo/swag/releases
255-
MAGE_X_YAMLFMT_VERSION=v0.20.0 # https://github.com/google/yamlfmt/releases
255+
MAGE_X_YAMLFMT_VERSION=v0.21.0 # https://github.com/google/yamlfmt/releases
256256
MAGE_X_BENCHSTAT_VERSION=v0.0.0-20251208221838-04cf7a2dca90 # https://pkg.go.dev/golang.org/x/perf/cmd/benchstat
257257

258258
# Exclude magefiles from prebuild - they require 'mage' build tag and fail without it
@@ -335,7 +335,7 @@ GO_PRE_COMMIT_DEBUG=false # Enable verbose debug output for tool
335335
GO_PRE_COMMIT_ALL_FILES=true
336336

337337
# Tool Versions
338-
GO_PRE_COMMIT_GOLANGCI_LINT_VERSION=v2.7.2 # https://github.com/golangci/golangci-lint/releases
338+
GO_PRE_COMMIT_GOLANGCI_LINT_VERSION=v2.8.0 # https://github.com/golangci/golangci-lint/releases
339339
GO_PRE_COMMIT_FUMPT_VERSION=v0.9.2 # https://github.com/mvdan/gofumpt/releases
340340
GO_PRE_COMMIT_GOIMPORTS_VERSION=latest # https://github.com/golang/tools
341341
GO_PRE_COMMIT_GITLEAKS_VERSION=v8.30.0 # https://github.com/gitleaks/gitleaks/releases

.github/actions/setup-benchstat/action.yml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# with:
1717
# benchstat-version: ${{ env.MAGE_X_BENCHSTAT_VERSION }}
1818
# runner-os: ${{ runner.os }}
19+
# go-version: ${{ matrix.go-version }}
1920
#
2021
# Maintainer: @mrz1836
2122
#
@@ -31,22 +32,60 @@ inputs:
3132
runner-os:
3233
description: "Runner OS for cache key (e.g., ubuntu-latest, mac-latest)"
3334
required: true
35+
go-version:
36+
description: "Go version being used (e.g., 1.24.x, 1.22). Benchstat requires Go 1.23+"
37+
required: true
3438

3539
outputs:
3640
cache-hit:
37-
description: "Whether benchstat was restored from cache (true/false)"
41+
description: "Whether benchstat was restored from cache (true/false). Empty if skipped due to Go version."
3842
value: ${{ steps.benchstat-cache.outputs.cache-hit }}
3943
installation-method:
40-
description: "How benchstat was obtained: cached or fresh"
44+
description: "How benchstat was obtained: cached, fresh, or skipped"
4145
value: ${{ steps.installation-summary.outputs.method }}
46+
skipped:
47+
description: "Whether benchstat installation was skipped due to Go version < 1.23"
48+
value: ${{ steps.version-check.outputs.skip }}
4249

4350
runs:
4451
using: "composite"
4552
steps:
53+
# --------------------------------------------------------------------
54+
# Check Go version compatibility (benchstat requires Go 1.23+)
55+
# --------------------------------------------------------------------
56+
- name: 🔍 Check Go version compatibility
57+
id: version-check
58+
shell: bash
59+
run: |
60+
GO_VERSION="${{ inputs.go-version }}"
61+
# Extract major and minor version:
62+
# "1.24.x" -> MAJOR=1, MINOR=24
63+
# "1.22" -> MAJOR=1, MINOR=22
64+
# "1.23.5" -> MAJOR=1, MINOR=23
65+
# "2.0.0" -> MAJOR=2, MINOR=0
66+
MAJOR=$(echo "$GO_VERSION" | sed -E 's/^([0-9]+)\..*/\1/')
67+
MINOR=$(echo "$GO_VERSION" | sed -E 's/^[0-9]+\.([0-9]+).*/\1/')
68+
69+
if [ -z "$MAJOR" ] || [ -z "$MINOR" ] || ! [[ "$MAJOR" =~ ^[0-9]+$ ]] || ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
70+
echo "❌ Could not parse Go version '$GO_VERSION'. Please provide a valid Go version (e.g., '1.23', '1.24.x')." >&2
71+
exit 1
72+
elif [ "$MAJOR" -gt 1 ]; then
73+
# Any Go major version > 1 is considered compatible with the 1.23+ requirement
74+
echo "✅ Go $GO_VERSION >= 1.23: proceeding with benchstat installation"
75+
echo "skip=false" >> $GITHUB_OUTPUT
76+
elif [ "$MAJOR" -eq 1 ] && [ "$MINOR" -lt 23 ]; then
77+
echo "⚠️ Go $GO_VERSION < 1.23: skipping benchstat installation (requires Go 1.23+)"
78+
echo "skip=true" >> $GITHUB_OUTPUT
79+
else
80+
echo "✅ Go $GO_VERSION >= 1.23: proceeding with benchstat installation"
81+
echo "skip=false" >> $GITHUB_OUTPUT
82+
fi
83+
4684
# --------------------------------------------------------------------
4785
# Restore benchstat binary cache
4886
# --------------------------------------------------------------------
4987
- name: 💾 Restore benchstat binary cache
88+
if: steps.version-check.outputs.skip != 'true'
5089
id: benchstat-cache
5190
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
5291
with:
@@ -57,7 +96,7 @@ runs:
5796
# Install cached binary to PATH when cache hits
5897
# --------------------------------------------------------------------
5998
- name: 📦 Install cached benchstat to PATH
60-
if: steps.benchstat-cache.outputs.cache-hit == 'true'
99+
if: steps.version-check.outputs.skip != 'true' && steps.benchstat-cache.outputs.cache-hit == 'true'
61100
shell: bash
62101
run: |
63102
echo "📦 Installing cached benchstat binary to PATH..."
@@ -74,14 +113,14 @@ runs:
74113
# Install benchstat via go install when cache misses
75114
# --------------------------------------------------------------------
76115
- name: ⬇️ Install benchstat (cache miss)
77-
if: steps.benchstat-cache.outputs.cache-hit != 'true'
116+
if: steps.version-check.outputs.skip != 'true' && steps.benchstat-cache.outputs.cache-hit != 'true'
78117
shell: bash
79118
run: |
80119
echo "⬇️ Cache miss – installing benchstat via go install..."
81120
echo "📋 Installing benchstat version: ${{ inputs.benchstat-version }}"
82121
83122
# Install benchstat
84-
go install golang.org/x/perf/cmd/benchstat@${{ inputs.benchstat-version }}
123+
go install "golang.org/x/perf/cmd/benchstat@${{ inputs.benchstat-version }}"
85124
86125
# Cache the binary for future runs
87126
mkdir -p ~/.cache/benchstat-bin
@@ -99,6 +138,14 @@ runs:
99138
id: installation-summary
100139
shell: bash
101140
run: |
141+
# Check if installation was skipped due to Go version
142+
if [[ "${{ steps.version-check.outputs.skip }}" == "true" ]]; then
143+
echo "⏭️ Benchstat installation skipped (Go version < 1.23)"
144+
echo "method=skipped" >> $GITHUB_OUTPUT
145+
echo "📋 Installation method: Skipped"
146+
exit 0
147+
fi
148+
102149
echo "🔍 Verifying benchstat installation..."
103150
104151
# Test that benchstat is available and working

.github/actions/upload-statistics/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ inputs:
4545
description: "Compression level for the artifact (0-9, 6 is default)"
4646
required: false
4747
default: "6"
48+
continue-on-error:
49+
description: "Continue workflow if upload fails (for non-critical artifacts)"
50+
required: false
51+
default: "false"
4852

4953
runs:
5054
using: "composite"
@@ -54,6 +58,7 @@ runs:
5458
# --------------------------------------------------------------------
5559
- name: 📤 Upload ${{ inputs.artifact-name }}
5660
if: always() # Always run to capture data even on job failure
61+
continue-on-error: ${{ inputs.continue-on-error == 'true' }}
5762
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
5863
with:
5964
name: ${{ inputs.artifact-name }}

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
# --------------------------------------------------------------------
165165
- name: 📊 Fetch Dependabot metadata
166166
id: metadata
167-
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0
167+
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
168168
with:
169169
github-token: ${{ secrets.GITHUB_TOKEN }}
170170

.github/workflows/fortress-completion-statistics.yml

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,18 @@ jobs:
551551
TOTAL_FILES_COUNT=$(echo "$LOC_OUTPUT" | jq -r '.total_files_count // empty')
552552
LOC_DATE=$(echo "$LOC_OUTPUT" | jq -r '.date // empty')
553553
554+
# Parse new size metrics
555+
TEST_FILES_SIZE=$(echo "$LOC_OUTPUT" | jq -r '.test_files_size_human // empty')
556+
GO_FILES_SIZE=$(echo "$LOC_OUTPUT" | jq -r '.go_files_size_human // empty')
557+
TOTAL_SIZE=$(echo "$LOC_OUTPUT" | jq -r '.total_size_human // empty')
558+
TEST_AVG_SIZE_BYTES=$(echo "$LOC_OUTPUT" | jq -r '.test_avg_size_bytes // empty')
559+
GO_AVG_SIZE_BYTES=$(echo "$LOC_OUTPUT" | jq -r '.go_avg_size_bytes // empty')
560+
561+
# Parse code quality metrics
562+
AVG_LINES_PER_FILE=$(echo "$LOC_OUTPUT" | jq -r '.avg_lines_per_file // empty')
563+
TEST_COVERAGE_RATIO=$(echo "$LOC_OUTPUT" | jq -r '.test_coverage_ratio // empty')
564+
PACKAGE_COUNT=$(echo "$LOC_OUTPUT" | jq -r '.package_count // empty')
565+
554566
echo " - Test Files LOC: '$TEST_FILES_LOC' (count: $TEST_FILES_COUNT)"
555567
echo " - Go Files LOC: '$GO_FILES_LOC' (count: $GO_FILES_COUNT)"
556568
echo " - Total LOC: '$TOTAL_LOC' (files: $TOTAL_FILES_COUNT)"
@@ -560,6 +572,11 @@ jobs:
560572
if [[ -n "$TEST_FILES_LOC" ]] && [[ -n "$GO_FILES_LOC" ]] && [[ -n "$TOTAL_LOC" ]]; then
561573
LOC_FOUND=true
562574
echo "✅ Successfully parsed LOC JSON data"
575+
576+
# Optionally warn if new metrics are missing
577+
if [[ -z "$TOTAL_SIZE" ]] || [[ -z "$AVG_LINES_PER_FILE" ]]; then
578+
echo "⚠️ Some enhanced metrics are missing (older magex version?)"
579+
fi
563580
fi
564581
else
565582
echo "⚠️ No output from magex metrics:loc json"
@@ -576,17 +593,67 @@ jobs:
576593
DISPLAY_TOTAL_FILES="${TOTAL_FILES_COUNT:-N/A}"
577594
DISPLAY_LOC_DATE="${LOC_DATE:-N/A}"
578595
596+
# Format average sizes for display
597+
if [[ -n "$TEST_AVG_SIZE_BYTES" ]] && [[ "$TEST_AVG_SIZE_BYTES" != "0" ]]; then
598+
DISPLAY_TEST_AVG_SIZE=$(numfmt --to=iec-i --suffix=B "$TEST_AVG_SIZE_BYTES" 2>/dev/null || echo "${TEST_AVG_SIZE_BYTES}B")
599+
else
600+
DISPLAY_TEST_AVG_SIZE="N/A"
601+
fi
602+
603+
if [[ -n "$GO_AVG_SIZE_BYTES" ]] && [[ "$GO_AVG_SIZE_BYTES" != "0" ]]; then
604+
DISPLAY_GO_AVG_SIZE=$(numfmt --to=iec-i --suffix=B "$GO_AVG_SIZE_BYTES" 2>/dev/null || echo "${GO_AVG_SIZE_BYTES}B")
605+
else
606+
DISPLAY_GO_AVG_SIZE="N/A"
607+
fi
608+
609+
DISPLAY_TEST_SIZE="${TEST_FILES_SIZE:-N/A}"
610+
DISPLAY_GO_SIZE="${GO_FILES_SIZE:-N/A}"
611+
DISPLAY_TOTAL_SIZE="${TOTAL_SIZE:-N/A}"
612+
579613
{
580614
echo ""
581615
echo "<br><br>"
582616
echo ""
583617
echo "### 📊 Lines of Code Summary"
584-
echo "| Type | Lines of Code | Files | Date |"
585-
echo "|------|---------------|-------|------|"
586-
echo "| Test Files | $DISPLAY_TEST_LOC | $DISPLAY_TEST_COUNT | $DISPLAY_LOC_DATE |"
587-
echo "| Go Files | $DISPLAY_GO_LOC | $DISPLAY_GO_COUNT | $DISPLAY_LOC_DATE |"
588-
echo "| **Total** | **$DISPLAY_TOTAL_LOC** | **$DISPLAY_TOTAL_FILES** | |"
618+
echo "| Type | Lines of Code | Files | Total Size | Avg Size | Date |"
619+
echo "|------|---------------|-------|------------|----------|------|"
620+
echo "| Test Files | $DISPLAY_TEST_LOC | $DISPLAY_TEST_COUNT | $DISPLAY_TEST_SIZE | $DISPLAY_TEST_AVG_SIZE | $DISPLAY_LOC_DATE |"
621+
echo "| Go Files | $DISPLAY_GO_LOC | $DISPLAY_GO_COUNT | $DISPLAY_GO_SIZE | $DISPLAY_GO_AVG_SIZE | $DISPLAY_LOC_DATE |"
622+
echo "| **Total** | **$DISPLAY_TOTAL_LOC** | **$DISPLAY_TOTAL_FILES** | **$DISPLAY_TOTAL_SIZE** | | |"
589623
echo ""
624+
625+
# Display code quality metrics if available
626+
if [[ -n "$AVG_LINES_PER_FILE" ]] || [[ -n "$TEST_COVERAGE_RATIO" ]] || [[ -n "$PACKAGE_COUNT" ]]; then
627+
echo "#### 📈 Code Quality Metrics"
628+
echo ""
629+
echo "| Metric | Value |"
630+
echo "|--------|-------|"
631+
632+
# Display average lines per file
633+
if [[ -n "$AVG_LINES_PER_FILE" ]]; then
634+
DISPLAY_AVG_LINES=$(LC_NUMERIC=en_US.UTF-8 printf "%.1f" "${AVG_LINES_PER_FILE}")
635+
echo "| Average Lines per File | $DISPLAY_AVG_LINES |"
636+
fi
637+
638+
# Display test coverage ratio
639+
if [[ -n "$TEST_COVERAGE_RATIO" ]]; then
640+
DISPLAY_COVERAGE=$(LC_NUMERIC=en_US.UTF-8 printf "%.1f%%" "${TEST_COVERAGE_RATIO}")
641+
echo "| Test Coverage Ratio | $DISPLAY_COVERAGE |"
642+
fi
643+
644+
# Display package count
645+
if [[ -n "$PACKAGE_COUNT" ]]; then
646+
echo "| Package/Directory Count | $PACKAGE_COUNT |"
647+
fi
648+
649+
# Display total size
650+
if [[ -n "$TOTAL_SIZE" ]]; then
651+
echo "| Total Project Size | $TOTAL_SIZE |"
652+
fi
653+
654+
echo ""
655+
fi
656+
590657
echo "<br><br>"
591658
} >> statistics-section.md
592659

.github/workflows/fortress-coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ jobs:
737737
738738
# Count processed files from coverage output
739739
if [ -f "$COVERAGE_FILE" ]; then
740-
FILES_PROCESSED=$(grep -v '^mode:' "$COVERAGE_FILE" | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
740+
FILES_PROCESSED=$(grep -v '^mode:' "$COVERAGE_FILE" | grep '^[^:]*:' | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
741741
echo "📁 Files processed: $FILES_PROCESSED"
742742
fi
743743
@@ -2463,7 +2463,7 @@ jobs:
24632463
fi
24642464
fi
24652465
2466-
FILES_PROCESSED=$(grep -v '^mode:' "coverage-artifacts/coverage-data/coverage.txt" | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
2466+
FILES_PROCESSED=$(grep -v '^mode:' "coverage-artifacts/coverage-data/coverage.txt" | grep '^[^:]*:' | grep -o '^[^:]*' | sort -u | wc -l | tr -d ' ' || echo "0")
24672467
echo "📈 Calculated coverage percentage: ${COVERAGE_PERCENTAGE}%"
24682468
echo "📁 Files processed: $FILES_PROCESSED"
24692469
else

.github/workflows/fortress-test-matrix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,14 @@ jobs:
172172

173173
# --------------------------------------------------------------------
174174
# Setup benchstat (required for benchmark comparison tests)
175+
# Note: benchstat requires Go 1.23+, action will skip for older versions
175176
# --------------------------------------------------------------------
176177
- name: 📊 Setup benchstat
177178
uses: ./.github/actions/setup-benchstat
178179
with:
179180
benchstat-version: ${{ env.MAGE_X_BENCHSTAT_VERSION }}
180181
runner-os: ${{ matrix.os }}
182+
go-version: ${{ matrix.go-version }}
181183

182184
# --------------------------------------------------------------------
183185
# Setup Redis service using composite action with caching

address.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ func GetAddressFromPubKey(publicKey *bec.PublicKey, compressed, mainnet bool) (*
134134
// go-bt/v2/bscript does not have a function that exports the uncompressed address
135135
// https://github.com/libsv/go-bt/blob/master/bscript/address.go#L98
136136
hash := crypto.Hash160(publicKey.SerialiseUncompressed())
137-
bb := make([]byte, 1)
138-
//nolint: makezero // we need to set up the array with 1
139-
bb = append(bb, hash...)
137+
bb := make([]byte, 1+len(hash))
138+
copy(bb[1:], hash)
140139
return &bscript.Address{
141140
AddressString: bscript.Base58EncodeMissingChecksum(bb),
142141
PublicKeyHash: hex.EncodeToString(hash),

0 commit comments

Comments
 (0)