Skip to content
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
3 changes: 1 addition & 2 deletions ci/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"

"github.com/mysteriumnetwork/go-ci/commands"
"github.com/mysteriumnetwork/go-ci/util"
"github.com/mysteriumnetwork/node/ci/packages"
Expand Down Expand Up @@ -60,7 +59,7 @@ func CheckGoVet() error {

// CheckGoImports checks for issues with go imports.
func CheckGoImports() error {
return commands.GoImportsD(".", "pb", "tequilapi/endpoints/assets")
return GoImportsD(".", "pb", "tequilapi/endpoints/assets")
}

// CheckSwagger checks whether swagger spec at "tequilapi/docs/swagger.json" is valid against swagger specification 2.0.
Expand Down
108 changes: 108 additions & 0 deletions ci/check/go_imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (C) 2026 The "MysteriumNetwork/node" Authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package check

import (
"errors"
"fmt"
"go/build"
"os"
"path"
"strings"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/mysteriumnetwork/go-ci/shell"
"github.com/mysteriumnetwork/go-ci/util"
)

// GoImportsD checks for issues with go imports.
//
// Instead of packages, it operates on directories, thus it is compatible with gomodules outside GOPATH.
//
// Example:
//
// commands.GoImportsD(".", "docs")
func GoImportsD(dir string, excludes ...string) error {
mg.Deps(GetImports)
goimportsBin, err := util.GetGoBinaryPath("goimports")
if err != nil {
fmt.Println("❌ GoImports")
fmt.Println("Tool 'goimports' not found")
return err
}
var allExcludes []string
allExcludes = append(allExcludes, excludes...)
allExcludes = append(allExcludes, util.GoLintExcludes()...)
dirs, err := util.GetProjectFileDirectories(allExcludes)
if err != nil {
return err
}
out, err := shell.NewCmd(goimportsBin + " -e -l -d " + strings.Join(dirs, " ")).Output()
if err != nil {
fmt.Println("❌ GoImports")
fmt.Println("goimports: error executing")
return err
}
if len(out) != 0 {
fmt.Println("❌ GoImports")
fmt.Println("goimports: the following files contain go import errors:")
fmt.Println(out)
return errors.New("goimports: not all imports follow the goimports format")
}
fmt.Println("✅ GoImports")
return nil
}

// GetGoPath returns the go path
func GetGoPath() string {
gopath := os.Getenv("GOPATH")
if gopath == "" {
gopath = build.Default.GOPATH
}
return gopath
}

// GetGoBinaryPath looks for the given binary in path, if not checks if it's in $GOPATH/bin
func GetGoBinaryPath(binaryName string) (string, error) {
res, err := sh.Output("which", binaryName)
if err == nil {
return res, nil
}
gopath := GetGoPath()
binaryUnderGopath := path.Join(gopath, "bin", binaryName)
if _, err := os.Stat(binaryUnderGopath); os.IsNotExist(err) {
return "", err
}
return binaryUnderGopath, nil
}

// GetImports installs goimports binary.
func GetImports() error {
path, _ := GetGoBinaryPath("goimports")
if path != "" {
fmt.Println("Tool 'goimports' already installed")
return nil
}
err := sh.RunV("go", "install", "golang.org/x/tools/cmd/goimports@v0.41.0")
if err != nil {
fmt.Println("Could not go get goimports")
return err
}
return nil
}
16 changes: 8 additions & 8 deletions metadata/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var MainnetDefinition = NetworkDefinition{
MystAddress: "0x1379e8886a944d2d9d440b3d88df536aea08d9f3",
EtherClientRPC: []string{
"https://polygon1.mysterium.network/",
"https://polygon-rpc.com/",
"https://polygon.drpc.org",
},
KnownHermeses: []string{
"0xa62a2a75949d25e17c6f08a7818e7be97c18a8d2",
Expand All @@ -99,15 +99,15 @@ var MainnetDefinition = NetworkDefinition{
PilvytisAddress: "https://pilvytis.mysterium.network",
ObserverAddress: "https://observer.mysterium.network",
DNSMap: map[string][]string{
"discovery.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81"},
"trust.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81"},
"broker.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81"},
"discovery.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81", "46.224.211.253", "188.245.149.150"},
"trust.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81", "46.224.211.253", "188.245.149.150"},
"broker.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81", "46.224.211.253", "188.245.149.150"},
"transactor.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81",
"51.158.204.23", "51.158.204.75", "51.158.204.9", "51.158.204.30"}, // remove after the migration is complete
"affiliator.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81"},
"51.158.204.23", "51.158.204.75", "51.158.204.9", "51.158.204.30", "46.224.211.253", "188.245.149.150"}, // remove after the migration is complete
"affiliator.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81", "46.224.211.253", "188.245.149.150"},
"pilvytis.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81",
"51.158.204.23", "51.158.204.75", "51.158.204.9", "51.158.204.30"}, // remove after the migration is complete
"observer.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81"},
"51.158.204.23", "51.158.204.75", "51.158.204.9", "51.158.204.30", "46.224.211.253", "188.245.149.150"}, // remove after the migration is complete
"observer.mysterium.network": {"159.69.15.34", "159.69.244.241", "116.203.130.98", "49.12.244.81", "46.224.211.253", "188.245.149.150"},
},
DefaultChainID: 137,
DefaultCurrency: "MYST",
Expand Down
Loading