2021-06-22 12:34:35 +02:00
|
|
|
DOCKER_RUN_GO_VERSION=1.16
|
2019-09-14 14:11:40 +02:00
|
|
|
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
|
2021-06-22 12:34:35 +02:00
|
|
|
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2021-06-22 13:12:26 +02:00
|
|
|
VERSION ?= ${DRONE_TAG}
|
|
|
|
ifeq ($(VERSION),)
|
|
|
|
VERSION := $(shell echo ${DRONE_COMMIT_SHA} | head -c 8)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LDFLAGS ?= -extldflags "-static"
|
|
|
|
ifneq ($(VERSION),)
|
|
|
|
LDFLAGS := ${LDFLAGS} -X github.com/woodpecker-ci/woodpecker/version.Version=${VERSION}
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2019-10-06 22:07:31 +02:00
|
|
|
DOCKER_RUN?=
|
|
|
|
_with-docker:
|
2021-06-22 12:34:35 +02:00
|
|
|
$(eval DOCKER_RUN=docker run --rm -v $(shell pwd):/go/src/ -v $(shell pwd)/build:/build -w /go/src golang:$(DOCKER_RUN_GO_VERSION))
|
2019-10-06 22:07:31 +02:00
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
all: deps build
|
|
|
|
|
|
|
|
deps:
|
|
|
|
go get -u golang.org/x/net/context
|
|
|
|
go get -u golang.org/x/net/context/ctxhttp
|
|
|
|
go get -u github.com/golang/protobuf/proto
|
|
|
|
go get -u github.com/golang/protobuf/protoc-gen-go
|
2021-02-19 10:43:03 +02:00
|
|
|
go get -d docker.io/go-docker
|
2021-02-19 10:47:26 +02:00
|
|
|
go get -d github.com/jackspirou/syscerts
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
formatcheck:
|
2021-06-22 12:34:35 +02:00
|
|
|
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
format:
|
|
|
|
@gofmt -w ${GOFILES_NOVENDOR}
|
|
|
|
|
2021-06-22 12:34:35 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
go clean -i ./...
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
.PHONY: vet
|
|
|
|
vet:
|
|
|
|
@echo "Running go vet..."
|
|
|
|
@go vet $(GO_PACKAGES)
|
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
test-agent:
|
2021-06-22 12:34:35 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/drone-agent $(GO_PACKAGES)
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
test-server:
|
2021-05-25 14:08:27 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s github.com/woodpecker-ci/woodpecker/cmd/drone-server
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2019-11-12 15:27:39 +02:00
|
|
|
test-frontend:
|
|
|
|
(cd web/; yarn run test)
|
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
test-lib:
|
2021-05-25 14:08:27 +02:00
|
|
|
go get github.com/woodpecker-ci/woodpecker/cncd/pipeline/pipec
|
|
|
|
go get github.com/woodpecker-ci/woodpecker/remote/mock
|
|
|
|
go get github.com/woodpecker-ci/woodpecker/cli/drone/internal
|
|
|
|
go get -t github.com/woodpecker-ci/woodpecker/cncd/pipeline/pipeline/frontend/yaml
|
2019-10-08 12:09:31 +02:00
|
|
|
$(DOCKER_RUN) go test -race -timeout 30s $(shell go list ./... | grep -v '/cmd/')
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
test: test-lib test-agent test-server
|
|
|
|
|
|
|
|
build-agent:
|
2021-05-25 14:08:27 +02:00
|
|
|
$(DOCKER_RUN) go build -o build/drone-agent github.com/woodpecker-ci/woodpecker/cmd/drone-agent
|
2019-09-14 14:11:40 +02:00
|
|
|
|
|
|
|
build-server:
|
2021-05-25 14:08:27 +02:00
|
|
|
$(DOCKER_RUN) go build -o build/drone-server github.com/woodpecker-ci/woodpecker/cmd/drone-server
|
2019-09-14 14:11:40 +02:00
|
|
|
|
2019-11-12 15:27:39 +02:00
|
|
|
build-frontend:
|
|
|
|
(cd web/; yarn run build)
|
|
|
|
|
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
build: build-agent build-server
|
|
|
|
|
2021-06-22 13:12:26 +02:00
|
|
|
release-agent:
|
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/drone-agent github.com/woodpecker-ci/woodpecker/cmd/drone-agent
|
|
|
|
|
|
|
|
release-server:
|
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '${LDFLAGS}' -o release/drone-server github.com/woodpecker-ci/woodpecker/cmd/drone-server
|
|
|
|
|
|
|
|
release: release-agent release-server
|
|
|
|
|
2019-09-14 14:11:40 +02:00
|
|
|
install:
|
2021-05-25 14:08:27 +02:00
|
|
|
go install github.com/woodpecker-ci/woodpecker/cmd/drone-agent
|
2021-06-22 12:34:35 +02:00
|
|
|
go install github.com/woodpecker-ci/woodpecker/cmd/drone-server
|