-
Notifications
You must be signed in to change notification settings - Fork 132
/
Makefile
86 lines (68 loc) · 3.24 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Mostly drives how 'semver' is tested. Also has an 'install' target.
# N.B. 'semver' does not need to be built: it's simply an executable script.
# The default installation directory (see the 'install' target for more info)
PREFIX ?= /usr/local
# The full path name of the source code repository. Used for "bind mounts" in
# Docker
SRC ?= $(shell pwd)
# rule #1: don't hardcode; define it once in this file
include DEPENDENCIES
# these definitions are common to local/developer and automated testing
lint_semver_args = --shell=bash src/semver
lint_doctest_args = --shell=bash test/documentation-test
test_semver_args = test
test_doctest_args = test/documentation-test
# "semver" and "help" -- default target explains what's going on
semver:
@echo Nothing to make: semver in src/semver is an executable script
@echo Run \"make help\" for more details
help: semver
@echo
@echo \"make test-stable\" runs all tests in well defined Docker environments
@echo \"make test-local\" runs all tests assuming test tools are locally installed
@echo
@echo \"make install\" installs \'semver\' to ${DESTDIR}${PREFIX}/bin
@echo
@echo See the Makefile and README for even more details
# "test-stable" relies on well defined and stable test tools.
# It is run by GitHub actions.
# "test-stable" can be run locally as long as Docker is installed and up.
# This might be a good idea before pushing to GitHub or generating a PR.
test-stable: lint unit-test doc-test
# "test-local" assumes that the test tools (bats, shellcheck, bash) are installed.
# Unlike "test-stable", one is free to install any version of the tools and
# by any method: useful for development and exploring new versions. "asdf" might
# be the right way to set up your local dev. environment.
test-local: lint-local unit-test-local doc-test-local
# "lint" tests check shell scripts for dubious code
lint:
docker run --rm -v "${SRC}:/semver-tool:ro" -w /semver-tool \
${shellcheck_docker_image}:${shellcheck_image_tag} ${lint_semver_args}
docker run --rm -v "${SRC}:/semver-tool:ro" -w /semver-tool \
${shellcheck_docker_image}:${shellcheck_image_tag} ${lint_doctest_args}
# the main functional/unit tests for 'semver'
unit-test:
docker run --rm -v "${SRC}:/semver-tool:ro" -w /semver-tool \
${bats_docker_image}:${bats_image_tag} ${test_semver_args}
# tests that the README documentation conforms to 'semver' behaviour
doc-test:
docker run --rm -v "${SRC}:/semver-tool:ro" -w /semver-tool \
${bash_docker_image}:${bash_image_tag} ${test_doctest_args}
# "lint" tests check shell scripts for dubious code
lint-local:
shellcheck ${lint_semver_args}
shellcheck ${lint_doctest_args}
# the main functional/unit tests for 'semver'
unit-test-local:
bats ${test_semver_args}
# tests that the README documentation conforms to 'semver' behaviour
doc-test-local:
bash ${test_doctest_args}
#
# "install" copies the script to the desired installation location. Note that
# if 'DESTDIR' is not set (via, perhaps, the environment), only the 'PREFIX'
# is used (defined above, but can be overridden). Without 'DESTDIR',
# the installation is to a global path (e.g. /usr/local)
install:
install src/semver ${DESTDIR}${PREFIX}/bin
.PHONY: lint unit-test doc-test lint lint-local unit-test-local doc-test-local install semver help