forked from dmitryn/GitStats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
59 lines (46 loc) · 1.42 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
# Makefile for building Docker image of gitstats.
SHELL = /bin/bash
# Absolute path to directory containing this Makefile.
# Needed for older `docker run` versions which don't support bind mounts using relative paths.
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Name and tag of the Docker image to be built.
DOCKERIMAGE=jk4ger/gitstats:local
# Use the local repository for the test.
REPO_DIR=$(ROOT_DIR)
# Output directory.
OUTDIR=$(ROOT_DIR)/out
OUT_INDEX=$(OUTDIR)/index.html
# Run with current user, otherwise the output files will be owned by root.
UID=$(shell id -u)
GID=$(shell id -g)
USER=$(UID):$(GID)
# Build the Docker image.
.PHONY: build
build:
docker build -t $(DOCKERIMAGE) --progress=plain .
# Rebuild and run.
.PHONY: run
run: build run-ci
# Run (without rebuild).
.PHONY: run-ci
run-ci:
docker run \
--user $(USER) \
-v "$(REPO_DIR):/repo:ro" \
-v "$(OUTDIR):/out" \
--rm \
$(DOCKERIMAGE)
# Clean up, rebuild, run and check output.
.PHONY: test
test: clean run check-output
# Clean up, run and check output (without rebuild).
.PHONY: test-ci
test-ci: clean run-ci check-output
# Smoke check for output files.
.PHONY: check-output
check-output:
@grep '<title>GitStats - repo</title>' $(OUT_INDEX) >/dev/null || (echo "Unexpected content of $(OUT_INDEX)."; exit 1)
# Clean up output files.
.PHONY: clean
clean:
find $(OUTDIR) -mindepth 1 -not -name .gitignore | xargs -l rm -fv