blob: 06e9dc291877acb76eaa9c1540be7170edf1b8c9 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file or at
4# https://developers.google.com/open-source/licenses/bsd
5
6# Makefile to simplify some common AppEngine actions.
7# Use 'make help' for a list of commands.
8
9DEVID = monorail-dev
10STAGEID= monorail-staging
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +020011PRODID= avm99963-bugs
Copybara854996b2021-09-07 19:36:02 +000012
13GAE_PY?= python gae.py
14DEV_APPSERVER_FLAGS?= --watcher_ignore_re="(.*/lib|.*/node_modules|.*/third_party|.*/venv)"
15
16WEBPACK_PATH := ./node_modules/webpack-cli/bin/cli.js
17
18TARDIR ?= "/workspace"
19
20FRONTEND_MODULES?= default
21BACKEND_MODULES?= besearch latency-insensitive api
22
23BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
24
25PY_DIRS = api,businesslogic,features,framework,project,proto,search,services,sitewide,testing,tracker
26
27_VERSION ?= $(shell ../../../infra/luci/appengine/components/tools/calculate_version.py)
28
Copybara854996b2021-09-07 19:36:02 +000029default: help
30
31check:
32ifndef NPM_VERSION
33 $(error npm not found. Install from nodejs.org or see README)
34endif
35
36help:
37 @echo "Available commands:"
38 @sed -n '/^[a-zA-Z0-9_.]*:/s/:.*//p' <Makefile
39
40# Run "eval `../../go/env.py`" before running the following prpc_proto commands
41prpc_proto_v0:
42 touch ../../ENV/lib/python2.7/site-packages/google/__init__.py
43 PYTHONPATH=../../ENV/lib/python2.7/site-packages \
44 PATH=../../luci/appengine/components/tools:$(PATH) \
45 ../../cipd/protoc \
46 --python_out=. --prpc-python_out=. api/api_proto/*.proto
47 cd ../../go/src/infra/monorailv2 && \
48 cproto -proto-path ../../../../appengine/monorail/ ../../../../appengine/monorail/api/api_proto/
49prpc_proto_v3:
50 touch ../../ENV/lib/python2.7/site-packages/google/__init__.py
51 PYTHONPATH=../../ENV/lib/python2.7/site-packages \
52 PATH=../../luci/appengine/components/tools:$(PATH) \
Adrià Vilanova Martínezf5e10392021-12-07 22:55:40 +010053 ../../cipd/bin/protoc \
Copybara854996b2021-09-07 19:36:02 +000054 --python_out=. --prpc-python_out=. api/v3/api_proto/*.proto
55 cd ../../go/src/infra/monorailv2 && \
56 cproto -proto-path ../../../../appengine/monorail/ ../../../../appengine/monorail/api/v3/api_proto/
57
58business_proto:
59 touch ../../ENV/lib/python2.7/site-packages/google/__init__.py
60 PYTHONPATH=../../ENV/lib/python2.7/site-packages \
61 PATH=../../luci/appengine/components/tools:$(PATH) \
62 ../../cipd/protoc \
63 --python_out=. --prpc-python_out=. proto/*.proto
64
65test:
66 ../../test.py test appengine/monorail
67
68test_no_coverage:
69 ../../test.py test appengine/monorail --no-coverage
70
71coverage:
72 @echo "Running tests + HTML coverage report in ~/monorail-coverage:"
73 ../../test.py test appengine/monorail --html-report ~/monorail-coverage --coveragerc appengine/monorail/.coveragerc
74
75# Shows coverage on the tests themselves, helps illuminate when we have test
76# methods that aren't used.
77test_coverage:
78 @echo "Running tests + HTML coverage report (for tests) in ~/monorail-test-coverage:"
79 ../../test.py test appengine/monorail --html-report ~/monorail-test-coverage --coveragerc appengine/monorail/.testcoveragerc
80
81# Commands for running locally using dev_appserver.
82# devserver requires an application ID (-A) to be specified.
83# We are using `-A monorail-staging` because ml spam code is set up
84# to impersonate monorail-staging in the local environment.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010085serve:
Copybara854996b2021-09-07 19:36:02 +000086 @echo "---[Starting SDK AppEngine Server]---"
87 $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS)& $(WEBPACK_PATH) --watch
88
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010089serve_email:
Copybara854996b2021-09-07 19:36:02 +000090 @echo "---[Starting SDK AppEngine Server]---"
91 $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True& $(WEBPACK_PATH) --watch
92
93# The _remote commands expose the app on 0.0.0.0, so that it is externally
94# accessible by hostname:port, rather than just localhost:port.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010095serve_remote:
Copybara854996b2021-09-07 19:36:02 +000096 @echo "---[Starting SDK AppEngine Server]---"
97 $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS)& $(WEBPACK_PATH) --watch
98
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010099serve_remote_email:
Copybara854996b2021-09-07 19:36:02 +0000100 @echo "---[Starting SDK AppEngine Server]---"
101 $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True& $(WEBPACK_PATH) --watch
102
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100103serve_cloud_tasks:
104 @echo "---[Starting Cloud Tasks Emulator]---"
105 ../../cipd/cloud-tasks-emulator \
106 --queue projects/monorail-staging/locations/us-central1/queues/componentexport \
107 --queue projects/monorail-staging/locations/us-central1/queues/default \
108 --queue projects/monorail-staging/locations/us-central1/queues/notifications \
109 --queue projects/monorail-staging/locations/us-central1/queues/outboundemail \
110 --queue projects/monorail-staging/locations/us-central1/queues/recomputederivedfields \
111 --queue projects/monorail-staging/locations/us-central1/queues/spamexport \
112 --queue projects/monorail-staging/locations/us-central1/queues/wipeoutsendusers \
113 --queue projects/monorail-staging/locations/us-central1/queues/wipeoutdeleteusers \
114 --queue projects/monorail-staging/locations/us-central1/queues/deleteusers \
115 --queue projects/monorail-staging/locations/us-central1/queues/pubsub-issueupdates \
116 -host localhost \
117 -port 9090
118
Copybara854996b2021-09-07 19:36:02 +0000119run: serve
120
121deps: node_deps
122 rm -f static/dist/*
123
124build_js:
125 $(WEBPACK_PATH) --mode=production
126
127clean_deps:
128 rm -rf node_modules
129
130node_deps:
131 npm ci --no-save
132
133dev_deps:
134 python -m pip install --no-deps -r requirements.dev.txt
135
136karma:
137 npx karma start --debug --coverage
138
139karma_debug:
140 npx karma start --debug
141
142pylint:
143 pylint -f parseable *py {$(PY_DIRS)}{/,/test/}*py
144
145py3lint:
146 pylint --py3k *py {$(PY_DIRS)}{/,/test/}*py
147
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100148deploy_dev: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000149 $(eval BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD))
150 @echo "---[Dev $(DEVID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200151 $(GAE_PY) upload --tag $(BRANCH_NAME) -A $(DEVID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000152
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100153# Build target used by LUCI CD and manual process to build frontend.
154build_frontend: clean_deps deps build_js
Copybara854996b2021-09-07 19:36:02 +0000155
156package_release:
157 rsync -aLK . $(TARDIR)/package
158
159
160
161lsbuilds:
162 gcloud builds list --filter="tags='monorail'"
163
164# AppEngine apps can be tested locally and in non-default versions upload to
165# the main app-id, but it is still sometimes useful to have a completely
166# separate app-id. E.g., for testing inbound email, load testing, or using
167# throwaway databases.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100168deploy_staging: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000169 @echo "---[Staging $(STAGEID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200170 $(GAE_PY) upload -A $(STAGEID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000171
172# This is our production server that users actually use.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100173deploy_prod: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000174 @echo "---[Deploying prod instance $(PRODID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200175 $(GAE_PY) upload -A $(PRODID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000176
177# Note that we do not provide a command-line way to make the newly-uploaded
178# version the default version. This is for two reasons: a) You should be using
179# your browser to confirm that the new version works anyway, so just use the
180# console interface to make it the default; and b) If you really want to use
181# the command line you can use gae.py directly.