forked from mongodb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (61 loc) · 4.03 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
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
USER=`whoami`
STAGING_URL="https://docs-mongodborg-staging.corp.mongodb.com"
PRODUCTION_URL="https://docs.mongodb.org"
STAGING_BUCKET=docs-mongodb-org-staging
PRODUCTION_BUCKET=docs-mongodb-org-prod
# "PROJECT" currently exists to support having multiple projects
# within one bucket. For the manual it is empty.
PROJECT=
DRIVERS_PATH=source/driver-examples
BLOCKS_FILE=./build/${GIT_BRANCH}/tests.blocks
TEST_FILE=./build/${GIT_BRANCH}/tests.js
.PHONY: help lint html stage deploy examples
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo
@echo 'Variables'
@printf " \033[36m%-18s\033[0m %s\n" 'ARGS' 'Arguments to pass to mut-publish'
lint: ## Checks URLs in the built corpus underneath build/<branch>/html
mut-lint --linters=links ./build/master/source/ ${ARGS}
test: html ## Runs test framework over the corpus
./build/docs-tools/tools/rst-testing/create-blocks.py ./build/${GIT_BRANCH}/source ${BLOCKS_FILE}
node ./build/docs-tools/tools/rst-testing/compile-blocks.js ${BLOCKS_FILE} > ${TEST_FILE}
./build/docs-tools/tools/rst-testing/rst_tester.py ${TEST_FILE}
html: examples ## Builds this branch's HTML under build/<branch>/html
giza make html
publish: examples ## Builds this branch's publishable HTML and other artifacts under build/public
giza make publish
# - Enter build/<branch>/html, and recurse over each regular file
# <basename>/<filename>.
# * Upload each to the S3 bucket under <project>/<username>/<basename>/<filename>
stage: ## Host online for review
mut-publish build/${GIT_BRANCH}/html ${STAGING_BUCKET} --prefix=${PROJECT} --stage ${ARGS}
@echo "Hosted at ${STAGING_URL}/${USER}/${GIT_BRANCH}/index.html"
# - Enter build/public/<branch>, as well as any symbolic links pointing
# to it, and recurse over each file <basename>/<filename>.
# * Upload each to the S3 bucket under <project>/<basename>/<filename>.
# - Upload each *regular file* <filename> underneath build/public
# underneath <project>/<filename>.
# - Download the redirect rules from S3 that begin with one of the
# --redirect-prefix regex rules.
# - Parse the file build/public/.htaccess, and for each redirect rule:
# * If rule does not exist in remote set, upload redirect.
# - Remove previously-matched redirect rules in S3 that do not exist in
# local redirect set.
# The recursive behavior would CHANGE if --all-subdirectories were
# given: ALL contents of build/public/<branch> would be upload
deploy: build/public ## Deploy to the production bucket
@echo "Doing a dry-run"
mut-publish build/public ${PRODUCTION_BUCKET} --prefix=${PROJECT} --deploy --redirect-prefix='v[0-9]\.[0-9]' --redirect-prefix='manual' --redirect-prefix='master' --verbose --dry-run ${ARGS}
@echo 'Press any key to perform the previous' && read result
mut-publish build/public ${PRODUCTION_BUCKET} --prefix=${PROJECT} --deploy --redirect-prefix='v[0-9]\.[0-9]' --redirect-prefix='manual' --redirect-prefix='master' ${ARGS}
@echo "Hosted at ${PRODUCTION_URL}/index.html"
examples:
mkdir -p ${DRIVERS_PATH}
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-python-driver/master/test/test_examples.py -o ${DRIVERS_PATH}/test_examples.py
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-perl-driver/master/t/examples/driver-examples.t -o ${DRIVERS_PATH}/driver-examples.t
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-php-library/master/tests/DocumentationExamplesTest.php -o ${DRIVERS_PATH}/DocumentationExamplesTest.php
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-java-driver/master/driver/src/examples/documentation/DocumentationSamples.java -o ${DRIVERS_PATH}/DocumentationSamples.java
curl -SfL https://raw.githubusercontent.com/mongodb/node-mongodb-native/2.2/test/functional/examples_tests.js -o ${DRIVERS_PATH}/examples_tests.js
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-ruby-driver/master/spec/mongo/shell_examples_spec.rb -o ${DRIVERS_PATH}/shell_examples_spec.rb