make sure we dont depend on tests for building binaries.

empty commit.

fix checkout.

fix checkout.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.

fix zig.
This commit is contained in:
Jason Kulatunga
2022-06-26 15:35:37 -07:00
parent d0b545dfb7
commit 797a6b0429
2 changed files with 43 additions and 16 deletions
+22 -13
View File
@@ -23,7 +23,7 @@ jobs:
- 8086:8086 - 8086:8086
env: env:
PROJECT_PATH: /go/src/github.com/analogj/scrutiny PROJECT_PATH: /go/src/github.com/analogj/scrutiny
CGO_ENABLED: 1 STATIC: true
steps: steps:
- name: Git - name: Git
run: | run: |
@@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Test - name: Test
run: | run: |
make clean binary-test-coverage make binary-clean binary-test-coverage
- name: Generate coverage report - name: Generate coverage report
uses: codecov/codecov-action@v2 uses: codecov/codecov-action@v2
with: with:
@@ -44,31 +44,40 @@ jobs:
verbose: true verbose: true
build: build:
name: Build ${{ matrix.cfg.goos }}/${{ matrix.cfg.goarch }} name: Build ${{ matrix.cfg.goos }}/${{ matrix.cfg.goarch }}
needs: release
runs-on: ${{ matrix.cfg.on }} runs-on: ${{ matrix.cfg.on }}
env: env:
GOOS: ${{ matrix.cfg.goos }} GOOS: ${{ matrix.cfg.goos }}
GOARCH: ${{ matrix.cfg.goarch }} GOARCH: ${{ matrix.cfg.goarch }}
GOARM: ${{ matrix.cfg.goarm }} GOARM: ${{ matrix.cfg.goarm }}
ZIG_CROSS_COMPILE_TARGET: ${{ matrix.cfg.zig_cc_target }}
STATIC: true
strategy: strategy:
matrix: matrix:
cfg: cfg:
- { on: ubuntu-latest, goos: linux, goarch: amd64 } - { on: ubuntu-latest, goos: linux, goarch: amd64 }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 5 } - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 5, zig_cc_target: armv5-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 6 } - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 6, zig_cc_target: armv6-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 7 } - { on: ubuntu-latest, goos: linux, goarch: arm, goarm: 7, zig_cc_target: armv7-linux }
- { on: ubuntu-latest, goos: linux, goarch: arm64 } - { on: ubuntu-latest, goos: linux, goarch: arm64, zig_cc_target: aarch64v8-linux }
- { on: macos-latest, goos: darwin, goarch: amd64 } - { on: macos-latest, goos: darwin, goarch: amd64 }
- { on: macos-latest, goos: darwin, goarch: arm64 } - { on: macos-latest, goos: darwin, goarch: arm64, zig_cc_target: aarch64v8-macos }
- { on: macos-latest, goos: freebsd, goarch: amd64 } - { on: macos-latest, goos: freebsd, goarch: amd64, zig_cc_target: x86_64-freebsd }
- { on: macos-latest, goos: freebsd, goarch: arm64 } - { on: macos-latest, goos: freebsd, goarch: arm64, zig_cc_target: aarch64v8-freebsd }
- { on: windows-latest, goos: windows, goarch: amd64 } - { on: windows-latest, goos: windows, goarch: amd64, zig_cc_target: x86_64-windows-gnu }
- { on: windows-latest, goos: windows, goarch: arm64 } - { on: windows-latest, goos: windows, goarch: arm64, zig_cc_target: aarch64v8-windows-gnu }
steps: steps:
- name: Checkout
uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v1
with:
version: v0.9
- name: Build Binaries - name: Build Binaries
run: | run: |
make clean binary-all
zig version
which zig
echo $PATH
make binary-clean binary-all
- name: Archive - name: Archive
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
+21 -3
View File
@@ -9,9 +9,24 @@ GO_WORKSPACE ?= /go/src/github.com/analogj/scrutiny
COLLECTOR_BINARY_NAME = scrutiny-collector-metrics COLLECTOR_BINARY_NAME = scrutiny-collector-metrics
WEB_BINARY_NAME = scrutiny-web WEB_BINARY_NAME = scrutiny-web
LD_FLAGS = LD_FLAGS =
WEB_STATIC_TAGS =
COLLECTOR_STATIC_TAGS =
# enable to build static binaries.
ifdef STATIC ifdef STATIC
LD_FLAGS := $(LD_FLAGS) -extldflags=-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 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)
endif
ifdef GOOS ifdef GOOS
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOOS) COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOOS)
WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOOS) WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOOS)
@@ -38,7 +53,8 @@ endif
all: binary-all all: binary-all
.PHONY: binary-all .PHONY: binary-all
binary-all: binary-web binary-collector binary-frontend binary-all: binary-collector binary-web
@echo "building all"
.PHONY: binary-clean .PHONY: binary-clean
binary-clean: binary-clean:
@@ -46,6 +62,8 @@ binary-clean:
.PHONY: binary-dep .PHONY: binary-dep
binary-dep: binary-dep:
env
go env
go mod vendor go mod vendor
.PHONY: binary-test .PHONY: binary-test
@@ -58,7 +76,7 @@ binary-test-coverage: binary-dep
.PHONY: binary-collector .PHONY: binary-collector
binary-collector: binary-dep binary-collector: binary-dep
go build -ldflags "$(LD_FLAGS)" -o $(COLLECTOR_BINARY_NAME) -tags "static netgo" ./collector/cmd/collector-metrics/ go build -ldflags "$(LD_FLAGS)" -o $(COLLECTOR_BINARY_NAME) $(COLLECTOR_STATIC_TAGS) ./collector/cmd/collector-metrics/
ifneq ($(OS),Windows_NT) ifneq ($(OS),Windows_NT)
chmod +x $(COLLECTOR_BINARY_NAME) chmod +x $(COLLECTOR_BINARY_NAME)
file $(COLLECTOR_BINARY_NAME) || true file $(COLLECTOR_BINARY_NAME) || true
@@ -68,7 +86,7 @@ endif
.PHONY: binary-web .PHONY: binary-web
binary-web: binary-dep binary-web: binary-dep
go build -ldflags "$(LD_FLAGS)" -o $(WEB_BINARY_NAME) -tags "static netgo sqlite_omit_load_extension" ./webapp/backend/cmd/scrutiny/ go build -ldflags "$(LD_FLAGS)" -o $(WEB_BINARY_NAME) $(WEB_STATIC_TAGS) ./webapp/backend/cmd/scrutiny/
ifneq ($(OS),Windows_NT) ifneq ($(OS),Windows_NT)
chmod +x $(WEB_BINARY_NAME) chmod +x $(WEB_BINARY_NAME)
file $(WEB_BINARY_NAME) || true file $(WEB_BINARY_NAME) || true