Skip to content

Commit

Permalink
Update dependencies, use go 1.20, update GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sas1024 committed Feb 2, 2024
1 parent 18ba111 commit 771a779
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 465 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ jobs:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v5
with:
images: |
vmkteam/brokersrv
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.20

- name: Test
env:
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.20

- name: Build
run: go build -v ./...
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.20
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.46
version: v1.54.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 30m
timeout: 30m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ PKG := `go list -f {{.Dir}} ./...`

MAIN := cmd/${NAME}/main.go

VERSION?=$(git version > /dev/null 2>&1 && git describe --dirty=-dirty --always 2>/dev/null || echo NO_VERSION)
LDFLAGS=-ldflags "-X=main.version=$(VERSION)"

fmt:
@goimports -local ${NAME} -l -w $(PKG)

Expand All @@ -16,11 +13,11 @@ lint:
@golangci-lint run -c .golangci.yml

build:
@CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o ${NAME} $(MAIN)
@CGO_ENABLED=0 go build $(GOFLAGS) -o ${NAME} $(MAIN)

run:
@echo "Compiling"
@go run -buildvcs=true $(LDFLAGS) $(GOFLAGS) $(MAIN) -config=cfg/local.toml -verbose
@go run -buildvcs=true $(GOFLAGS) $(MAIN) -config=cfg/local.toml -verbose

mod:
@go mod tidy
26 changes: 24 additions & 2 deletions cmd/brokersrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/rand"
"os"
"os/signal"
"runtime/debug"
"syscall"
"time"

Expand All @@ -23,15 +24,15 @@ var (
flConfigPath = fs.String("config", "config.toml", "Path to config file")
flVerbose = fs.Bool("verbose", false, "enable debug output")
cfg app.Config
version string
)

func main() {
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
flag.DefaultConfigFlagname = "config.flag"
exitOnError(fs.Parse(os.Args[1:]))
fixStdLog(*flVerbose)

version := appVersion()
log.Printf("starting %v version=%v", appName, version)
if _, err := toml.DecodeFile(*flConfigPath, &cfg); err != nil {
exitOnError(err)
Expand Down Expand Up @@ -76,3 +77,24 @@ func exitOnError(err error) {
log.Fatal(err)
}
}

// appVersion returns app version from VCS info
func appVersion() string {
result := "devel"
info, ok := debug.ReadBuildInfo()
if !ok {
return result
}

for _, v := range info.Settings {
if v.Key == "vcs.revision" {
result = v.Value
}
}

if len(result) > 8 {
result = result[:8]
}

return result
}
43 changes: 21 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
module github.com/vmkteam/brokersrv

go 1.18
go 1.20

require (
github.com/BurntSushi/toml v1.2.1
github.com/labstack/echo/v4 v4.9.1
github.com/BurntSushi/toml v1.3.2
github.com/labstack/echo/v4 v4.11.4
github.com/namsral/flag v1.7.4-pre
github.com/nats-io/nats.go v1.23.0
github.com/prometheus/client_golang v1.13.0
github.com/nats-io/nats.go v1.32.0
github.com/prometheus/client_golang v1.18.0
github.com/vmkteam/zenrpc-middleware v1.1.5
github.com/vmkteam/zenrpc/v2 v2.2.8
github.com/vmkteam/zenrpc/v2 v2.2.11
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/getsentry/sentry-go v0.13.0 // indirect
github.com/go-pg/pg/v10 v10.10.6 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/nats-io/nats-server/v2 v2.9.4 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
mellium.im/sasl v0.3.0 // indirect
)
Loading

0 comments on commit 771a779

Please sign in to comment.