Skip to content

Commit

Permalink
Fix code coverage failing (#4463)
Browse files Browse the repository at this point in the history
## Motivation
Code coverage is failing because it tests packages that are not part of the node code and runs into name collisions of global variables

## Changes
Remove packages of utility tools from code coverage tests and unit tests.

## Test Plan
n/a

## TODO
<!-- This section should be removed when all items are complete -->
- [x] Explain motivation or link existing issue(s)
- [x] Test changes and document test plan
- [x] Update documentation as needed

## DevOps Notes
<!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases -->
- [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
- [x] This PR does not affect public APIs
- [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
- [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
  • Loading branch information
fasmat committed Jun 2, 2023
1 parent f402fb1 commit e4243ff
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 46 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LDFLAGS = -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.
include Makefile-libs.Inc

DOCKER_HUB ?= spacemeshos
UNIT_TESTS ?= $(shell go list ./... | grep -v systest/tests)
UNIT_TESTS ?= $(shell go list ./... | grep -v systest/tests | grep -v cmd/node | grep -v cmd/gen-p2p-identity | grep -v cmd/trace | grep -v genvm/cmd)

COMMIT = $(shell git rev-parse HEAD)
SHA = $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -58,7 +58,6 @@ all: install build
.PHONY: all

install:
go run scripts/check-go-version.go --major 1 --minor 19
go mod download
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.0
go install github.com/spacemeshos/go-scale/[email protected]
Expand All @@ -77,15 +76,15 @@ get-profiler: get-postrs-profiler
.PHONY: get-profiler

gen-p2p-identity:
cd $@ ; go build -o $(BIN_DIR)$@$(EXE) .
cd cmd/gen-p2p-identity ; go build -o $(BIN_DIR)$@$(EXE) .
.PHONY: gen-p2p-identity

go-spacemesh: get-libs
go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) .
cd cmd/node ; go build -o $(BIN_DIR)$@$(EXE) $(LDFLAGS) .
.PHONY: go-spacemesh gen-p2p-identity

bootstrapper:
echo $(BIN_DIR) ; cd cmd/bootstrapper ; go build -o $(BIN_DIR)go-$@$(EXE) .
cd cmd/bootstrapper ; go build -o $(BIN_DIR)go-$@$(EXE) .
.PHONY: bootstrapper

tidy:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ _Note: we need to use eval to interpret the commands since there are spaces in
the values of the variables so the shell can't correctly split them as
arguments._

1. Setting the variables on the same line as the `go` command (e.g., `eval $(make print-env) go build`). This affects the environment for that command invocation only.
1. Setting the variables on the same line as the `go` command (e.g., `eval $(make print-env) go build ./...`). This affects the environment for that command invocation only.
2. Exporting the variables in the shell's environment (e.g., `eval export $(make print-env)`). The variables will persist for the duration of that shell (and will be passed to subshells).
3. Setting the variables in the go environment (e.g., `eval go env -w $(make print-env)`). Persistently adds these values to Go's environment for any future runs.

Expand Down
2 changes: 1 addition & 1 deletion cmd/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/spacemeshos/go-spacemesh/cmd/flags"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/config"
"github.com/spacemeshos/go-spacemesh/node/flags"
)

var (
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion main.go → cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"

"github.com/spacemeshos/go-spacemesh/cmd"
"github.com/spacemeshos/go-spacemesh/cmd/node"
"github.com/spacemeshos/go-spacemesh/node"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/spacemeshos/go-spacemesh/cmd/flags"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/config"
"github.com/spacemeshos/go-spacemesh/config/presets"
"github.com/spacemeshos/go-spacemesh/node/flags"
)

var cfg = config.DefaultConfig()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 1 addition & 7 deletions cmd/node/node.go → node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/spacemeshos/go-spacemesh/bootstrap"
"github.com/spacemeshos/go-spacemesh/checkpoint"
"github.com/spacemeshos/go-spacemesh/cmd"
"github.com/spacemeshos/go-spacemesh/cmd/mapstructureutil"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/config"
"github.com/spacemeshos/go-spacemesh/config/presets"
Expand All @@ -51,6 +50,7 @@ import (
"github.com/spacemeshos/go-spacemesh/mesh"
"github.com/spacemeshos/go-spacemesh/metrics"
"github.com/spacemeshos/go-spacemesh/miner"
"github.com/spacemeshos/go-spacemesh/node/mapstructureutil"
"github.com/spacemeshos/go-spacemesh/p2p"
"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
"github.com/spacemeshos/go-spacemesh/proposals"
Expand Down Expand Up @@ -205,12 +205,6 @@ func init() {
grpclog = grpc_logsettable.ReplaceGrpcLoggerV2()
}

// Service is a general service interface that specifies the basic start/stop functionality.
type Service interface {
Start(ctx context.Context) error
Close()
}

func loadConfig(c *cobra.Command) (*config.Config, error) {
conf, err := LoadConfigFromFile()
if err != nil {
Expand Down
File renamed without changes.
30 changes: 0 additions & 30 deletions scripts/check-go-version.go

This file was deleted.

0 comments on commit e4243ff

Please sign in to comment.