8000 chore(ci): fix linter and Go test failures by MicBun · Pull Request #998 · trufnetwork/node · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(ci): fix linter and Go test failures #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 13 additions & 54 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,69 +49,28 @@ jobs:

- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install Taskfile
uses: arduino/setup-task@v2

- name: Run Taskfile
run: task kwil-binaries

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
run: task build

- name: Run Go Tests
# skip it while we don't have any tests
if: false
run: |
go test ./internal/...

- name: Setup Docker
uses: docker/setup-buildx-action@v3
run: go test -short -p 1 ./...

- name: Docker Compose Up
# docker compose up --wait makes it exit with 1 even for a successful run
continue-on-error: true
uses: isbang/compose-action@v1.5.1
with:
compose-file: "./compose.yaml"
# waits every container to be ready, so we're sure there's data already
# when in ACT, also force build to ensure it is working locally
up-flags: "--wait ${{env.ACT && '--build --force-recreate --no-deps' || ''}}"
env:
CACHE_FROM: "type=gha,scope=truflation/tn"
CACHE_TO: "type=gha,mode=max,scope=truflation/tn"
- name: Start Single-Node Stack
run: task single:start

# we need it to be manually checked, as above action will always exit with 1 even if it's successful
- name: Check compose status
- name: Wait for node to warm up
run: |
output=$(docker ps -a --format "{{.Names}},{{.Image}},{{.Status}}")

function expect_status() {
image_name=$1
expected_status=$2
image_row=$(echo "$output" | grep "$image_name")
if echo "$image_row" | grep -q "$expected_status"; then
echo "$image_name exited with 0"
else
echo -e "$image_name isn't with expected status $expected_status\n"
echo -e "docker ps output: \n$output\n\n"

# extract the container name, knowing it's the first column
container_name=$(echo "$image_row" | cut -d ',' -f 1)

echo -e "docker logs for $image_name: \n"
docker logs $container_name | tail -n 500

exit 1
fi
}

# we ensure both containers are exited with 0
# if you are running locally, make sure any previous postgres volume state is clean
# otherwise, tn-db will error for out for block state being out of sync.
expect_status "tn-db:local" "Up"
echo "⏳ giving the node 10s to initialize…"
sleep 10

- name: Run Tests
- name: Run CI Tests Script
run: |
scripts/ci-tests.sh
1 change: 1 addition & 0 deletions .github/workflows/deploy-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
deploy-benchmark:
if: ${{ false }} # Disabled for now, enable when ready
name: Deploy Benchmark Stack
runs-on: ubuntu-latest
environment: production
Expand Down
6 changes: 5 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ output:
issues:
exclude-dirs:
- deployments/infra/cdk.out
- vendor
- vendor

linters:
disable:
- errcheck
5 changes: 0 additions & 5 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ services:
build:
context: .
dockerfile: ./deployments/Dockerfile
# For local development, if cache is not supported, please comment the following lines
cache_from:
- ${CACHE_FROM:-type=local,src=/tmp/buildx-cache}/tn-db
cache_to:
- ${CACHE_TO:-type=local,dest=/tmp/buildx-cache-new}/tn-db
args:
- CHAIN_ID=${CHAIN_ID:-trufnetwork-dev}
environment:
Expand Down
1 change: 0 additions & 1 deletion internal/benchmark/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ var (
readerAddress = MustNewEthereumAddressFromString("0x0000000000000000010000000000000000000001")
deployer = MustNewEthereumAddressFromString("0x0000000000000000000000000000000200000000")
fixedDate = time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC)
dailyInterval = time.Hour * 24
secondInterval = time.Second
)
3 changes: 3 additions & 0 deletions internal/benchmark/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (

// Main benchmark test function
func TestBench(t *testing.T) {
if testing.Short() {
t.Skip("skipping benchmark test in short mode")
}
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
LogPhaseEnter(t, "TestBench", "Starting main benchmark test function")
Expand Down
23 changes: 0 additions & 23 deletions internal/benchmark/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ func setupSchemas(

// Separate primitive and composed streams for different handling
var primitiveStreams []setup.StreamInfo
var primitiveNodes []trees.TreeNode
var composedStreams []setup.StreamInfo
var composedNodes []trees.TreeNode

for i, streamInfo := range allStreamInfos {
if input.Tree.Nodes[i].IsLeaf {
primitiveStreams = append(primitiveStreams, streamInfo)
primitiveNodes = append(primitiveNodes, input.Tree.Nodes[i])
} else {
composedStreams = append(composedStreams, streamInfo)
composedNodes = append(composedNodes, input.Tree.Nodes[i])
Expand Down Expand Up @@ -407,27 +405,6 @@ func getMockStreamIds(n int) []util.StreamId {
return streamIds
}

// insertRecordsForPrimitive inserts records for a primitive stream using bulk insert.
func insertRecordsForPrimitive(ctx context.Context, platform *kwilTesting.Platform, stream setup.StreamInfo, rangeParams RangeParameters) error {
records := generateRecords(rangeParams)

input := setup.InsertPrimitiveDataInput{
Platform: platform,
Height: 1,
PrimitiveStream: setup.PrimitiveStreamWithData{
PrimitiveStreamDefinition: setup.PrimitiveStreamDefinition{
StreamLocator: stream.Locator,
},
Data: records,
},
}

if err := setup.InsertPrimitiveDataBatch(ctx, input); err != nil {
return errors.Wrap(err, "failed to execute bulk insert")
}
return nil
}

type RangeParameters struct {
DataPoints int
FromDate time.Time
Expand Down
1 change: 0 additions & 1 deletion internal/benchmark/util/mem_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type DockerMemoryCollector struct {
ctx context.Context
cancel context.CancelFunc
wg sync.WaitGroup
mu sync.Mutex
errChan chan error
firstSampleChan chan struct{}
}
Expand Down
4 changes: 1 addition & 3 deletions tests/streams/aggregation/get_all_weights_for_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ func GetAllWeightsForQuery(ctx context.Context, input GetAllWeightsForQueryInput
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down
4 changes: 4 additions & 0 deletions tests/streams/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ func testComposePermissionControl(t *testing.T, contractInfo setup.StreamInfo) k
ComposingLocator: upperStreamInfo.Locator,
Height: 0,
})
if err != nil {
return errors.Wrapf(err, "failed to check compose permissions for upper stream %s on contract %s",
upperStreamInfo.Locator.StreamId.String(), contractInfo.Locator.StreamId.String())
}
assert.False(t, canCompose, "Upper stream should not be allowed to compose without permission")

// Grant compose permission to the foreign stream
Expand Down
33 changes: 0 additions & 33 deletions tests/streams/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,39 +193,6 @@ func runTestForAllStreamTypes(t *testing.T, testName string, testFn func(ctx con
}
}

// Helper functions for testing
// streamTestingHandler wraps testing.T to include stream information in error messages
type streamTestingHandler struct {
*testing.T
StreamName string
StreamId string
}

// errorCapturingT is a wrapper around testing.T that captures errors instead of failing the test
type errorCapturingT struct {
*testing.T
StreamName string
StreamId string
ErrorOccurred bool
ErrorMessage string
}

// Errorf captures the error message rather than failing the test immediately
func (e *errorCapturingT) Errorf(format string, args ...interface{}) {
e.ErrorOccurred = true
e.ErrorMessage = fmt.Sprintf(format, args...)
// Also log the error to the main test
e.T.Logf("[%s (StreamId: %s)] %s", e.StreamName, e.StreamId, e.ErrorMessage)
}

// Fatalf captures the error message rather than failing the test immediately
func (e *errorCapturingT) Fatalf(format string, args ...interface{}) {
e.ErrorOccurred = true
e.ErrorMessage = fmt.Sprintf(format, args...)
// Also log the error to the main test
e.T.Logf("[%s (StreamId: %s)] %s", e.StreamName, e.StreamId, e.ErrorMessage)
}

// [QUERY01] Authorized users (owner and whitelisted wallets) can query records over a specified date range.
func testQUERY01_InsertAndGetRecord(t *testing.T) func(ctx context.Context, platform *kwilTesting.Platform) error {
return runTestForAllStreamTypes(t, "QUERY01_InsertAndGetRecord", func(ctx context.Context, platform *kwilTesting.Platform, config TestConfig) error {
Expand Down
28 changes: 7 additions & 21 deletions tests/streams/utils/procedure/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func GetRecord(ctx context.Context, input GetRecordInput) ([]ResultRow, error) {
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -97,9 +95,7 @@ func GetIndex(ctx context.Context, input GetIndexInput) ([]ResultRow, error) {
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -145,9 +141,7 @@ func GetIndexChange(ctx context.Context, input GetIndexChangeInput) ([]ResultRow
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -190,9 +184,7 @@ func GetFirstRecord(ctx context.Context, input GetFirstRecordInput) ([]ResultRow
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -299,9 +291,7 @@ func DescribeTaxonomies(ctx context.Context, input DescribeTaxonomiesInput) ([]R
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -393,9 +383,7 @@ func GetCategoryStreams(ctx context.Context, input GetCategoryStreamsInput) ([]R
}, func(row *common.Row) error {
// Convert the row values to []any
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down Expand Up @@ -544,9 +532,7 @@ func ListStreams(ctx context.Context, input ListStreamsInput) ([]ResultRow, erro
input.BlockHeight,
}, func(row *common.Row) error {
values := make([]any, len(row.Values))
for i, v := range row.Values {
values[i] = v
}
copy(values, row.Values)
resultRows = append(resultRows, values)
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion tests/streams/utils/setup/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func CreateTestRole(ctx context.Context, input CreateTestRoleInput) error {
callerAddr = deployer.Address()

// Also assert that the owner parameter matches the signer's address.
if strings.ToLower(callerAddr) != strings.ToLower(input.Owner) {
if !strings.EqualFold(callerAddr, input.Owner) {
return errors.Errorf("owner parameter (%s) does not match platform signer address (%s)", input.Owner, callerAddr)
}
}
Expand Down
Loading
0