blob: 899d34c4dc5d60da5c345e113e009d5d70d4ab1d [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# Copyright 2016 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
Copybara854996b2021-09-07 19:36:02 +00004
5# Makefile to simplify some common AppEngine actions.
6# Use 'make help' for a list of commands.
7
8DEVID = monorail-dev
9STAGEID= monorail-staging
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +020010PRODID= avm99963-bugs
Copybara854996b2021-09-07 19:36:02 +000011
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010012GAE_PY?= vpython3 gae.py
13DEV_APPSERVER_FLAGS?= --python_virtualenv_path venv --watcher_ignore_re="(.*/lib|.*/node_modules|.*/venv)"
Copybara854996b2021-09-07 19:36:02 +000014
15WEBPACK_PATH := ./node_modules/webpack-cli/bin/cli.js
16
17TARDIR ?= "/workspace"
18
19FRONTEND_MODULES?= default
20BACKEND_MODULES?= besearch latency-insensitive api
21
22BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
23
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010024PY_DIRS = api,businesslogic,features,framework,project,mrproto,search,services,sitewide,testing,tracker
Copybara854996b2021-09-07 19:36:02 +000025
26_VERSION ?= $(shell ../../../infra/luci/appengine/components/tools/calculate_version.py)
27
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020028RUN_CLOUD_TASKS := ../../cipd/cloud-tasks-emulator \
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020029 --queue projects/monorail-staging/locations/us-central1/queues/default \
30 --queue projects/monorail-staging/locations/us-central1/queues/notifications \
31 --queue projects/monorail-staging/locations/us-central1/queues/outboundemail \
32 --queue projects/monorail-staging/locations/us-central1/queues/recomputederivedfields \
33 --queue projects/monorail-staging/locations/us-central1/queues/spamexport \
34 --queue projects/monorail-staging/locations/us-central1/queues/wipeoutsendusers \
35 --queue projects/monorail-staging/locations/us-central1/queues/wipeoutdeleteusers \
36 --queue projects/monorail-staging/locations/us-central1/queues/deleteusers \
37 --queue projects/monorail-staging/locations/us-central1/queues/pubsub-issueupdates \
38 -host localhost \
39 -port 9090
40
Copybara854996b2021-09-07 19:36:02 +000041default: help
42
Copybara854996b2021-09-07 19:36:02 +000043help:
44 @echo "Available commands:"
45 @sed -n '/^[a-zA-Z0-9_.]*:/s/:.*//p' <Makefile
46
47# Run "eval `../../go/env.py`" before running the following prpc_proto commands
48prpc_proto_v0:
Copybara854996b2021-09-07 19:36:02 +000049 PATH=../../luci/appengine/components/tools:$(PATH) \
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020050 ../../cipd/bin/protoc \
Copybara854996b2021-09-07 19:36:02 +000051 --python_out=. --prpc-python_out=. api/api_proto/*.proto
52 cd ../../go/src/infra/monorailv2 && \
53 cproto -proto-path ../../../../appengine/monorail/ ../../../../appengine/monorail/api/api_proto/
54prpc_proto_v3:
Copybara854996b2021-09-07 19:36:02 +000055 PATH=../../luci/appengine/components/tools:$(PATH) \
Adrià Vilanova Martínezf5e10392021-12-07 22:55:40 +010056 ../../cipd/bin/protoc \
Copybara854996b2021-09-07 19:36:02 +000057 --python_out=. --prpc-python_out=. api/v3/api_proto/*.proto
58 cd ../../go/src/infra/monorailv2 && \
59 cproto -proto-path ../../../../appengine/monorail/ ../../../../appengine/monorail/api/v3/api_proto/
60
61business_proto:
Copybara854996b2021-09-07 19:36:02 +000062 PATH=../../luci/appengine/components/tools:$(PATH) \
63 ../../cipd/protoc \
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010064 --python_out=. --prpc-python_out=. mrproto/*.proto
Copybara854996b2021-09-07 19:36:02 +000065
66# Commands for running locally using dev_appserver.
67# devserver requires an application ID (-A) to be specified.
68# We are using `-A monorail-staging` because ml spam code is set up
69# to impersonate monorail-staging in the local environment.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010070serve:
Copybara854996b2021-09-07 19:36:02 +000071 @echo "---[Starting SDK AppEngine Server]---"
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020072 $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS) 2>&1 | grep -a -v 'AccessTokenRefreshError' | grep -a -v 'csp.do' \
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020073 & $(WEBPACK_PATH) --watch\
74 & $(RUN_CLOUD_TASKS)
Copybara854996b2021-09-07 19:36:02 +000075
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010076serve_email:
Copybara854996b2021-09-07 19:36:02 +000077 @echo "---[Starting SDK AppEngine Server]---"
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020078 $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True\
79 & $(WEBPACK_PATH) --watch\
80 & $(RUN_CLOUD_TASKS)
Copybara854996b2021-09-07 19:36:02 +000081
82# The _remote commands expose the app on 0.0.0.0, so that it is externally
83# accessible by hostname:port, rather than just localhost:port.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010084serve_remote:
Copybara854996b2021-09-07 19:36:02 +000085 @echo "---[Starting SDK AppEngine Server]---"
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020086 $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS)\
87 & $(WEBPACK_PATH) --watch\
88 & $(RUN_CLOUD_TASKS)
Copybara854996b2021-09-07 19:36:02 +000089
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010090serve_remote_email:
Copybara854996b2021-09-07 19:36:02 +000091 @echo "---[Starting SDK AppEngine Server]---"
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020092 $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True\
93 & $(WEBPACK_PATH) --watch\
94 & $(RUN_CLOUD_TASKS)
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +010095
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +010096jsdeps:
Copybara854996b2021-09-07 19:36:02 +000097 rm -rf node_modules
Copybara854996b2021-09-07 19:36:02 +000098 npm ci --no-save
99
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +0100100jsbuild:
101 rm -f static/dist/*
102 rm -f templates/webpack-out/*
103 $(WEBPACK_PATH) --mode=production
104
105jstest:
106 npx karma start --debug
107
108jstest_coverage:
109 npx karma start --debug --coverage
110
111pytest:
112 vpython3 test.py
113
114pylint:
115 pylint --py3k *py {$(PY_DIRS)}{/,/test/}*py
Copybara854996b2021-09-07 19:36:02 +0000116
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +0200117generate_requirements_txt:
118 vpython3 -m pip freeze > requirements.txt
119 printf "# This file is generated from the .vpython3 spec file.\n# Use \`make generate_requirements_txt\` to update.\n$$(cat requirements.txt)" > requirements.txt
120
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100121deploy_dev: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000122 $(eval BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD))
123 @echo "---[Dev $(DEVID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200124 $(GAE_PY) upload --tag $(BRANCH_NAME) -A $(DEVID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000125
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100126# Build target used by LUCI CD and manual process to build frontend.
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +0100127build_frontend: jsdeps jsbuild
Copybara854996b2021-09-07 19:36:02 +0000128
129# AppEngine apps can be tested locally and in non-default versions upload to
130# the main app-id, but it is still sometimes useful to have a completely
131# separate app-id. E.g., for testing inbound email, load testing, or using
132# throwaway databases.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100133deploy_staging: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000134 @echo "---[Staging $(STAGEID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200135 $(GAE_PY) upload -A $(STAGEID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000136
137# This is our production server that users actually use.
Adrià Vilanova Martínez2d5457a2022-01-13 13:25:39 +0100138deploy_prod: build_frontend
Copybara854996b2021-09-07 19:36:02 +0000139 @echo "---[Deploying prod instance $(PRODID)]---"
Adrià Vilanova Martínez515639b2021-07-06 16:43:59 +0200140 $(GAE_PY) upload -A $(PRODID) $(FRONTEND_MODULES)
Copybara854996b2021-09-07 19:36:02 +0000141
142# Note that we do not provide a command-line way to make the newly-uploaded
143# version the default version. This is for two reasons: a) You should be using
144# your browser to confirm that the new version works anyway, so just use the
145# console interface to make it the default; and b) If you really want to use
146# the command line you can use gae.py directly.