Cleanup references to make
This commit is contained in:
parent
d359130bcf
commit
8da7db3e26
6 changed files with 17 additions and 264 deletions
|
@ -6,6 +6,6 @@
|
||||||
|
|
||||||
* [ ] I added or improved tests
|
* [ ] I added or improved tests
|
||||||
* [ ] I added or improved docs for my feature
|
* [ ] I added or improved docs for my feature
|
||||||
* [ ] Swagger (including `make do-the-swag`)
|
* [ ] Swagger (including `mage do-the-swag`)
|
||||||
* [ ] Error codes
|
* [ ] Error codes
|
||||||
* [ ] New config options
|
* [ ] New config options
|
247
Makefile
247
Makefile
|
@ -1,247 +0,0 @@
|
||||||
DIST := dist
|
|
||||||
IMPORT := code.vikunja.io/api
|
|
||||||
|
|
||||||
SED_INPLACE := sed -i
|
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
|
||||||
EXECUTABLE := vikunja.exe
|
|
||||||
else
|
|
||||||
EXECUTABLE := vikunja
|
|
||||||
UNAME_S := $(shell uname -s)
|
|
||||||
ifeq ($(UNAME_S),Darwin)
|
|
||||||
SED_INPLACE := sed -i ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
GOFILES := $(shell find . -name "*.go" -type f ! -path "*/bindata.go")
|
|
||||||
GOFMT ?= gofmt -s
|
|
||||||
|
|
||||||
EXTRA_GOFLAGS ?=
|
|
||||||
GOFLAGS := -v $(EXTRA_GOFLAGS)
|
|
||||||
|
|
||||||
LDFLAGS := -X "code.vikunja.io/api/pkg/version.Version=$(shell git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')" -X "main.Tags=$(TAGS)"
|
|
||||||
|
|
||||||
PACKAGES ?= $(filter-out code.vikunja.io/api/pkg/integrations,$(shell go list all | grep code\.vikunja\.io\/api))
|
|
||||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
|
||||||
|
|
||||||
TAGS ?=
|
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
|
||||||
EXECUTABLE := vikunja.exe
|
|
||||||
else
|
|
||||||
EXECUTABLE := vikunja
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(DRONE_TAG),)
|
|
||||||
VERSION ?= $(subst v,,$(DRONE_TAG))
|
|
||||||
else
|
|
||||||
ifneq ($(DRONE_BRANCH),)
|
|
||||||
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
|
|
||||||
else
|
|
||||||
VERSION ?= master
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(DRONE_WORKSPACE),'')
|
|
||||||
BINLOCATION := $(EXECUTABLE)
|
|
||||||
else
|
|
||||||
BINLOCATION := $(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-linux-amd64
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(VERSION),master)
|
|
||||||
PKGVERSION := $(shell git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')
|
|
||||||
else
|
|
||||||
PKGVERSION := $(VERSION)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: build
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
go clean ./...
|
|
||||||
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test:
|
|
||||||
# We run everything sequentially and not in parallel to prevent issues with real test databases
|
|
||||||
VIKUNJA_SERVICE_ROOTPATH=$(shell pwd) go test $(GOFLAGS) -p 1 -cover -coverprofile cover.out $(PACKAGES)
|
|
||||||
|
|
||||||
.PHONY: test-coverage
|
|
||||||
test-coverage: test
|
|
||||||
go tool cover -html=cover.out -o cover.html
|
|
||||||
|
|
||||||
.PHONY: integration-test
|
|
||||||
integration-test:
|
|
||||||
# We run everything sequentially and not in parallel to prevent issues with real test databases
|
|
||||||
VIKUNJA_SERVICE_ROOTPATH=$(shell pwd) go test $(GOFLAGS) -p 1 code.vikunja.io/api/pkg/integrations
|
|
||||||
|
|
||||||
.PHONY: lint
|
|
||||||
lint:
|
|
||||||
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) golang.org/x/lint/golint; \
|
|
||||||
fi
|
|
||||||
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
|
|
||||||
|
|
||||||
.PHONY: fmt
|
|
||||||
fmt:
|
|
||||||
$(GOFMT) -w $(GOFILES)
|
|
||||||
|
|
||||||
.PHONY: fmt-check
|
|
||||||
fmt-check:
|
|
||||||
# get all go files and run go fmt on them
|
|
||||||
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
|
||||||
if [ -n "$$diff" ]; then \
|
|
||||||
echo "Please run 'make fmt' and commit the result:"; \
|
|
||||||
echo "$${diff}"; \
|
|
||||||
exit 1; \
|
|
||||||
fi;
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build: generate $(EXECUTABLE)
|
|
||||||
|
|
||||||
.PHONY: generate
|
|
||||||
generate:
|
|
||||||
go generate code.vikunja.io/api/pkg/static
|
|
||||||
|
|
||||||
$(EXECUTABLE): $(SOURCES)
|
|
||||||
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
|
|
||||||
|
|
||||||
.PHONY: compress-build
|
|
||||||
compress-build:
|
|
||||||
upx -9 $(EXECUTABLE)
|
|
||||||
|
|
||||||
.PHONY: release
|
|
||||||
release: release-dirs release-windows release-linux release-darwin release-copy release-check release-os-package release-zip
|
|
||||||
|
|
||||||
.PHONY: release-dirs
|
|
||||||
release-dirs:
|
|
||||||
mkdir -p $(DIST)/binaries $(DIST)/release $(DIST)/zip
|
|
||||||
|
|
||||||
.PHONY: release-windows
|
|
||||||
release-windows:
|
|
||||||
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
|
|
||||||
fi
|
|
||||||
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out vikunja-$(VERSION) .
|
|
||||||
ifneq ($(DRONE_WORKSPACE),'')
|
|
||||||
mv /build/* $(DIST)/binaries
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: release-linux
|
|
||||||
release-linux:
|
|
||||||
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
|
|
||||||
fi
|
|
||||||
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out vikunja-$(VERSION) .
|
|
||||||
ifneq ($(DRONE_WORKSPACE),'')
|
|
||||||
mv /build/* $(DIST)/binaries
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: release-darwin
|
|
||||||
release-darwin:
|
|
||||||
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) src.techknowlogick.com/xgo; \
|
|
||||||
fi
|
|
||||||
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out vikunja-$(VERSION) .
|
|
||||||
ifneq ($(DRONE_WORKSPACE),'')
|
|
||||||
mv /build/* $(DIST)/binaries
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Compresses all releases made by make release-* but not mips* releases since upx can't handle these.
|
|
||||||
.PHONY: release-compress
|
|
||||||
release-compress:
|
|
||||||
$(foreach file,$(filter-out $(wildcard $(wildcard $(DIST)/binaries/$(EXECUTABLE)-*mips*)),$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*)), upx -9 $(file);)
|
|
||||||
|
|
||||||
.PHONY: release-copy
|
|
||||||
release-copy:
|
|
||||||
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
|
||||||
|
|
||||||
.PHONY: release-check
|
|
||||||
release-check:
|
|
||||||
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
|
||||||
|
|
||||||
.PHONY: release-os-package
|
|
||||||
release-os-package:
|
|
||||||
$(foreach file,$(filter-out %.sha256,$(wildcard $(DIST)/release/$(EXECUTABLE)-*)),mkdir $(file)-full;mv $(file) $(file)-full/; mv $(file).sha256 $(file)-full/; cp config.yml.sample $(file)-full/config.yml; cp LICENSE $(file)-full/; )
|
|
||||||
|
|
||||||
.PHONY: release-zip
|
|
||||||
release-zip:
|
|
||||||
$(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),cd $(file); zip -r ../../zip/$(shell basename $(file)).zip *; cd ../../../; )
|
|
||||||
|
|
||||||
# Builds a deb package using fpm from a previously created binary (using make build)
|
|
||||||
.PHONY: build-deb
|
|
||||||
build-deb:
|
|
||||||
fpm -s dir -t deb --url https://vikunja.io -n vikunja -v $(PKGVERSION) --license GPLv3 --directories /opt/vikunja --after-install ./build/after-install.sh --description 'Vikunja is an open-source todo application, written in Go. It lets you create lists,tasks and share them via teams or directly between users.' -m maintainers@vikunja.io ./$(BINLOCATION)=/opt/vikunja/vikunja ./config.yml.sample=/etc/vikunja/config.yml;
|
|
||||||
|
|
||||||
.PHONY: reprepro
|
|
||||||
reprepro:
|
|
||||||
reprepro_expect debian includedeb strech ./$(EXECUTABLE)_$(PKGVERSION)_amd64.deb
|
|
||||||
|
|
||||||
.PHONY: got-swag
|
|
||||||
got-swag: do-the-swag
|
|
||||||
@diff=$$(git diff docs/swagger/swagger.json); \
|
|
||||||
if [ -n "$$diff" ]; then \
|
|
||||||
echo "Please run 'make do-the-swag' and commit the result:"; \
|
|
||||||
echo "$${diff}"; \
|
|
||||||
exit 1; \
|
|
||||||
fi;
|
|
||||||
|
|
||||||
.PHONY: do-the-swag
|
|
||||||
do-the-swag:
|
|
||||||
@hash swag > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) github.com/swaggo/swag/cmd/swag; \
|
|
||||||
fi
|
|
||||||
swag init -g pkg/routes/routes.go --parseDependency -o ./pkg/swagger;
|
|
||||||
# Fix the generated swagger file, currently a workaround until swaggo can properly use go mod
|
|
||||||
sed -i '/"definitions": {/a "code.vikunja.io.web.HTTPError": {"type": "object","properties": {"code": {"type": "integer"},"message": {"type": "string"}}},' pkg/swagger/docs.go;
|
|
||||||
sed -i 's/code.vikunja.io\/web.HTTPError/code.vikunja.io.web.HTTPError/g' pkg/swagger/docs.go;
|
|
||||||
sed -i 's/package\ docs/package\ swagger/g' pkg/swagger/docs.go;
|
|
||||||
sed -i 's/` + \\"`\\" + `/` + "`" + `/g' pkg/swagger/docs.go;
|
|
||||||
|
|
||||||
.PHONY: misspell-check
|
|
||||||
misspell-check:
|
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
for S in $(GOFILES); do misspell -error $$S || exit 1; done;
|
|
||||||
|
|
||||||
.PHONY: ineffassign-check
|
|
||||||
ineffassign-check:
|
|
||||||
@hash ineffassign > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go install $(GOFLAGS) github.com/gordonklaus/ineffassign; \
|
|
||||||
fi
|
|
||||||
for S in $(GOFILES); do ineffassign $$S || exit 1; done;
|
|
||||||
|
|
||||||
.PHONY: gocyclo-check
|
|
||||||
gocyclo-check:
|
|
||||||
@hash gocyclo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go get -u github.com/fzipp/gocyclo; \
|
|
||||||
go install $(GOFLAGS) github.com/fzipp/gocyclo; \
|
|
||||||
fi
|
|
||||||
for S in $(GOFILES); do gocyclo -over 49 $$S || exit 1; done;
|
|
||||||
|
|
||||||
.PHONY: static-check
|
|
||||||
static-check:
|
|
||||||
@hash staticcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go get -u honnef.co/go/tools; \
|
|
||||||
go install $(GOFLAGS) honnef.co/go/tools/cmd/staticcheck; \
|
|
||||||
fi
|
|
||||||
staticcheck $(PACKAGES);
|
|
||||||
|
|
||||||
.PHONY: gosec-check
|
|
||||||
gosec-check:
|
|
||||||
@hash gosec > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
echo "Please manually install gosec by running"; \
|
|
||||||
echo "curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | bash -s -- -b $GOPATH/bin v2.2.0"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
gosec ./...
|
|
||||||
|
|
||||||
.PHONY: goconst-check
|
|
||||||
goconst-check:
|
|
||||||
@hash goconst > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
go get -u github.com/jgautheron/goconst/cmd/goconst; \
|
|
||||||
go install $(GOFLAGS) github.com/jgautheron/goconst/cmd/goconst; \
|
|
||||||
fi;
|
|
||||||
for S in $(PACKAGES); do goconst $$S || exit 1; done;
|
|
|
@ -51,7 +51,7 @@ git fetch --all --prune
|
||||||
{{< /highlight >}}
|
{{< /highlight >}}
|
||||||
|
|
||||||
This should provide a working development environment for Vikunja. Take a look at the Makefile to get an overview about
|
This should provide a working development environment for Vikunja. Take a look at the Makefile to get an overview about
|
||||||
the available tasks. The most common tasks should be `make test` which will start our test environment and `make build`
|
the available tasks. The most common tasks should be `mage test:unit` which will start our test environment and `mage build:build`
|
||||||
which will build a vikunja binary into the working directory. Writing test cases is not mandatory to contribute, but it
|
which will build a vikunja binary into the working directory. Writing test cases is not mandatory to contribute, but it
|
||||||
is highly encouraged and helps developers sleep at night.
|
is highly encouraged and helps developers sleep at night.
|
||||||
|
|
||||||
|
@ -62,4 +62,4 @@ That’s it! You are ready to hack on Vikunja. Test changes, push them to the re
|
||||||
Each Vikunja release contains all static assets directly compiled into the binary.
|
Each Vikunja release contains all static assets directly compiled into the binary.
|
||||||
To prevent this during development, use the `dev` tag when developing.
|
To prevent this during development, use the `dev` tag when developing.
|
||||||
|
|
||||||
See the [make docs](make.md#statically-compile-all-templates-into-the-binary) about how to compile with static assets for a release.
|
See the [mage docs](mage.md#statically-compile-all-templates-into-the-binary) about how to compile with static assets for a release.
|
||||||
|
|
|
@ -47,7 +47,7 @@ This document will explain what these mean and what you can find where.
|
||||||
|
|
||||||
## Root level
|
## Root level
|
||||||
|
|
||||||
The root directory is where [the config file]({{< ref "../setup/config.md">}}), [Makefile]({{< ref "make.md">}}), license, drone config,
|
The root directory is where [the config file]({{< ref "../setup/config.md">}}), [Magefile]({{< ref "mage.md">}}), license, drone config,
|
||||||
application entry point (`main.go`) and so on are located.
|
application entry point (`main.go`) and so on are located.
|
||||||
|
|
||||||
## docker
|
## docker
|
||||||
|
@ -152,11 +152,11 @@ Every handler function which does not use the standard web handler should live h
|
||||||
|
|
||||||
### static
|
### static
|
||||||
|
|
||||||
All static files generated by `make generate` live here.
|
All static files generated by `mage generate` live here.
|
||||||
|
|
||||||
### swagger
|
### swagger
|
||||||
|
|
||||||
This is where the [generated]({{< ref "make.md#generate-swagger-definitions-from-code-comments">}} [api docs]({{< ref "../usage/api.md">}}) live.
|
This is where the [generated]({{< ref "mage.md#generate-swagger-definitions-from-code-comments">}} [api docs]({{< ref "../usage/api.md">}}) live.
|
||||||
You usually don't need to touch this package.
|
You usually don't need to touch this package.
|
||||||
|
|
||||||
### user
|
### user
|
||||||
|
@ -175,7 +175,7 @@ See their function definitions for instructions on how to use them.
|
||||||
### version
|
### version
|
||||||
|
|
||||||
The single purpouse of this package is to hold the current vikunja version which gets overridden through build flags
|
The single purpouse of this package is to hold the current vikunja version which gets overridden through build flags
|
||||||
each time `make release` or `make build` is run.
|
each time `mage release` or `mage build` is run.
|
||||||
It is a seperate package to avoid import cycles with other packages.
|
It is a seperate package to avoid import cycles with other packages.
|
||||||
|
|
||||||
## REST-Tests
|
## REST-Tests
|
||||||
|
|
|
@ -10,10 +10,10 @@ menu:
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
|
|
||||||
You can run unit tests with [our `Makefile`]({{< ref "make.md">}}) with
|
You can run unit tests with [our `Magefile`]({{< ref "mage.md">}}) with
|
||||||
|
|
||||||
{{< highlight bash >}}
|
{{< highlight bash >}}
|
||||||
make test
|
mage test:unit
|
||||||
{{< /highlight >}}
|
{{< /highlight >}}
|
||||||
|
|
||||||
### Running tests with config
|
### Running tests with config
|
||||||
|
@ -36,12 +36,12 @@ When you add a new test case which requires new database entries to test against
|
||||||
# Integration tests
|
# Integration tests
|
||||||
|
|
||||||
All integration tests live in `pkg/integrations`.
|
All integration tests live in `pkg/integrations`.
|
||||||
You can run them by executing `make integration-test`.
|
You can run them by executing `mage test:integration`.
|
||||||
|
|
||||||
The integration tests use the same config and fixtures as the unit tests and therefor have the same options available,
|
The integration tests use the same config and fixtures as the unit tests and therefor have the same options available,
|
||||||
see at the beginning of this document.
|
see at the beginning of this document.
|
||||||
|
|
||||||
To run integration tests, use `make integration-test`.
|
To run integration tests, use `mage test:integration`.
|
||||||
|
|
||||||
# Initializing db fixtures when writing tests
|
# Initializing db fixtures when writing tests
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,16 @@ Vikunja being a go application, has no other dependencies than go itself.
|
||||||
All libraries are bundeled inside the repo in the `vendor/` folder, so all it boils down to are these steps:
|
All libraries are bundeled inside the repo in the `vendor/` folder, so all it boils down to are these steps:
|
||||||
|
|
||||||
1. Make sure [Go](https://golang.org/doc/install) is properly installed on your system. You'll need at least Go `1.9`.
|
1. Make sure [Go](https://golang.org/doc/install) is properly installed on your system. You'll need at least Go `1.9`.
|
||||||
2. Make sure [Make](https://www.gnu.org/software/make/) is properly installed on your system.
|
2. Make sure [Mage](https://magefile) is properly installed on your system.
|
||||||
3. Clone the repo with `git clone https://code.vikunja.io/api`
|
3. Clone the repo with `git clone https://code.vikunja.io/api`
|
||||||
3. Run `make build` in the source of this repo. This will build a binary in the root of the repo which will be able to run on your system.
|
3. Run `mage build:build` in the source of this repo. This will build a binary in the root of the repo which will be able to run on your system.
|
||||||
|
|
||||||
*Note:* Static ressources such as email templates are built into the binary.
|
*Note:* Static ressources such as email templates are built into the binary.
|
||||||
For these to work, you may need to run `make generate` before building the vikunja binary.
|
For these to work, you may need to run `mage build:generate` before building the vikunja binary.
|
||||||
When builing entirely with `make`, you dont need to do this, `make generate` will be run automatically when running `make build`.
|
When builing entirely with `mage`, you dont need to do this, `mage build:generate` will be run automatically when running `mage build:build`.
|
||||||
|
|
||||||
# Build for different architectures
|
# Build for different architectures
|
||||||
|
|
||||||
To build for other platforms and architectures than the one you're currently on, simply run `make release` or `make release-{linux|windows|darwin}`.
|
To build for other platforms and architectures than the one you're currently on, simply run `mage release:release` or `mage release:{linux|windows|darwin}`.
|
||||||
|
|
||||||
More options are available, please refer to the [makefile docs]({{< ref "../development/make.md">}}) for more details.
|
More options are available, please refer to the [magefile docs]({{< ref "../development/mage.md">}}) for more details.
|
Loading…
Reference in a new issue