Skip to content

Commit 6c5389a

Browse files
authored
Fix go build pre-commit hook, make it pass (#1786)
* fix go build pre-commit * fix go build pre-commit, remove stale module
1 parent 1e4204c commit 6c5389a

File tree

10 files changed

+53
-1663
lines changed

10 files changed

+53
-1663
lines changed

.githooks/go-test-build

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,37 @@
22

33
set -e
44

5-
# Find all 'go.mod' files, excluding the 'seth' directory, get their directories, and run an empty 'go test' in them to compile the tests.
6-
# Seth is excluded because it can't be tested like this, env vars are required and setup
7-
find "./" -path "./seth" -prune -o -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do
5+
echo "Compiling tests in all packages (excluding seth)"
6+
7+
# Use a temporary file to track failures since variables in pipe loops don't persist
8+
FAILED_FILE=$(mktemp)
9+
trap 'rm -f "$FAILED_FILE"' EXIT
10+
11+
# Find all 'go.mod' files, excluding the 'seth' directory
12+
find "./" -name "go.mod" ! -path ".*seth*" -print0 | while IFS= read -r -d $'\0' file; do
813
dir=$(dirname "$file")
9-
echo "Executing cd \"$dir\" && go test -run=^# ./..."
10-
cd "$dir"
11-
go test -run=^# ./...
12-
cd -
13-
done
14+
echo "=== Compiling tests in $dir ==="
15+
16+
# Run in a subshell to avoid cd issues
17+
(
18+
cd "$dir"
19+
# Check if there are any test files before running go test
20+
if [ -n "$(find . -name '*_test.go' -print -quit)" ]; then
21+
if ! go test -run=^# ./...; then
22+
echo "Error: Failed to compile tests in $dir" >&2
23+
exit 1 # This exits the subshell
24+
fi
25+
else
26+
echo "No test files found in $dir"
27+
fi
28+
) || echo "1" >> "$FAILED_FILE" # Record failure
29+
done
30+
31+
# Check if we had any failures
32+
if [ -s "$FAILED_FILE" ]; then
33+
echo "Error: Some packages failed to compile" >&2
34+
exit 1
35+
fi
36+
37+
echo "Test compilation complete"
38+
exit 0

_typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[files]
22
extend-exclude = [
3+
"**/logs.txt",
34
"**/go-cache",
45
"framework/examples/myproject_cll/README.md",
56
"framework/components/blockchain/tron.go",

seth/examples_wasp/README.md

Lines changed: 0 additions & 109 deletions
This file was deleted.

seth/examples_wasp/client_main_test.go

Lines changed: 0 additions & 130 deletions
This file was deleted.

seth/examples_wasp/client_wasp_test.go

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)