-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (151 loc) · 6.29 KB
/
Makefile
File metadata and controls
181 lines (151 loc) · 6.29 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Configuration
APP_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/..)
APP_NAME := thunderbird
include .env
# Notebook targets
LOCAL_URL = http://localhost:5000/wps
DEV_PORT ?= $(shell bash -c 'read -ep "Target port: " port; echo $$port')
# Used in target refresh-notebooks to make it looks like the notebooks have
# been refreshed from the production server below instead of from the local dev
# instance so the notebooks can also be used as tutorial notebooks.
OUTPUT_URL = https://$(DACCS_HOST)/wpsoutputs
SANITIZE_FILE := https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/docs/output-sanitize.cfg
.PHONY: all
all: develop test-all clean-test test-notebooks-prod
.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of:"
@echo " help to print this help message. (Default)"
@echo " install to install app by running 'pip install -e .'"
@echo " develop to install with additional development requirements."
@echo " start to start $(APP_NAME) service as daemon (background process)."
@echo " stop to stop $(APP_NAME) service."
@echo " restart to restart $(APP_NAME) service."
@echo " status to show status of $(APP_NAME) service."
@echo " clean to remove all files generated by build and tests."
@echo "\nTesting targets:"
@echo " test to run tests (but skip online and long running tests)."
@echo " test-not-online to run tests (but skip online tests)."
@echo " test-all to run all tests (including online and long running tests)."
@echo " lint to run code style checks with flake8."
@echo "\nSphinx targets:"
@echo " docs to generate HTML documentation with Sphinx."
@echo "\nDeployment targets:"
@echo " dist to build source and wheel package."
## Build targets
.PHONY: install
install: install-cdo
@echo "Installing application ..."
@-bash -c 'poetry install'
@echo "\nStart service with \`thunderbird start'"
.PHONY: install-cdo
install-cdo:
@echo "Installing cdo package ..."
@-bash -c "sudo apt-get update"
@-bash -c "sudo apt-get install cdo"
.PHONY: install-ci
install-ci: install-cdo
@echo "Installing ci requirements"
@-bash -c 'poetry install --with=dev'
.PHONY: develop
develop: install-cdo
@echo "Installing development requirements for tests and docs ..."
@-bash -c 'poetry install --with=dev'
# These commands have been disabled until further notice. Due to the issues with
# cdo's signal handling, we cannot reliably start/stop using make.
#
# .PHONY: start
# start: venv
# @echo "Starting application ..."
# @-bash -c "${VENV}/bin/$(APP_NAME) start -d"
#
# .PHONY: stop
# stop: venv
# @echo "Stopping application ..."
# @-bash -c "${VENV}/bin/$(APP_NAME) stop"
#
# .PHONY: restart
# restart: venv stop start
# @echo "Restarting application ..."
#
# .PHONY: status
# status: venv
# @echo "Show status ..."
# @-bash -c "${VENV}/bin/$(APP_NAME) status"
.PHONY: clean
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
.PHONY: clean-build
clean-build:
@echo "Remove build artifacts ..."
@-rm -fr build/
@-rm -fr dist/
@-rm -fr .eggs/
@-find . -name '*.egg-info' -exec rm -fr {} +
@-find . -name '*.egg' -exec rm -f {} +
@-find . -name '*.log' -exec rm -fr {} +
@-find . -name '*.sqlite' -exec rm -fr {} +
.PHONY: clean-pyc
clean-pyc:
@echo "Remove Python file artifacts ..."
@-find . -name '*.pyc' -exec rm -f {} +
@-find . -name '*.pyo' -exec rm -f {} +
@-find . -name '*~' -exec rm -f {} +
@-find . -name '__pycache__' -exec rm -fr {} +
.PHONY: clean-test
clean-test:
@echo "Remove test artifacts ..."
@-rm -fr .pytest_cache
.PHONY: clean-dist
clean-dist: clean
@echo "Running 'git clean' ..."
@git diff --quiet HEAD || echo "There are uncommitted changes! Aborting 'git clean' ..."
## do not use git clean -e/--exclude here, add them to .gitignore instead
@-git clean -dfx
## Test targets
.PHONY: test
test:
@echo "Running tests (skip slow and online tests) ..."
@bash -c 'poetry run pytest -v -m "not slow and not online" tests/'
.PHONY: test-all
test-all:
@echo "Running all tests (including slow and online tests) ..."
@bash -c 'poetry run pytest -v tests/'
.PHONY: test-not-online
test-not-online:
@echo "Running tests (including slow but excluding online tests) ..."
@bash -c 'poetry run pytest -v -m "not online" tests/'
.PHONY: notebook-sanitizer
notebook-sanitizer:
@echo "Copying notebook output sanitizer ..."
@-bash -c "curl -L $(SANITIZE_FILE) -o $(CURDIR)/docs/output-sanitize.cfg --silent"
.PHONY: test-notebooks
test-notebooks: notebook-sanitizer
@echo "Running notebook-based tests"
@bash -c "poetry shell && env LOCAL_URL=$(LOCAL_URL) pytest --nbval --verbose $(CURDIR)/notebooks/ --sanitize-with $(CURDIR)/docs/output-sanitize.cfg --ignore $(CURDIR)/notebooks/.ipynb_checkpoints"
.PHONY: test-notebooks-prod
test-notebooks-prod: notebook-sanitizer
@echo "Running notebook-based tests against production instance of thunderbird"
@bash -c "poetry shell && pytest --nbval --verbose $(CURDIR)/notebooks/ --sanitize-with $(CURDIR)/docs/output-sanitize.cfg --ignore $(CURDIR)/notebooks/.ipynb_checkpoints"
.PHONY: test-notebooks-dev
test-notebooks-dev: notebook-sanitizer
@echo "Running notebook-based tests against development instance of thunderbird"
@bash -c "poetry shell && env DEV_URL=http://$(DACCS_HOST):30099/wps pytest --nbval --verbose $(CURDIR)/notebooks/ --sanitize-with $(CURDIR)/docs/output-sanitize.cfg --ignore $(CURDIR)/notebooks/.ipynb_checkpoints"
.PHONY: test-notebooks-custom
test-notebooks-custom: notebook-sanitizer
@echo "Running notebook-based tests against custom instance of thunderbird"
@bash -c "poetry shell && env DEV_URL=http://$(DACCS_HOST):$(DEV_PORT)/wps pytest --nbval --verbose $(CURDIR)/notebooks/ --sanitize-with $(CURDIR)/docs/output-sanitize.cfg --ignore $(CURDIR)/notebooks/.ipynb_checkpoints"
.PHONY: lint
lint: venv
@echo "Running black code style checks ..."
@bash -c 'poetry run black . --check'
## Sphinx targets
.PHONY: docs
docs:
@echo "Updating notebook docs"
@bash -c 'poetry shell && jupyter nbconvert --to html notebooks/* --output-dir docs/formatted_demos/'
## Deployment targets
.PHONY: dist
dist: clean
@echo "Builds source and wheel package ..."
@bash -c 'poetry build'
ls -l dist