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 | |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 28 | products: |
| 29 | mkdir products |
| 30 | |
| 31 | site: |
| 32 | mkdir site |
| 33 | |
| 34 | |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 35 | build: buildcollector siterender ## Collect build info and create website |
| 36 | |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 37 | buildcollector: $(VENV_NAME) products ## Collect build information from Jenkins jobs |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 38 | source ./$</bin/activate ; set -u ;\ |
| 39 | $(PYTHON) buildcollector.py scrape.yaml --credentials credentials.yaml $(COMMON_ARGS) |
| 40 | |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 41 | siterender: $(VENV_NAME) site ## Create static website from build information |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 42 | source ./$</bin/activate ; set -u ;\ |
| 43 | $(PYTHON) siterender.py $(COMMON_ARGS) |
| 44 | cp -r static/* site/ |
| 45 | |
| 46 | serve: |
| 47 | cd site && $(PYTHON) -m http.server |
| 48 | |
| 49 | sync: |
| 50 | rsync --delete-after -avP site/ ubuntu@static.opennetworking.org:/srv/sites/certification.opennetworking.org/ |
| 51 | |
| 52 | # testing targets |
| 53 | test: yamllint tox ## run all tests |
| 54 | |
| 55 | # YAML files, excluding venv and cookiecutter directories |
| 56 | YAML_FILES ?= $(shell find . -type d \( -path "./venv_sjsc" \) -prune -o -type f \( -name '*.yaml' -o -name '*.yml' \) -print ) |
| 57 | |
| 58 | yamllint: $(VENV_NAME) ## lint YAML format using yamllint |
| 59 | source ./$</bin/activate ; set -u ;\ |
| 60 | yamllint --version ;\ |
| 61 | yamllint \ |
| 62 | -d "{extends: default, rules: {line-length: {max: 139}}}" \ |
| 63 | -s $(YAML_FILES) |
| 64 | |
| 65 | tox: ## test code with tox |
| 66 | tox |
| 67 | |
| 68 | license: ## Check code for licensing with REUSE |
| 69 | reuse --root . lint |
| 70 | |
| 71 | clean: ## Delete all temporary files |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 72 | rm -rf products site |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 73 | |
| 74 | clean-all: clean ## Delete virtualenv and all cached job information |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 75 | rm -rf $(VENV_NAME) jobs .tox |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 76 | |
| 77 | help: ## Print help for each target |
Zack Williams | cb2746d | 2020-12-16 10:27:24 -0700 | [diff] [blame^] | 78 | @echo sjsg test targets |
Zack Williams | 712caf6 | 2020-04-28 13:37:41 -0700 | [diff] [blame] | 79 | @echo |
| 80 | @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 81 | | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};' |