-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (97 loc) · 2.88 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2023 The Foundation for Public Code <info@publiccode.net>
# Makefile variables used:
#
# $@ : target label
# $< : the first prerequisite after the colon
# $^ : all of the prerequisite files
BROWSER ?= firefox
SHELL=/bin/bash
COVERAGE ?= python3-coverage
.PHONY: default
default: check-all
.PHONY: run
run: url-check.py url-check-run-config.json
./url-check.py --config=url-check-run-config.json
./node_modules/.bin/badge:
npm install badge-maker
make-badge: ./node_modules/.bin/badge
LICENSE_ID ?= CC0-1.0
COPYRIGHT_TEXT ?= 2023 The Foundation for Public Code <info@publiccode.net>
badges/url-check.svg: make-badge url-check-url-check-fails.json
LICENSE_ID='$(LICENSE_ID)' COPYRIGHT_TEXT='$(COPYRIGHT_TEXT)' \
./make-badge url-check main
badges/url-check-bad.svg: make-badge url-check-bad-url-check-fails.json
LICENSE_ID='$(LICENSE_ID)' COPYRIGHT_TEXT='$(COPYRIGHT_TEXT)' \
./make-badge url-check-bad demo-bad-link
url-check-url-check-look.json \
url-check-url-check-fails.json \
url-check-url-check-results.json \
url-check-bad-url-check-look.json \
url-check-bad-url-check-fails.json \
url-check-bad-url-check-results.json \
url-check-fails.json \
url-check-results.json \
&: url-check.py url-check-demo-config.json
./url-check.py --config=url-check-demo-config.json
site: badges/url-check.svg \
badges/url-check-bad.svg \
url-check-url-check-look.json \
url-check-url-check-fails.json \
url-check-url-check-results.json \
url-check-bad-url-check-look.json \
url-check-bad-url-check-fails.json \
url-check-bad-url-check-results.json \
url-check-fails.json \
url-check-results.json
cp -v $^ _site/
url-check.test.py: url-check.py
check: url-check.test.py
./$<
@echo "SUCCESS $@"
.coverage: url-check.test.py url-check.py
$(COVERAGE) run --concurrency=multiprocessing url-check.test.py
$(COVERAGE) combine
.PHONY: coverage
coverage: .coverage
$(COVERAGE) report url-check.py
COVERAGE_PERCENT_CMD=\
`$(COVERAGE) report url-check.py \
| grep url-check.py \
| awk '{print $$4}' \
| sed 's/%//'`
MIN_COVERAGE_PCT_THRESHOLD=100
.PHONY: check-coverage
check-coverage: .coverage
{ \
$(COVERAGE) report url-check.py; \
COVERAGE_PERCENT=$(COVERAGE_PERCENT_CMD); \
if [ $$COVERAGE_PERCENT -lt $(MIN_COVERAGE_PCT_THRESHOLD) ]; \
then \
false; \
fi \
}
@echo "SUCCESS $@"
.PHONY: test
test: run
if [ $$(grep -c '"failing"' url-check-fails.json) -ne 0 ]; then \
false; \
fi
@echo "SUCCESS $@"
.PHONY: check-all
check-all: check check-coverage test
@echo "SUCCESS $@"
htmlcov/url-check_py.html: .coverage
$(COVERAGE) html url-check.py
.PHONY: view-coverage
view-coverage: htmlcov/url-check_py.html
$(BROWSER) htmlcov/url-check_py.html
.PHONY: tidy
tidy: url-check.py url-check.test.py
yapf3 --in-place $^
.PHONY: clean
clean:
rm -vf .coverage _site/*.json _site/*.svg
.PHONY: dist-clean
dist-clean:
git clean -dxff