Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | SHELL = bash -e -o pipefail |
| 5 | |
| 6 | # Common set of args, set to --debug for more output |
| 7 | COMMON_ARGS ?= --debug |
| 8 | |
| 9 | # tooling binaries |
| 10 | VIRTUALENV ?= virtualenv -p python3 |
| 11 | PYTHON ?= 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 |
| 18 | VENV_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 | |
| 28 | build: buildcollector siterender ## Collect build info and create website |
| 29 | |
| 30 | buildcollector: $(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 | |
| 34 | siterender: $(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 | |
| 39 | serve: |
| 40 | cd site && $(PYTHON) -m http.server |
| 41 | |
| 42 | sync: |
| 43 | rsync --delete-after -avP site/ ubuntu@static.opennetworking.org:/srv/sites/certification.opennetworking.org/ |
| 44 | |
| 45 | # testing targets |
| 46 | test: yamllint tox ## run all tests |
| 47 | |
| 48 | # YAML files, excluding venv and cookiecutter directories |
| 49 | YAML_FILES ?= $(shell find . -type d \( -path "./venv_sjsc" \) -prune -o -type f \( -name '*.yaml' -o -name '*.yml' \) -print ) |
| 50 | |
| 51 | yamllint: $(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 | |
| 58 | tox: ## test code with tox |
| 59 | tox |
| 60 | |
| 61 | license: ## Check code for licensing with REUSE |
| 62 | reuse --root . lint |
| 63 | |
| 64 | clean: ## Delete all temporary files |
| 65 | rm -rf products/* site/* |
| 66 | |
| 67 | clean-all: clean ## Delete virtualenv and all cached job information |
| 68 | rm -rf $(VENV_NAME) jobs/* .tox |
| 69 | |
| 70 | help: ## 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};' |