Skip to content

Commit

Permalink
Merge pull request #1 from alienc0der/master
Browse files Browse the repository at this point in the history
cicd: added cicd pipeline
  • Loading branch information
sumoshi21 committed Apr 13, 2023
2 parents a11a74c + 71b5da3 commit 8c46aba
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 13 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/orchestrator_builder.yml
@@ -0,0 +1,64 @@
name: Build and release orchestrator

on:
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
xgo:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install zip utility
run: |
sudo apt update
sudo apt install -y zip
- name: Make version
run: make version
- name: Build orchestrator
uses: crazy-max/ghaction-xgo@v2.4.0
with:
xgo_version: latest
go_version: 1.20.0
dest: build
prefix: orchestrator
pkg: ./main.go
targets: linux/amd64,linux/arm64
v: true
x: true
ldflags: '-extldflags "-Wl,--allow-multiple-definition"'
buildvcs: false
buildmode: default
trimpath: true
- name: Add execute flag
run: |
chmod +x build/*
- name: Archive files
run: |
cd build
zip orchestrator-linux-amd64.zip orchestrator-linux-amd64
zip orchestrator-linux-arm64.zip orchestrator-linux-arm64
rm orchestrator-linux-amd64
rm orchestrator-linux-arm64
- name: Generate checksums
run: |
cd build
echo $(sha256sum *)
echo $(sha256sum *) >> SHA256CHECKSUMS.txt
- name: Set version
run: |
ORCHESTRATOR=$(cat metadata/version.go | grep Version | awk -F '"' '{print $2}')
echo "ORCHESTRATOR_VERSION=$ORCHESTRATOR" >> $GITHUB_ENV
- name: Upload files to a GitHub release
uses: svenstaro/upload-release-action@2.5.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*
release_name: ${{ env.ORCHESTRATOR_VERSION }}
tag: ${{ env.ORCHESTRATOR_VERSION }}-alphanet
file_glob: true
overwrite: true
body: ""
17 changes: 15 additions & 2 deletions Makefile
@@ -1,11 +1,24 @@
.PHONY: all clean version

GO ?= latest

BINARY_NAME=orchestrator
BUILDDIR = $(shell pwd)/build
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_COMMIT_FILE=$(shell pwd)/metadata/git_commit.go

build:
go build --ldflags '-extldflags "-Wl,--allow-multiple-definition"' -o ${BINARY_NAME} main.go
go build --ldflags '-extldflags "-Wl,--allow-multiple-definition"' -o $(BUILDDIR)/${BINARY_NAME} main.go

run:
./${BINARY_NAME}

version:
@echo "package metadata\n" > $(GIT_COMMIT_FILE)
@echo "const (" >> $(GIT_COMMIT_FILE)
@echo "\tGitCommit = \"${GIT_COMMIT}\"" >> $(GIT_COMMIT_FILE)
@echo ")" >> $(GIT_COMMIT_FILE)

clean:
go clean
rm orchestrator
rm $(BINARY_NAME)
34 changes: 34 additions & 0 deletions app/action_version.go
@@ -0,0 +1,34 @@
package app

import (
"fmt"
"os"
"runtime"

"orchestrator/metadata"

"gopkg.in/urfave/cli.v1"
)

var (
versionCommand = cli.Command{
Action: versionAction,
Name: "version",
Usage: "Print version numbers",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
}
)

func versionAction(*cli.Context) error {
fmt.Printf(`orchestrator
Version:%v
Architecture:%v
Go Version:%v
Operating System:%v
GOPATH:%v
GOROOT:%v
Commit hash:%v
`, metadata.Version, runtime.GOARCH, runtime.Version(), runtime.GOOS, os.Getenv("GOPATH"), runtime.GOROOT(), metadata.GitCommit)
return nil
}
48 changes: 42 additions & 6 deletions app/cli.go
Expand Up @@ -2,9 +2,16 @@ package app

import (
"fmt"
"gopkg.in/urfave/cli.v1"
"net/http"
"os"
"path/filepath"
"runtime"
"sort"
"time"

"orchestrator/metadata"

"gopkg.in/urfave/cli.v1"
)

var (
Expand All @@ -28,20 +35,49 @@ func Stop() {
}

func init() {
app.Name = filepath.Base(os.Args[0])
app.HideVersion = false
app.Version = metadata.Version
app.Compiled = time.Now()
app.Usage = "orchestrator Node"
app.Commands = []cli.Command{
versionCommand,
}
sort.Sort(cli.CommandsByName(app.Commands))

app.Flags = AllFlags
app.Before = beforeAction
app.Action = action
app.After = afterAction
}
func beforeAction(ctx *cli.Context) error {
if len(ctx.Args()) == 0 {
max := runtime.NumCPU()
fmt.Printf("Starting orchestrator.\n")
runtime.GOMAXPROCS(max)

max := runtime.NumCPU()
fmt.Printf("Starting orchestrator.\n")
fmt.Printf("current time is %v\n", time.Now().Format("2009-01-03 18:15:05"))
fmt.Printf("version: %v\n", metadata.Version)
fmt.Printf("git-commit-hash: %v\n", metadata.GitCommit)
fmt.Printf("orchestrator will use at most %v cpu-cores\n", max)
runtime.GOMAXPROCS(max)

// pprof server
if ctx.GlobalIsSet(PprofFlag.Name) {
listenHost := ctx.String(PprofAddrFlag.Name)

port := ctx.Int(PprofPortFlag.Name)

address := fmt.Sprintf("%s:%d", listenHost, port)

go func() {
if err := http.ListenAndServe(address, nil); err != nil {
nodeManager.logger.Error(err.Error())
}
}()
}

return nil
}
func action(ctx *cli.Context) error {
//Make sure No subCommands were entered,Only the flags
if args := ctx.Args(); len(args) > 0 {
return fmt.Errorf("invalid command: %q", args[0])
}
Expand Down
34 changes: 34 additions & 0 deletions app/flags.go
@@ -0,0 +1,34 @@
package app

import (
"gopkg.in/urfave/cli.v1"
)

var (

// pprof

PprofFlag = cli.BoolFlag{
Name: "pprof",
Usage: "Enable the pprof HTTP server",
}
PprofPortFlag = cli.Uint64Flag{
Name: "pprof.port",
Usage: "pprof HTTP server listening port",
Value: 6060,
}

PprofAddrFlag = cli.StringFlag{
Name: "pprof.addr",
Usage: "pprof HTTP server listening interface",
Value: "127.0.0.1",
}

AllFlags = []cli.Flag{

// pprof
PprofFlag,
PprofPortFlag,
PprofAddrFlag,
}
)
6 changes: 3 additions & 3 deletions examples/tss/main.go
Expand Up @@ -119,7 +119,7 @@ func main() {

// Start keygen
fmt.Println("Start keygen")
if err := z.Send(z.Client.BridgeApi.AllowKeygen()); err != nil {
if err := z.Send(z.Client.BridgeApi.SetAllowKeygen(true)); err != nil {
fmt.Println(err)
}
fmt.Println("Done")
Expand Down Expand Up @@ -154,7 +154,7 @@ func main() {

// Keygen is done, setting TSS Public Key
fmt.Println("Keygen is done, setting TSS Public Key", tssPubKey)
if err := z.Send(z.Client.BridgeApi.ChangeTssECDSAPubKey(tssPubKey, "", "", uint32(numPillars))); err != nil {
if err := z.Send(z.Client.BridgeApi.ChangeTssECDSAPubKey(tssPubKey, "", "")); err != nil {
fmt.Println("ChangeTssECDSAPubKey err:")
fmt.Println(err)
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func main() {
fmt.Println("EstimatedMomentumTime: ", orchestratorInfo.EstimatedMomentumTime)
fmt.Println("ConfirmationsToFinality: ", orchestratorInfo.ConfirmationsToFinality)
fmt.Println("AllowKeyGenHeight: ", orchestratorInfo.AllowKeyGenHeight)
fmt.Println("KeySignThreshold: ", orchestratorInfo.KeySignThreshold)
fmt.Println("KeyGenThreshold: ", orchestratorInfo.KeyGenThreshold)
}

fmt.Println("--------------------------------\nSecurity Info")
Expand Down
2 changes: 0 additions & 2 deletions examples/wrap/main.go
Expand Up @@ -48,7 +48,6 @@ func main() {
} else {
fmt.Println("CompressedTssECDSAPubKey: ", bridgeInfo.CompressedTssECDSAPubKey)
fmt.Println("DecompressedTssECDSAPubKey: ", bridgeInfo.DecompressedTssECDSAPubKey)
fmt.Println("AdministratorEDDSAPubKey: ", bridgeInfo.AdministratorEDDSAPubKey)
fmt.Println("AllowKeygen: ", bridgeInfo.AllowKeyGen)
fmt.Println("HaltActivated: ", bridgeInfo.Halted)
fmt.Println("UnhaltHeight: ", bridgeInfo.UnhaltedAt)
Expand All @@ -66,7 +65,6 @@ func main() {
fmt.Println("EstimatedMomentumTime: ", orchestratorInfo.EstimatedMomentumTime)
fmt.Println("ConfirmationsToFinality: ", orchestratorInfo.ConfirmationsToFinality)
fmt.Println("AllowKeyGenHeight: ", orchestratorInfo.AllowKeyGenHeight)
fmt.Println("KeySignThreshold: ", orchestratorInfo.KeySignThreshold)
}

fmt.Println("--------------------------------\nSecurity Info")
Expand Down
5 changes: 5 additions & 0 deletions metadata/git_commit.go
@@ -0,0 +1,5 @@
package metadata

const (
GitCommit = ""
)
5 changes: 5 additions & 0 deletions metadata/version.go
@@ -0,0 +1,5 @@
package metadata

const (
Version = "v0.0.1"
)

0 comments on commit 8c46aba

Please sign in to comment.