From 01415b87456516f249207111d56e860eaa79c939 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Erik=20Hedenstro=CC=88m?= <erik@hedenstroem.com>
Date: Mon, 9 Nov 2015 21:40:59 +0100
Subject: [PATCH] Cleaned up build scripts

---
 .gitlab-ci.yml |  9 +++++----
 Makefile       | 32 ++++++++++++++------------------
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aaf9459..96efd73 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,6 +9,7 @@ before_script:
   - if [ "$HTTP_PROXY" != "" ]; then printf "{http_proxy,\"$HTTP_PROXY\"}.\n" >> ~/.config/rebar3/rebar.config; fi
   - if [ "$HTTPS_PROXY" != "" ]; then printf "{https_proxy,\"$HTTPS_PROXY\"}.\n" >> ~/.config/rebar3/rebar.config; fi
   - curl -jksSL -o rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
+  - rebar3 update
 
 stages:
   - compile
@@ -18,12 +19,12 @@ stages:
 compile:
   stage: compile
   script:
-    - ./rebar3 as production do compile
+    - rebar3 as production do compile
 
 test:
   stage: test
   script:
-    - ./rebar3 do eunit --cover --dir=test, cover --verbose
+    - rebar3 as test do eunit --cover --dir=test, cover --verbose
     - coverage.escript _build/test/cover/eunit.coverdata
 
 publish:
@@ -31,5 +32,5 @@ publish:
   only:
     - /^\d+[.]\d+[.]\d+$/ # Only publish HEAD tagged with semantic version
   script:
-    - ./rebar3 update
-    - echo Y | ./rebar3 hex publish
+    - rebar3 update
+    - echo Y | rebar3 hex publish
diff --git a/Makefile b/Makefile
index c1c4f22..33df7b3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,33 +1,29 @@
-REBAR ?= $(CURDIR)/rebar3
-REBAR_URL ?= https://s3.amazonaws.com/rebar3/rebar3
-define get_rebar
-	curl -s -L -o $(REBAR) $(REBAR_URL) || rm $(REBAR)
-	chmod +x $(REBAR)
-endef
-export REBAR
+REBAR_VERSION := $(shell rebar3 --version 2>/dev/null)
+ifdef REBAR_VERSION
+REBAR := rebar3
+else
+REBAR := $(CURDIR)/rebar3
+$(shell if ! [ -e "$(REBAR)" ]; then curl -jksSL -o $(REBAR) https://s3.amazonaws.com/rebar3/rebar3; chmod +x $(REBAR); fi)
+endif
 
-all: test
+all: tests
 
-$(REBAR):
-	@$(call get_rebar)
-	@$(REBAR) update
-
-compile: $(REBAR)
+compile:
 	@$(REBAR) compile
 
-test: $(REBAR)
+tests:
 	@$(REBAR) do eunit --cover --dir=test, cover --verbose
 
-analyze: $(REBAR)
+analyze:
 	@$(REBAR) dialyzer
 
-release: $(REBAR)
+release:
 	@$(REBAR) release
 
-docs: $(REBAR)
+docs:
 	@$(REBAR) edoc
 
-clean: $(REBAR)
+clean:
 	@$(REBAR) clean
 
 distclean:
-- 
GitLab