This is part 1 of the series where we will discuss on initials of make file and how this can enhance the taste buds of automation to tox.
Makefile or make has eased life of developers in the past and is still commonly used in various spaces. This blog relates the usage of make with a tox infrastructure test run.
As this is for the community and if you are interested in just the code, go ahead.
1
2 # Theory
3 # - Cleanup of old binaries and non required files
4 # - Performing git clone
5 # - Calling as shell script to build
6
7
8 .PHONY: build clean run git
9
10 VERSION = "0.0.1" #using '0.0.1' , use $RANDOM if you want to use it as
$(shell $RANDOM)
11
12 TARGET_FILEPATH = $(addsuffix $(VERSION), ./dist/prod-build-)
13 TARGET_ZIPFILEPATH = $(addsuffix .tar.gz,$(TARGET_FILEPATH))
14
15 clean:
16 $(shell bash ./run.sh)
17
18 Run:
19 $(clean)
20 $(run.sh) tox
21
22 Git:
23 git clone https://
24
25 $(TARGET_ZIPFILEPATH):
26 $(git)
27 @python3 setup.py sdist
28
29 build: $(TARGET_ZIPFILEPATH)
What does that means ?
make clean # will clean the directory
-
Let us look at the code line by line
line 7 : phony here is to ensure explicit calls to build clean run git, this is not an order of execution for indepth understanding Refer :: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
line 9 : this is assignment of a string "0.0.1" to a variable
line 11 : this appends $(VERSION) with ./dist/prod-build- thus variable "TARGET_FILEPATH" = /dist/prod-build-0.0.1 line 12 : this will make TARGET_ZIPFILEPATH = /dist/prod-build-0.0.1.tar.gz
line 14, 17, 21, 24, 28 : all represents a call similar to a goto statement
-
Lets see the code calls and respective outputs
make clean build # will clean the directory , then do a git clone (line 22), execute a python sdist (line 26)
make clean build run # will do "make clean build" in sequence and thereafter will perform clean (line 15) and then run with tox
parameter (line 19)
Still working on Next Part