blob: c2c756a60064ce3b6019f76532b71e675f9a0619 [file] [log] [blame]
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
SHELL = bash -e -o pipefail
# Common set of args, set to --debug for more output
COMMON_ARGS ?= --debug
# tooling binaries
VIRTUALENV ?= virtualenv -p python3
PYTHON ?= python3
# change to be 'python3 -m cProfile -s cumtime' to profile a script
.DEFAULT_GOAL := help
.PHONY: test lint yamllint license help build siterender buildcollector sync
# Create the virtualenv with all the tools installed
VENV_NAME = venv_sjsg
$(VENV_NAME): requirements.txt
$(VIRTUALENV) $@ ;\
source ./$@/bin/activate ; set -u ;\
$(PYTHON) -m pip install -r requirements.txt yamllint
echo "To enter virtualenv, run 'source $@/bin/activate'"
# build targets
build: buildcollector siterender ## Collect build info and create website
buildcollector: $(VENV_NAME) ## Collect build information from Jenkins jobs
source ./$</bin/activate ; set -u ;\
$(PYTHON) buildcollector.py scrape.yaml --credentials credentials.yaml $(COMMON_ARGS)
siterender: $(VENV_NAME) ## Create static website from build information
source ./$</bin/activate ; set -u ;\
$(PYTHON) siterender.py $(COMMON_ARGS)
cp -r static/* site/
serve:
cd site && $(PYTHON) -m http.server
sync:
rsync --delete-after -avP site/ ubuntu@static.opennetworking.org:/srv/sites/certification.opennetworking.org/
# testing targets
test: yamllint tox ## run all tests
# YAML files, excluding venv and cookiecutter directories
YAML_FILES ?= $(shell find . -type d \( -path "./venv_sjsc" \) -prune -o -type f \( -name '*.yaml' -o -name '*.yml' \) -print )
yamllint: $(VENV_NAME) ## lint YAML format using yamllint
source ./$</bin/activate ; set -u ;\
yamllint --version ;\
yamllint \
-d "{extends: default, rules: {line-length: {max: 139}}}" \
-s $(YAML_FILES)
tox: ## test code with tox
tox
license: ## Check code for licensing with REUSE
reuse --root . lint
clean: ## Delete all temporary files
rm -rf products/* site/*
clean-all: clean ## Delete virtualenv and all cached job information
rm -rf $(VENV_NAME) jobs/* .tox
help: ## Print help for each target
@echo nginx test targets
@echo
@grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'