start refactoring the Makefile to build artifacts in parallel (eventually using Zig for cross compilation).
parent
b4adf3d88d
commit
b0bff53bbd
@ -1,85 +0,0 @@
|
|||||||
name: CI
|
|
||||||
# This workflow is triggered on pushes & pull requests
|
|
||||||
on: [pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: techknowlogick/xgo:go-1.17.x
|
|
||||||
|
|
||||||
# Service containers to run with `build` (Required for end-to-end testing)
|
|
||||||
services:
|
|
||||||
influxdb:
|
|
||||||
image: influxdb:2.2
|
|
||||||
env:
|
|
||||||
DOCKER_INFLUXDB_INIT_MODE: setup
|
|
||||||
DOCKER_INFLUXDB_INIT_USERNAME: admin
|
|
||||||
DOCKER_INFLUXDB_INIT_PASSWORD: password12345
|
|
||||||
DOCKER_INFLUXDB_INIT_ORG: scrutiny
|
|
||||||
DOCKER_INFLUXDB_INIT_BUCKET: metrics
|
|
||||||
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: my-super-secret-auth-token
|
|
||||||
ports:
|
|
||||||
- 8086:8086
|
|
||||||
env:
|
|
||||||
PROJECT_PATH: /go/src/github.com/analogj/scrutiny
|
|
||||||
CGO_ENABLED: 1
|
|
||||||
steps:
|
|
||||||
- name: Git
|
|
||||||
run: |
|
|
||||||
apt-get update && apt-get install -y software-properties-common
|
|
||||||
add-apt-repository ppa:git-core/ppa && apt-get update && apt-get install -y git
|
|
||||||
git --version
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
mkdir -p $(dirname "$PROJECT_PATH")
|
|
||||||
cp -a $GITHUB_WORKSPACE $PROJECT_PATH
|
|
||||||
cd $PROJECT_PATH
|
|
||||||
|
|
||||||
go mod vendor
|
|
||||||
go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" $(go list ./... | grep -v /vendor/)
|
|
||||||
- name: Generate coverage report
|
|
||||||
uses: codecov/codecov-action@v2
|
|
||||||
with:
|
|
||||||
files: ${{ env.PROJECT_PATH }}/coverage.txt
|
|
||||||
flags: unittests
|
|
||||||
fail_ci_if_error: true
|
|
||||||
verbose: true
|
|
||||||
- name: Build Binaries
|
|
||||||
run: |
|
|
||||||
|
|
||||||
cd $PROJECT_PATH
|
|
||||||
make all
|
|
||||||
|
|
||||||
- name: Archive
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: binaries.zip
|
|
||||||
path: |
|
|
||||||
/build/scrutiny-web-linux-amd64
|
|
||||||
/build/scrutiny-collector-metrics-linux-amd64
|
|
||||||
/build/scrutiny-web-linux-arm64
|
|
||||||
/build/scrutiny-collector-metrics-linux-arm64
|
|
||||||
/build/scrutiny-web-linux-arm-5
|
|
||||||
/build/scrutiny-collector-metrics-linux-arm-5
|
|
||||||
/build/scrutiny-web-linux-arm-6
|
|
||||||
/build/scrutiny-collector-metrics-linux-arm-6
|
|
||||||
/build/scrutiny-web-linux-arm-7
|
|
||||||
/build/scrutiny-collector-metrics-linux-arm-7
|
|
||||||
/build/scrutiny-web-windows-4.0-amd64.exe
|
|
||||||
/build/scrutiny-collector-metrics-windows-4.0-amd64.exe
|
|
||||||
# /build/scrutiny-web-darwin-arm64
|
|
||||||
# /build/scrutiny-collector-metrics-darwin-arm64
|
|
||||||
# /build/scrutiny-web-darwin-amd64
|
|
||||||
# /build/scrutiny-collector-metrics-darwin-amd64
|
|
||||||
# /build/scrutiny-web-freebsd-amd64
|
|
||||||
# /build/scrutiny-collector-metrics-freebsd-amd64
|
|
||||||
- uses: codecov/codecov-action@v2
|
|
||||||
with:
|
|
||||||
file: ${{ env.PROJECT_PATH }}/coverage.txt
|
|
||||||
flags: unittests
|
|
||||||
fail_ci_if_error: false
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
name: CI
|
||||||
|
# This workflow is triggered on pushes & pull requests
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ghcr.io/packagrio/packagr:latest-golang
|
||||||
|
|
||||||
|
# Service containers to run with `build` (Required for end-to-end testing)
|
||||||
|
services:
|
||||||
|
influxdb:
|
||||||
|
image: influxdb:2.2
|
||||||
|
env:
|
||||||
|
DOCKER_INFLUXDB_INIT_MODE: setup
|
||||||
|
DOCKER_INFLUXDB_INIT_USERNAME: admin
|
||||||
|
DOCKER_INFLUXDB_INIT_PASSWORD: password12345
|
||||||
|
DOCKER_INFLUXDB_INIT_ORG: scrutiny
|
||||||
|
DOCKER_INFLUXDB_INIT_BUCKET: metrics
|
||||||
|
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: my-super-secret-auth-token
|
||||||
|
ports:
|
||||||
|
- 8086:8086
|
||||||
|
env:
|
||||||
|
PROJECT_PATH: /go/src/github.com/analogj/scrutiny
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
steps:
|
||||||
|
- name: Git
|
||||||
|
run: |
|
||||||
|
apt-get update && apt-get install -y software-properties-common
|
||||||
|
add-apt-repository ppa:git-core/ppa && apt-get update && apt-get install -y git
|
||||||
|
git --version
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
make clean binary-test-coverage
|
||||||
|
- name: Generate coverage report
|
||||||
|
uses: codecov/codecov-action@v2
|
||||||
|
with:
|
||||||
|
files: ${{ github.workspace }}/coverage.txt
|
||||||
|
flags: unittests
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
build:
|
||||||
|
name: Build ${{ matrix.cfg.goos }}/${{ matrix.cfg.goarch }}
|
||||||
|
needs: release
|
||||||
|
runs-on: ${{ matrix.cfg.on }}
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.cfg.goos }}
|
||||||
|
GOARCH: ${{ matrix.cfg.goarch }}
|
||||||
|
GOARM: ${{ matrix.cfg.goarm }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
cfg:
|
||||||
|
- { on: ubuntu-latest, goos: linux, goarch: amd64 }
|
||||||
|
- { 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 }
|
||||||
|
- { 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: Build Binaries
|
||||||
|
run: |
|
||||||
|
make clean binary-all
|
||||||
|
|
||||||
|
- name: Archive
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: binaries.zip
|
||||||
|
path: |
|
||||||
|
scrutiny-web-*
|
||||||
|
scrutiny-collector-metrics-*
|
@ -1,66 +1,107 @@
|
|||||||
export CGO_ENABLED = 1
|
.ONESHELL: # Applies to every targets in the file! .ONESHELL instructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains.
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
# Global Env Settings
|
||||||
|
########################################################################################################################
|
||||||
|
export CGO_ENABLED = 1
|
||||||
GO_WORKSPACE ?= /go/src/github.com/analogj/scrutiny
|
GO_WORKSPACE ?= /go/src/github.com/analogj/scrutiny
|
||||||
|
|
||||||
BINARY=\
|
COLLECTOR_BINARY_NAME = scrutiny-collector-metrics
|
||||||
linux/amd64 \
|
WEB_BINARY_NAME = scrutiny-web
|
||||||
linux/arm-5 \
|
LD_FLAGS =
|
||||||
linux/arm-6 \
|
ifdef STATIC
|
||||||
linux/arm-7 \
|
LD_FLAGS := $(LD_FLAGS) -extldflags=-static
|
||||||
linux/arm64 \
|
endif
|
||||||
|
ifdef GOOS
|
||||||
|
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOOS)
|
||||||
|
WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOOS)
|
||||||
|
LD_FLAGS := $(LD_FLAGS) -X main.goos=$(GOOS)
|
||||||
|
endif
|
||||||
|
ifdef GOARCH
|
||||||
|
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOARCH)
|
||||||
|
WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOARCH)
|
||||||
|
LD_FLAGS := $(LD_FLAGS) -X main.goarch=$(GOARCH)
|
||||||
|
endif
|
||||||
|
ifdef GOARM
|
||||||
|
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME)-$(GOARM)
|
||||||
|
WEB_BINARY_NAME := $(WEB_BINARY_NAME)-$(GOARM)
|
||||||
|
endif
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
COLLECTOR_BINARY_NAME := $(COLLECTOR_BINARY_NAME).exe
|
||||||
|
WEB_BINARY_NAME := $(WEB_BINARY_NAME).exe
|
||||||
|
endif
|
||||||
|
|
||||||
.ONESHELL: # Applies to every targets in the file! .ONESHELL instructs make to invoke a single instance of the shell and provide it with the entire recipe, regardless of how many lines it contains.
|
########################################################################################################################
|
||||||
.PHONY: all $(BINARY)
|
# Binary
|
||||||
all: $(BINARY) windows/amd64
|
########################################################################################################################
|
||||||
|
.PHONY: all
|
||||||
|
all: binary-all
|
||||||
|
|
||||||
|
.PHONY: binary-all
|
||||||
|
binary-all: binary-web binary-collector binary-frontend
|
||||||
|
|
||||||
$(BINARY): OS = $(word 1,$(subst /, ,$*))
|
.PHONY: binary-clean
|
||||||
$(BINARY): ARCH = $(word 2,$(subst /, ,$*))
|
binary-clean:
|
||||||
$(BINARY): build/scrutiny-web-%:
|
go clean
|
||||||
@echo "building web binary (OS = $(OS), ARCH = $(ARCH))"
|
|
||||||
xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-web -tags "static netgo sqlite_omit_load_extension" ${GO_WORKSPACE}/webapp/backend/cmd/scrutiny/
|
|
||||||
|
|
||||||
chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)"
|
.PHONY: binary-dep
|
||||||
file "/build/scrutiny-web-$(OS)-$(ARCH)" || true
|
binary-dep:
|
||||||
ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true
|
go mod vendor
|
||||||
|
|
||||||
@echo "building collector binary (OS = $(OS), ARCH = $(ARCH))"
|
.PHONY: binary-test
|
||||||
xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-collector-metrics -tags "static netgo" ${GO_WORKSPACE}/collector/cmd/collector-metrics/
|
binary-test: binary-dep
|
||||||
|
go test -v -tags "static" ./...
|
||||||
|
|
||||||
chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)"
|
.PHONY: binary-test-coverage
|
||||||
file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true
|
binary-test-coverage: binary-dep
|
||||||
ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true
|
go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" ./...
|
||||||
|
|
||||||
windows/amd64: export OS = windows
|
.PHONY: binary-collector
|
||||||
windows/amd64: export ARCH = amd64
|
binary-collector: binary-dep
|
||||||
windows/amd64:
|
go build -ldflags "$(LD_FLAGS)" -o $(COLLECTOR_BINARY_NAME) -tags "static netgo" ./collector/cmd/collector-metrics/
|
||||||
@echo "building web binary (OS = $(OS), ARCH = $(ARCH))"
|
ifneq ($(OS),Windows_NT)
|
||||||
xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-web -tags "static netgo sqlite_omit_load_extension" ${GO_WORKSPACE}/webapp/backend/cmd/scrutiny/
|
chmod +x $(COLLECTOR_BINARY_NAME)
|
||||||
|
file $(COLLECTOR_BINARY_NAME) || true
|
||||||
|
ldd $(COLLECTOR_BINARY_NAME) || true
|
||||||
|
./$(COLLECTOR_BINARY_NAME) || true
|
||||||
|
endif
|
||||||
|
|
||||||
@echo "building collector binary (OS = $(OS), ARCH = $(ARCH))"
|
.PHONY: binary-web
|
||||||
xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-collector-metrics -tags "static netgo" ${GO_WORKSPACE}/collector/cmd/collector-metrics/
|
binary-web: binary-dep
|
||||||
|
go build -ldflags "$(LD_FLAGS)" -o $(WEB_BINARY_NAME) -tags "static netgo sqlite_omit_load_extension" ./webapp/backend/cmd/scrutiny/
|
||||||
|
ifneq ($(OS),Windows_NT)
|
||||||
|
chmod +x $(WEB_BINARY_NAME)
|
||||||
|
file $(WEB_BINARY_NAME) || true
|
||||||
|
ldd $(WEB_BINARY_NAME) || true
|
||||||
|
./$(WEB_BINARY_NAME) || true
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: binary-frontend
|
||||||
|
# reduce logging, disable angular-cli analytics for ci environment
|
||||||
|
binary-frontend: export NPM_CONFIG_LOGLEVEL = warn
|
||||||
|
binary-frontend: export NG_CLI_ANALYTICS = false
|
||||||
|
binary-frontend:
|
||||||
|
cd webapp/frontend
|
||||||
|
npm install -g @angular/cli@9.1.4
|
||||||
|
mkdir -p $(CURDIR)/dist
|
||||||
|
npm ci
|
||||||
|
npm run build:prod -- --output-path=$(CURDIR)/dist
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
TARGETARCH ?= amd64
|
||||||
|
|
||||||
|
.PHONY: docker-web
|
||||||
docker-collector:
|
docker-collector:
|
||||||
@echo "building collector docker image"
|
@echo "building collector docker image"
|
||||||
docker build --build-arg TARGETARCH=amd64 -f docker/Dockerfile.collector -t analogj/scrutiny-dev:collector .
|
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile.collector -t analogj/scrutiny-dev:collector .
|
||||||
|
|
||||||
|
.PHONY: docker-web
|
||||||
docker-web:
|
docker-web:
|
||||||
@echo "building web docker image"
|
@echo "building web docker image"
|
||||||
docker build --build-arg TARGETARCH=amd64 -f docker/Dockerfile.web -t analogj/scrutiny-dev:web .
|
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile.web -t analogj/scrutiny-dev:web .
|
||||||
|
|
||||||
|
.PHONY: docker-omnibus
|
||||||
docker-omnibus:
|
docker-omnibus:
|
||||||
@echo "building omnibus docker image"
|
@echo "building omnibus docker image"
|
||||||
docker build --build-arg TARGETARCH=amd64 -f docker/Dockerfile -t analogj/scrutiny-dev:omnibus .
|
docker build --build-arg TARGETARCH=$(TARGETARCH) -f docker/Dockerfile -t analogj/scrutiny-dev:omnibus .
|
||||||
|
|
||||||
# reduce logging, disable angular-cli analytics for ci environment
|
|
||||||
frontend: export NPM_CONFIG_LOGLEVEL = warn
|
|
||||||
frontend: export NG_CLI_ANALYTICS = false
|
|
||||||
frontend:
|
|
||||||
cd webapp/frontend
|
|
||||||
npm install -g @angular/cli@9.1.4
|
|
||||||
mkdir -p $(CURDIR)/dist
|
|
||||||
npm ci
|
|
||||||
npm run build:prod -- --output-path=$(CURDIR)/dist
|
|
||||||
|
|
||||||
# clean:
|
|
||||||
# rm scrutiny-collector-metrics-* scrutiny-web-*
|
|
||||||
|
Loading…
Reference in new issue