1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Add multiarch support agent (#622)

- Makefile
  - Delete _with-docker
  - Fix version creation
  - Add default values for  TARGETOS & TARGETARCH
- Add multiarch Dockerfile for agent
- pipeline config
  - target more platforms for agent docker builds (windows & darwin)

close #181, close #187
This commit is contained in:
6543
2021-12-21 02:35:48 +01:00
committed by GitHub
parent d0da1a104e
commit 9c7691094a
6 changed files with 77 additions and 51 deletions
+13 -14
View File
@@ -1,7 +1,9 @@
DOCKER_RUN_GO_VERSION=1.16
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
TARGETOS ?= linux
TARGETARCH ?= amd64
VERSION ?= next
ifneq ($(CI_COMMIT_TAG),)
VERSION := $(CI_COMMIT_TAG:v%=%)
@@ -10,15 +12,12 @@ endif
# append commit-sha to next version
BUILD_VERSION := $(VERSION)
ifeq ($(BUILD_VERSION),next)
CI_COMMIT_SHA ?= $(shell git rev-parse HEAD)
BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)")
endif
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
DOCKER_RUN?=
_with-docker:
$(eval DOCKER_RUN=docker run --rm -v $(shell pwd):/go/src/ -v $(shell pwd)/build:/build -w /go/src golang:$(DOCKER_RUN_GO_VERSION))
all: build
vendor:
@@ -51,16 +50,16 @@ lint-frontend:
(cd web/; yarn lint --quiet)
test-agent:
$(DOCKER_RUN) go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/agent github.com/woodpecker-ci/woodpecker/agent/...
go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/agent github.com/woodpecker-ci/woodpecker/agent/...
test-server:
$(DOCKER_RUN) go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/server $(shell go list github.com/woodpecker-ci/woodpecker/server/... | grep -v '/store')
go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/server $(shell go list github.com/woodpecker-ci/woodpecker/server/... | grep -v '/store')
test-cli:
$(DOCKER_RUN) go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/cli github.com/woodpecker-ci/woodpecker/cli/...
go test -race -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/cli github.com/woodpecker-ci/woodpecker/cli/...
test-server-datastore:
$(DOCKER_RUN) go test -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/server/store/...
go test -cover -coverprofile coverage.out -timeout 30s github.com/woodpecker-ci/woodpecker/server/store/...
test-frontend: frontend-dependencies
(cd web/; yarn run lint)
@@ -69,7 +68,7 @@ test-frontend: frontend-dependencies
(cd web/; yarn run test)
test-lib:
$(DOCKER_RUN) go test -race -cover -coverprofile coverage.out -timeout 30s $(shell go list ./... | grep -v '/cmd\|/agent\|/cli\|/server')
go test -race -cover -coverprofile coverage.out -timeout 30s $(shell go list ./... | grep -v '/cmd\|/agent\|/cli\|/server')
test: test-agent test-server test-server-datastore test-cli test-lib test-frontend
@@ -77,13 +76,13 @@ build-frontend:
(cd web/; yarn install --frozen-lockfile; yarn build)
build-server: build-frontend
$(DOCKER_RUN) go build -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-server github.com/woodpecker-ci/woodpecker/cmd/server
build-agent:
$(DOCKER_RUN) go build -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-agent github.com/woodpecker-ci/woodpecker/cmd/agent
build-cli:
$(DOCKER_RUN) go build -o dist/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
build: build-agent build-server build-cli
@@ -152,4 +151,4 @@ bundle: bundle-agent bundle-server bundle-cli
.PHONY: version
version:
@echo ${VERSION}
@echo ${BUILD_VERSION}