Skip to content

Commit

Permalink
remove zig. remove cgo dependency for sqlite (using pkg.go.dev/modern…
Browse files Browse the repository at this point in the history
…c.org/sqlite)
  • Loading branch information
AnalogJ committed Jul 7, 2022
1 parent 797a6b0 commit 4419f7f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 764 deletions.
25 changes: 9 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,21 @@ jobs:
matrix:
cfg:
- { on: ubuntu-latest, goos: linux, goarch: amd64 }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 5, zig_cc_target: armv5-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 6, zig_cc_target: armv6-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 7, zig_cc_target: armv7-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm64, zig_cc_target: aarch64v8-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 5 }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 6 }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 7 }
- { on: ubuntu-latest, goos: linux, goarch: arm64 }
- { on: macos-latest, goos: darwin, goarch: amd64 }
- { on: macos-latest, goos: darwin, goarch: arm64, zig_cc_target: aarch64v8-macos }
- { on: macos-latest, goos: freebsd, goarch: amd64, zig_cc_target: x86_64-freebsd }
- { on: macos-latest, goos: freebsd, goarch: arm64, zig_cc_target: aarch64v8-freebsd }
- { on: windows-latest, goos: windows, goarch: amd64, zig_cc_target: x86_64-windows-gnu }
- { on: windows-latest, goos: windows, goarch: arm64, zig_cc_target: aarch64v8-windows-gnu }
- { on: macos-latest, goos: darwin, goarch: arm64 }
- { on: macos-latest, goos: freebsd, goarch: amd64 }
- { on: macos-latest, goos: freebsd, goarch: arm64 }
- { on: windows-latest, goos: windows, goarch: amd64 }
- { on: windows-latest, goos: windows, goarch: arm64 }
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v1
with:
version: v0.9
- name: Build Binaries
run: |
zig version
which zig
echo $PATH
make binary-clean binary-all
- name: Archive
uses: actions/upload-artifact@v2
Expand Down
39 changes: 16 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,25 @@
########################################################################################################################
# Global Env Settings
########################################################################################################################
export CGO_ENABLED = 1
export CGO_ENABLED = 0
GO_WORKSPACE ?= /go/src/github.com/analogj/scrutiny

COLLECTOR_BINARY_NAME = scrutiny-collector-metrics
WEB_BINARY_NAME = scrutiny-web
LD_FLAGS =

WEB_STATIC_TAGS =
COLLECTOR_STATIC_TAGS =

STATIC_TAGS =
# enable multiarch docker image builds
DOCKER_TARGETARCH_BUILD_ARG =
ifdef TARGETARCH
DOCKER_TARGETARCH_BUILD_ARG := $(DOCKER_TARGETARCH_BUILD_ARG) --build-arg TARGETARCH=$(TARGETARCH)
endif

# enable to build static binaries.
ifdef STATIC
LD_FLAGS := $(LD_FLAGS) -extldflags=-static
WEB_STATIC_TAGS := $(WEB_STATIC_TAGS) -tags "static netgo sqlite_omit_load_extension"
COLLECTOR_STATIC_TAGS := $(COLLECTOR_STATIC_TAGS) -tags "static netgo"
endif
#enable to do cross compilation (build windows/mac binaries on linux)
ifdef ZIG_CROSS_COMPILE_TARGET
ZIG_BINARY != which zig
export CC = $(ZIG_BINARY) cc -target $(ZIG_CROSS_COMPILE_TARGET)
export CXX = $(ZIG_BINARY) cc -target $(ZIG_CROSS_COMPILE_TARGET)
STATIC_TAGS := $(STATIC_TAGS) -tags "static netgo"
endif

ifdef GOOS
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOOS)
WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOOS)
Expand Down Expand Up @@ -68,15 +63,15 @@ binary-dep:

.PHONY: binary-test
binary-test: binary-dep
go test -v -tags "static" ./...
go test -v $(STATIC_TAGS) ./...

.PHONY: binary-test-coverage
binary-test-coverage: binary-dep
go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" ./...
go test -race -coverprofile=coverage.txt -covermode=atomic -v $(STATIC_TAGS) ./...

.PHONY: binary-collector
binary-collector: binary-dep
go build -ldflags "$(LD_FLAGS)" -o $(COLLECTOR_BINARY_NAME) $(COLLECTOR_STATIC_TAGS) ./collector/cmd/collector-metrics/
go build -ldflags "$(LD_FLAGS)" -o $(COLLECTOR_BINARY_NAME) $(STATIC_TAGS) ./collector/cmd/collector-metrics/
ifneq ($(OS),Windows_NT)
chmod +x $(COLLECTOR_BINARY_NAME)
file $(COLLECTOR_BINARY_NAME) || true
Expand All @@ -86,7 +81,7 @@ endif

.PHONY: binary-web
binary-web: binary-dep
go build -ldflags "$(LD_FLAGS)" -o $(WEB_BINARY_NAME) $(WEB_STATIC_TAGS) ./webapp/backend/cmd/scrutiny/
go build -ldflags "$(LD_FLAGS)" -o $(WEB_BINARY_NAME) $(STATIC_TAGS) ./webapp/backend/cmd/scrutiny/
ifneq ($(OS),Windows_NT)
chmod +x $(WEB_BINARY_NAME)
file $(WEB_BINARY_NAME) || true
Expand All @@ -107,19 +102,17 @@ binary-frontend:


#############
TARGETARCH ?= amd64

.PHONY: docker-web
.PHONY: docker-collector
docker-collector:
@echo "building collector docker image"
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile.collector -t analogj/scrutiny-dev:collector .
docker build $(DOCKER_TARGETARCH_BUILD_ARG) -f docker/Dockerfile.collector -t analogj/scrutiny-dev:collector .

.PHONY: docker-web
docker-web:
@echo "building web docker image"
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile.web -t analogj/scrutiny-dev:web .
docker build $(DOCKER_TARGETARCH_BUILD_ARG) -f docker/Dockerfile.web -t analogj/scrutiny-dev:web .

.PHONY: docker-omnibus
docker-omnibus:
@echo "building omnibus docker image"
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile -t analogj/scrutiny-dev:omnibus .
docker build $(DOCKER_TARGETARCH_BUILD_ARG) -f docker/Dockerfile -t analogj/scrutiny-dev:omnibus .
33 changes: 19 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ require (
github.com/containrrr/shoutrrr v0.4.4
github.com/fatih/color v1.10.0
github.com/gin-gonic/gin v1.6.3
github.com/glebarez/sqlite v1.4.5
github.com/go-gormigrate/gormigrate/v2 v2.0.0
github.com/golang/mock v1.4.3
github.com/influxdata/influxdb-client-go/v2 v2.9.0
github.com/jaypipes/ghw v0.6.1
github.com/jinzhu/gorm v1.9.16
github.com/mitchellh/mapstructure v1.2.2
github.com/sirupsen/logrus v1.4.2
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.7.1
github.com/urfave/cli/v2 v2.2.0
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
gorm.io/driver/sqlite v1.1.3
gorm.io/gorm v1.20.2
gorm.io/gorm v1.23.5
)

require (
Expand All @@ -31,34 +30,35 @@ require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.17.2 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.2.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect
github.com/jaypipes/pcidb v0.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.1 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/klauspost/compress v1.12.1 // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kvz/logstreamer v0.0.0-20150507115422-a635b98146f0 // indirect
github.com/kvz/logstreamer v0.0.0-20201023134116-02d20f4338f5 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-sqlite3 v1.14.4 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.1 // indirect
github.com/nxadm/tail v1.4.6 // indirect
github.com/onsi/ginkgo v1.14.2 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
Expand All @@ -69,15 +69,20 @@ require (
github.com/ugorji/go/codec v1.1.7 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 // indirect
golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gosrc.io/xmpp v0.5.1 // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
nhooyr.io/websocket v1.8.7 // indirect
modernc.org/libc v1.16.8 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.1.1 // indirect
modernc.org/sqlite v1.17.2 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)
Loading

0 comments on commit 4419f7f

Please sign in to comment.