forked from OBOFoundry/purl.obolibrary.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (124 loc) · 4.37 KB
/
Makefile
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
# OBO Purls Makefile
# 2015-11-06
# James A. Overton <james@overton.ca>
#
# Last major modification: 2019-02-10, Michael Cuffaro <consulting@michaelcuffaro.com>
#
# This file contains code for working with
# Open Biomedical Ontoloiges (OBO)
# Persistent Uniform Resource Locators (PURLs).
#
# WARNING: This file contains significant whitespace!
# Make sure that your text editor distinguishes tabs from spaces.
#
# Required software:
#
# - [GNU Make](http://www.gnu.org/software/make/) to run this file
# - [Python 3](https://www.python.org/downloads/) to run scripts
# - [PyYAML](http://pyyaml.org/wiki/PyYAML) for translation to Apache
### Configuration
#
# You can override these defaults with environment variables:
#
# export DEVELOPMENT=172.16.100.10; make all test
#
# List of ontology IDs to work with, as file names (lowercase).
# Defaults to the list of config/*.yml files.
ONTOLOGY_IDS ?= $(patsubst config/%.yml,%,$(wildcard config/*.yml))
# Local development server.
DEVELOPMENT ?= localhost
# Production server.
PRODUCTION ?= purl.obolibrary.org
### Boilerplate
#
# Recommended defaults: http://clarkgrubb.com/makefile-style-guide
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
.DEFAULT_GOAL := all
.SUFFIXES:
### Basic Operations
# Default goal: Remove generated files and regenerate.
.PHONY: all
all: clean build
# Remove directories with generated files and tests.
.PHONY: clean
clean:
rm -rf temp tests
### Build recipe for a single project.
#
# Convert the YAML file of a single project to a .htaccess file and place it
# in the temp/ directory.
.PHONY: build-%
build-%:
tools/translate_yaml.py --input_files config/$*.yml --output_dir temp
@echo "Built files in temp/$*"
# Build recipe for all projects
#
# Convert the YAML files of every project to .htaccess files and place them
# in the www/obo directory.
# Final output directory:
www/obo/:
mkdir -p $@
# When a new build is created, the old build's files are moved here, in a subdirectory
# whose name is generated in a portable way using python (see the target-specific
# variable BACKUP below).
backup/:
mkdir $@
# The main build target:
.PHONY: build
build: BACKUP = backup/obo-$(shell python -c "import time,os;print(time.strftime('%Y%m%d-%H%M%S',time.gmtime(os.path.getmtime('www/obo'))))")
build: | backup/ www/obo/
tools/translate_yaml.py --input_dir config --output_dir temp/obo
rm -rf temp/obo/obo temp/obo/OBO
-test -e www/obo && mv www/obo $(BACKUP)
mv temp/obo www/obo
rmdir temp
### Test Development Apache Config
#
# Make HTTP HEAD requests quickly against the DEVELOPMENT server
# to ensure that redirects are working properly.
# Fail if any FAIL line is found in any of them.
.PHONY: test
test:
tools/test.py --delay=0.01 --output=tests/development --domain=$(DEVELOPMENT) config/*.yml
### Test Production Apache Config
#
# Make HTTP HEAD requests slowly against the PRODUCTION server
# to ensure that redirects are working properly.
.PHONY: test-production
test-production:
tools/test.py --delay=1 --output=tests/production --domain=$(PRODUCTION) config/*.yml
### Test Tools
#
# Test our tools on files in examples/ directory.
.PHONY: test-example1
test-example1:
tools/migrate.py test1 tools/examples/test1/test1.xml tests/examples/test1/test1.yml
diff tools/examples/test1/test1.yml tests/examples/test1/test1.yml
.PHONY: test-example2
test-example2:
tools/translate_yaml.py --input_dir tools/examples/test2/ --output_dir tests/examples/test2/
diff tools/examples/test2/test2.htaccess tests/examples/test2/.htaccess
diff tools/examples/test2/obo/obo.htaccess tests/examples/test2/obo/.htaccess
diff tools/examples/test2/test2/test2.htaccess tests/examples/test2/test2/.htaccess
.PHONY: test-examples
test-examples: test-example1 test-example2
### Update Repository
#
# Run the safe-update.py script which does the following:
# - Check Travis-CI for the last build.
# - If it did not pass, or if it is the same as the current build, then do nothing.
# - Otherwise replace .current_build, pull from git, and run a new `make`.
safe-update:
tools/safe-update.py
### Code style and lint checks for python source files.
#
# Note that `|| true` is appended to force make to ignore the exit code in both cases
.PHONY: style
style:
pep8 --max-line-length=100 --ignore E129,E126,E121,E111,E114 tools/*.py || true
.PHONY: delint
delint:
python3 -m pyflakes tools/*.py || true