Skip to content

Commit

Permalink
Upgrade/build params (#78)
Browse files Browse the repository at this point in the history
* add build tags
* update builds to use new tags
  • Loading branch information
jordan-rash committed Jan 22, 2024
1 parent 0f3a363 commit 2523ef8
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 42 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,26 @@ jobs:
name: Build nex cli
working-directory: ./nex
run: go build .


goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: build --verbose --clean --snapshot

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ dist/

# nex binaries
nex/nex
rootfs.ext4
13 changes: 12 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ builds:
binary: "nex"
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
- arm
goarm:
- 7
ignore:
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
ldflags:
- -s -w --X main.VERSION={{.Version}} -X main.COMMIT={{.Commit}} -X main.BUILDDATE={{.Date}}
- -extldflags "-static"
tags:
- netgo
- withui
hooks:
pre:
- go run ./ui/web/build/main.go ./ui/web
Expand All @@ -37,7 +49,6 @@ builds:
hooks:
post:
- sudo go run ./agent/fc-image/. {{.Path}}
- ls -lah

archives:
- id: binaries
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tasks:
sources:
- "*.go"
cmds:
- go build -tags netgo -ldflags '-extldflags "-static"'
- go build -tags netgo,withui -ldflags '-extldflags "-static"'

echo-service:
dir: examples/echoservice
Expand Down
19 changes: 4 additions & 15 deletions nex/nex.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var (
COMMIT = ""
BUILDDATE = ""

ncli = fisk.New("nex", "")
nodes = ncli.Command("node", "Interact with execution engine nodes")

Opts = &models.Options{}
GuiOpts = &models.UiOptions{}
RunOpts = &models.RunOptions{Env: make(map[string]string)}
Expand All @@ -25,9 +28,8 @@ var (

func main() {
blue := color.New(color.FgBlue).SprintFunc()
help := fmt.Sprintf("%s\nNATS Execution Engine CLI Version %s\n", blue(Banner), VERSION)
ncli.Help = fmt.Sprintf("%s\nNATS Execution Engine CLI Version %s\n", blue(Banner), VERSION)

ncli := fisk.New("nex", help)
ncli.Author("Synadia Communications")
ncli.UsageWriter(os.Stdout)
ncli.Version(fmt.Sprintf("v%s [%s] | Built-on: %s", VERSION, COMMIT, BUILDDATE))
Expand All @@ -46,22 +48,13 @@ func main() {
ncli.Flag("timeout", "Time to wait on responses from NATS").Default("2s").Envar("NATS_TIMEOUT").PlaceHolder("DURATION").DurationVar(&Opts.Timeout)
ncli.Flag("namespace", "Scoping namespace for applicable operations").Default("default").Envar("NEX_NAMESPACE").StringVar(&Opts.Namespace)

nodes := ncli.Command("node", "Interact with execution engine nodes")
nodes_ls := nodes.Command("ls", "List nodes")
nodes_ls.Action(ListNodes)

nodes_info := nodes.Command("info", "Get information for an engine node")
nodes_info.Arg("id", "Public key of the node you're interested in").Required().String()
nodes_info.Action(NodeInfo)

node_up := nodes.Command("up", "Starts a NEX node")
node_up.Flag("config", "configuration file for the node").Default("./config.json").StringVar(&NodeOpts.Config)
node_preflight := nodes.Command("preflight", "Checks system for node requirements and installs missing")
node_preflight.Flag("force", "installs missing dependencies without prompt").Default("false").BoolVar(&NodeOpts.ForceDepInstall)
node_preflight.Flag("config", "configuration file for the node").Default("./config.json").StringVar(&NodeOpts.Config)
node_up.Action(RunNodeUp)
node_preflight.Action(RunNodePreflight)

run := ncli.Command("run", "Run a workload on a target node")
run.Arg("url", "URL pointing to the file to run").Required().URLVar(&RunOpts.WorkloadUrl)
run.Arg("id", "Public key of the target node to run the workload").Required().StringVar(&RunOpts.TargetNode)
Expand Down Expand Up @@ -98,9 +91,5 @@ func main() {
evts := ncli.Command("events", "Live monitor events from nex nodes")
evts.Action(WatchEvents)

ui := ncli.Command("ui", "Starts a web server for interacting with Nex")
ui.Flag("port", "Port on which to run the UI").Default("8080").IntVar(&GuiOpts.Port)
ui.Action(RunUI)

ncli.MustParseWithUsage(os.Args[1:])
}
25 changes: 0 additions & 25 deletions nex/node.go

This file was deleted.

36 changes: 36 additions & 0 deletions nex/node_linux_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"context"

nexnode "github.com/ConnectEverything/nex/internal/node"
"github.com/choria-io/fisk"
"github.com/sirupsen/logrus"
)

func init() {
node_up := nodes.Command("up", "Starts a NEX node")
node_up.Flag("config", "configuration file for the node").Default("./config.json").StringVar(&NodeOpts.Config)
node_preflight := nodes.Command("preflight", "Checks system for node requirements and installs missing")
node_preflight.Flag("force", "installs missing dependencies without prompt").Default("false").BoolVar(&NodeOpts.ForceDepInstall)
node_preflight.Flag("config", "configuration file for the node").Default("./config.json").StringVar(&NodeOpts.Config)
node_up.Action(RunNodeUp)
node_preflight.Action(RunNodePreflight)

}

func RunNodeUp(ctx *fisk.ParseContext) error {
log := logrus.New()
ctxx, cancel := context.WithCancel(context.Background())
nexnode.CmdUp(Opts, NodeOpts, ctxx, cancel, log)
<-ctxx.Done()
return nil
}

func RunNodePreflight(ctx *fisk.ParseContext) error {
log := logrus.New()
ctxx, cancel := context.WithCancel(context.Background())
nexnode.CmdPreflight(Opts, NodeOpts, ctxx, cancel, log)

return nil
}
8 changes: 8 additions & 0 deletions nex/ui.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
//go:build withui

package main

import (
nexui "github.com/ConnectEverything/nex/ui"
"github.com/choria-io/fisk"
)

func init() {
ui := ncli.Command("ui", "Starts a web server for interacting with Nex")
ui.Flag("port", "Port on which to run the UI").Default("8080").IntVar(&GuiOpts.Port)
ui.Action(RunUI)
}

func RunUI(ctx *fisk.ParseContext) error {
nexui.ServeUI(GuiOpts.Port)

Expand Down

0 comments on commit 2523ef8

Please sign in to comment.