blob: c2c756a60064ce3b6019f76532b71e675f9a0619 [file] [log] [blame]
Zack Williams712caf62020-04-28 13:37:41 -07001# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
2# SPDX-License-Identifier: Apache-2.0
3
4SHELL = bash -e -o pipefail
5
6# Common set of args, set to --debug for more output
7COMMON_ARGS ?= --debug
8
9# tooling binaries
10VIRTUALENV ?= virtualenv -p python3
11PYTHON ?= python3
12# change to be 'python3 -m cProfile -s cumtime' to profile a script
13
14.DEFAULT_GOAL := help
15.PHONY: test lint yamllint license help build siterender buildcollector sync
16
17# Create the virtualenv with all the tools installed
18VENV_NAME = venv_sjsg
19
20$(VENV_NAME): requirements.txt
21 $(VIRTUALENV) $@ ;\
22 source ./$@/bin/activate ; set -u ;\
23 $(PYTHON) -m pip install -r requirements.txt yamllint
24 echo "To enter virtualenv, run 'source $@/bin/activate'"
25
26# build targets
27
28build: buildcollector siterender ## Collect build info and create website
29
30buildcollector: $(VENV_NAME) ## Collect build information from Jenkins jobs
31 source ./$</bin/activate ; set -u ;\
32 $(PYTHON) buildcollector.py scrape.yaml --credentials credentials.yaml $(COMMON_ARGS)
33
34siterender: $(VENV_NAME) ## Create static website from build information
35 source ./$</bin/activate ; set -u ;\
36 $(PYTHON) siterender.py $(COMMON_ARGS)
37 cp -r static/* site/
38
39serve:
40 cd site && $(PYTHON) -m http.server
41
42sync:
43 rsync --delete-after -avP site/ ubuntu@static.opennetworking.org:/srv/sites/certification.opennetworking.org/
44
45# testing targets
46test: yamllint tox ## run all tests
47
48# YAML files, excluding venv and cookiecutter directories
49YAML_FILES ?= $(shell find . -type d \( -path "./venv_sjsc" \) -prune -o -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
50
51yamllint: $(VENV_NAME) ## lint YAML format using yamllint
52 source ./$</bin/activate ; set -u ;\
53 yamllint --version ;\
54 yamllint \
55 -d "{extends: default, rules: {line-length: {max: 139}}}" \
56 -s $(YAML_FILES)
57
58tox: ## test code with tox
59 tox
60
61license: ## Check code for licensing with REUSE
62 reuse --root . lint
63
64clean: ## Delete all temporary files
65 rm -rf products/* site/*
66
67clean-all: clean ## Delete virtualenv and all cached job information
68 rm -rf $(VENV_NAME) jobs/* .tox
69
70help: ## Print help for each target
71 @echo nginx test targets
72 @echo
73 @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
74 | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'