mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 08:10:45 +00:00
Add a pre-push git-hook to run tests on obitools commands before pushing on master
This commit is contained in:
33
Makefile
33
Makefile
@ -16,6 +16,12 @@ PACKAGES_SRC:= $(wildcard pkg/*/*.go pkg/*/*/*.go)
|
||||
PACKAGE_DIRS:=$(sort $(patsubst %/,%,$(dir $(PACKAGES_SRC))))
|
||||
PACKAGES:=$(notdir $(PACKAGE_DIRS))
|
||||
|
||||
GITHOOK_SRC_DIR=git-hooks
|
||||
GITHOOKS_SRC:=$(wildcard $(GITHOOK_SRC_DIR)/*)
|
||||
|
||||
GITHOOK_DIR=.git/hooks
|
||||
GITHOOKS:=$(patsubst $(GITHOOK_SRC_DIR)/%,$(GITHOOK_DIR)/%,$(GITHOOKS_SRC))
|
||||
|
||||
OBITOOLS_SRC:= $(wildcard cmd/obitools/*/*.go)
|
||||
OBITOOLS_DIRS:=$(sort $(patsubst %/,%,$(dir $(OBITOOLS_SRC))))
|
||||
OBITOOLS:=$(notdir $(OBITOOLS_DIRS))
|
||||
@ -53,15 +59,23 @@ endif
|
||||
|
||||
OUTPUT:=$(shell mktemp)
|
||||
|
||||
all: obitools
|
||||
all: install-githook obitools
|
||||
|
||||
packages: $(patsubst %,pkg-%,$(PACKAGES))
|
||||
obitools: $(patsubst %,$(OBITOOLS_PREFIX)%,$(OBITOOLS))
|
||||
|
||||
install-githook: $(GITHOOKS)
|
||||
|
||||
$(GITHOOK_DIR)/%: $(GITHOOK_SRC_DIR)/%
|
||||
@echo installing $$(basename $@)...
|
||||
@mkdir -p $(GITHOOK_DIR)
|
||||
@cp $< $@
|
||||
@chmod +x $@
|
||||
|
||||
|
||||
update-deps:
|
||||
go get -u ./...
|
||||
|
||||
test:
|
||||
test: .FORCE
|
||||
$(GOTEST) ./...
|
||||
|
||||
obitests:
|
||||
@ -70,17 +84,6 @@ obitests:
|
||||
done
|
||||
|
||||
githubtests: obitools obitests
|
||||
|
||||
man:
|
||||
make -C doc man
|
||||
obibook:
|
||||
make -C doc obibook
|
||||
doc: man obibook
|
||||
|
||||
macos-pkg:
|
||||
@bash pkgs/macos/macos-installer-builder-master/macOS-x64/build-macos-x64.sh \
|
||||
OBITools \
|
||||
0.0.1
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $@
|
||||
@ -104,5 +107,5 @@ ifneq ($(strip $(COMMIT_ID)),)
|
||||
@rm -f $(OUTPUT)
|
||||
endif
|
||||
|
||||
.PHONY: all packages obitools man obibook doc update-deps obitests githubtests .FORCE
|
||||
.PHONY: all obitools update-deps obitests githubtests .FORCE
|
||||
.FORCE:
|
23
git-hooks/pre-push
Executable file
23
git-hooks/pre-push
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
remote="$1"
|
||||
#url="$2"
|
||||
|
||||
log() {
|
||||
echo -e "[Pre-Push tests @ $(date)] $*" 1>&2
|
||||
}
|
||||
|
||||
current_branch=$(git symbolic-ref --short head)
|
||||
|
||||
cmd="make githubtests"
|
||||
|
||||
if [[ $current_branch = "master" ]]; then
|
||||
log "you are on $current_branch, running build test"
|
||||
if ! eval "$cmd"; then
|
||||
log "Pre-push tests failed $cmd"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Tests are OK, ready to push on $remote"
|
||||
exit 0
|
@ -8,7 +8,7 @@ import (
|
||||
// corresponds to the last commit, and not the one when the file will be
|
||||
// commited
|
||||
|
||||
var _Commit = "65bd29b"
|
||||
var _Commit = "52d5f6f"
|
||||
var _Version = "Release 4.4.0"
|
||||
|
||||
// Version returns the version of the obitools package.
|
||||
|
Reference in New Issue
Block a user