From 963211caf2c870ecad8a0e5449e9952edd2e934a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:00:37 +0200 Subject: [PATCH 01/10] Updated makefiles from gsictl --- README.md | 2 +- base.mk | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e025233..2ab487e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ To add them to your project, simply do: git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git git subtree add --prefix=.makefiles/ makefiles master touch Makefile -echo "include .makefiles/makefiles.mk" >> Makefile +echo "include .makefiles/base.mk" >> Makefile ``` Now you can take advantage of the recipes. diff --git a/base.mk b/base.mk index 55b8a34..aaeae57 100644 --- a/base.mk +++ b/base.mk @@ -1,5 +1,8 @@ +NAME ?= $(shell basename $(CURDIR)) VERSION ?= $(shell git describe --tags --dirty 2>/dev/null) +# Get the location of this makefile. +MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) .FORCE: version: .FORCE @@ -20,5 +23,6 @@ config: ## Load config from the environment. You should run it once in every se ci: ## Run a task using gitlab-runner. Only use to debug problems in the CI pipeline gitlab-runner exec shell --builds-dir '.builds' --env CI_PROJECT_NAME=$(NAME) ${action} +include $(MK_DIR)/makefiles.mk .PHONY:: config help ci version .FORCE From 53db670715c4fad5ca7de8bfa071a75982e506ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:11:08 +0200 Subject: [PATCH 02/10] Updated makefiles from gsictl --- base.mk | 1 + docker.mk | 10 +++++++--- git.mk | 11 +++++++---- makefiles.mk | 4 +++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/base.mk b/base.mk index aaeae57..1390d44 100644 --- a/base.mk +++ b/base.mk @@ -24,5 +24,6 @@ ci: ## Run a task using gitlab-runner. Only use to debug problems in the CI pip gitlab-runner exec shell --builds-dir '.builds' --env CI_PROJECT_NAME=$(NAME) ${action} include $(MK_DIR)/makefiles.mk +include $(MK_DIR)/docker.mk .PHONY:: config help ci version .FORCE diff --git a/docker.mk b/docker.mk index aab2a8a..61d9f0a 100644 --- a/docker.mk +++ b/docker.mk @@ -1,6 +1,6 @@ IMAGEWTAG ?= $(IMAGENAME):$(VERSION) -login: ## Log in to the registry. It will only be used in the server, or when running a CI task locally (if CI_BUILD_TOKEN is set). +docker-login: ## Log in to the registry. It will only be used in the server, or when running a CI task locally (if CI_BUILD_TOKEN is set). ifeq ($(CI_BUILD_TOKEN),) @echo "Not logging in to the docker registry" "$(CI_REGISTRY)" else @@ -12,10 +12,14 @@ else @docker login -u $(HUB_USER) -p $(HUB_PASSWORD) endif -clean:: ## Remove docker credentials +login:: docker-login + +clean:: docker-clean ## Remove docker credentials + +docker-clean: ifeq ($(HUB_USER),) else @docker logout endif -.PHONY:: login clean +.PHONY:: docker-login docker-clean login clean diff --git a/git.mk b/git.mk index c4f6493..991b929 100644 --- a/git.mk +++ b/git.mk @@ -1,12 +1,15 @@ -git_commit: +commit: git commit -a -git_tag: +tag: git tag ${VERSION} -git_push: +push:: git push --tags origin master +pull:: + git pull --all + push-github: ## Push the code to github. You need to set up HUB_USER and HUB_PASSWORD $(eval KEY_FILE := $(shell mktemp)) @echo "$$GITHUB_DEPLOY_KEY" > $(KEY_FILE) @@ -16,4 +19,4 @@ push-github: ## Push the code to github. You need to set up HUB_USER and HUB_PAS @GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git push github-deploy $(CI_COMMIT_REF_NAME) rm $(KEY_FILE) -.PHONY:: git_commit git_tag git_push push-github +.PHONY:: commit tag push push-github diff --git a/makefiles.mk b/makefiles.mk index 4bee03b..158c332 100644 --- a/makefiles.mk +++ b/makefiles.mk @@ -1,5 +1,5 @@ makefiles-remote: - git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git || true + @git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git 2>/dev/null || true makefiles-commit: makefiles-remote git add -f .makefiles @@ -11,4 +11,6 @@ makefiles-push: makefiles-pull: makefiles-remote git subtree pull --prefix=.makefiles/ makefiles master --squash +update:: makefiles-pull + .PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull From fc94b454482181bbf2dffc1ddb91a048cd9e2949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:14:29 +0200 Subject: [PATCH 03/10] Updated makefiles from gsictl --- makefiles.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefiles.mk b/makefiles.mk index 158c332..d97127b 100644 --- a/makefiles.mk +++ b/makefiles.mk @@ -11,6 +11,6 @@ makefiles-push: makefiles-pull: makefiles-remote git subtree pull --prefix=.makefiles/ makefiles master --squash -update:: makefiles-pull +pull:: makefiles-pull .PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull From 99d4bc70bcd9dc22b3cdffed552ea8b3c90813dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:32:11 +0200 Subject: [PATCH 04/10] Updated makefiles from gsictl --- docker.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker.mk b/docker.mk index 61d9f0a..16973a7 100644 --- a/docker.mk +++ b/docker.mk @@ -14,9 +14,9 @@ endif login:: docker-login -clean:: docker-clean ## Remove docker credentials +clean:: docker-clean -docker-clean: +docker-clean: ## Remove docker credentials ifeq ($(HUB_USER),) else @docker logout From f9a75f4e215398064f334342f5f586d42f75a4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:32:51 +0200 Subject: [PATCH 05/10] Updated makefiles from gsictl --- docker.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker.mk b/docker.mk index 16973a7..4845c2f 100644 --- a/docker.mk +++ b/docker.mk @@ -12,14 +12,14 @@ else @docker login -u $(HUB_USER) -p $(HUB_PASSWORD) endif -login:: docker-login - -clean:: docker-clean - docker-clean: ## Remove docker credentials ifeq ($(HUB_USER),) else @docker logout endif +login:: docker-login + +clean:: docker-clean + .PHONY:: docker-login docker-clean login clean From 3d23370a5957e074775d94837bdb41e2c568082a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:33:58 +0200 Subject: [PATCH 06/10] Updated makefiles from gsictl --- base.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/base.mk b/base.mk index 1390d44..d0c392b 100644 --- a/base.mk +++ b/base.mk @@ -25,5 +25,6 @@ ci: ## Run a task using gitlab-runner. Only use to debug problems in the CI pip include $(MK_DIR)/makefiles.mk include $(MK_DIR)/docker.mk +include $(MK_DIR)/git.mk .PHONY:: config help ci version .FORCE From 14bcfd511fc42c5734bc3697e72867b72a6d53e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:38:59 +0200 Subject: [PATCH 07/10] Updated makefiles from gsictl --- git.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.mk b/git.mk index 991b929..6a2413f 100644 --- a/git.mk +++ b/git.mk @@ -5,7 +5,7 @@ tag: git tag ${VERSION} push:: - git push --tags origin master + git push -u --tags origin HEAD pull:: git pull --all From a3a9414073ab454ce9d27444e80cd24534037c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:39:26 +0200 Subject: [PATCH 08/10] Updated makefiles from gsictl --- git.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.mk b/git.mk index 6a2413f..178cd98 100644 --- a/git.mk +++ b/git.mk @@ -5,7 +5,7 @@ tag: git tag ${VERSION} push:: - git push -u --tags origin HEAD + git push --tags -u origin HEAD pull:: git pull --all From cbef9630b4e8bcc3f34d52bf4d42c7e3d638f310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:51:56 +0200 Subject: [PATCH 09/10] Updated makefiles from gsictl --- git.mk | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/git.mk b/git.mk index 178cd98..dae0e82 100644 --- a/git.mk +++ b/git.mk @@ -4,19 +4,25 @@ commit: tag: git tag ${VERSION} -push:: +git-push:: git push --tags -u origin HEAD -pull:: +git-pull: git pull --all -push-github: ## Push the code to github. You need to set up HUB_USER and HUB_PASSWORD +push-github: ## Push the code to github. You need to set up GITHUB_DEPLOY_KEY +ifeq ($(GITHUB_DEPLOY_KEY),) +else $(eval KEY_FILE := $(shell mktemp)) - @echo "$$GITHUB_DEPLOY_KEY" > $(KEY_FILE) + @echo "$(GITHUB_DEPLOY_KEY)" > $(KEY_FILE) @git remote rm github-deploy || true git remote add github-deploy $(GITHUB_REPO) @GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git fetch github-deploy $(CI_COMMIT_REF_NAME) || true @GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git push github-deploy $(CI_COMMIT_REF_NAME) rm $(KEY_FILE) +endif -.PHONY:: commit tag push push-github +push:: git-push +pull:: git-pull + +.PHONY:: commit tag push git-push git-pull push-github From 0dc93fc16be7e659fef1c9cbed838659f89a7538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Fri, 29 Sep 2017 15:53:14 +0200 Subject: [PATCH 10/10] Updated makefiles from gsictl --- makefiles.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makefiles.mk b/makefiles.mk index d97127b..03dcc17 100644 --- a/makefiles.mk +++ b/makefiles.mk @@ -12,5 +12,6 @@ makefiles-pull: makefiles-remote git subtree pull --prefix=.makefiles/ makefiles master --squash pull:: makefiles-pull +push:: makefiles-push -.PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull +.PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull pull push