Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | # 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. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | # Makefile to simplify some common AppEngine actions. |
| 6 | # Use 'make help' for a list of commands. |
| 7 | |
| 8 | DEVID = monorail-dev |
| 9 | STAGEID= monorail-staging |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 10 | PRODID= avm99963-bugs |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 11 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 12 | GAE_PY?= vpython3 gae.py |
| 13 | DEV_APPSERVER_FLAGS?= --python_virtualenv_path venv --watcher_ignore_re="(.*/lib|.*/node_modules|.*/venv)" |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 14 | |
| 15 | WEBPACK_PATH := ./node_modules/webpack-cli/bin/cli.js |
| 16 | |
| 17 | TARDIR ?= "/workspace" |
| 18 | |
| 19 | FRONTEND_MODULES?= default |
| 20 | BACKEND_MODULES?= besearch latency-insensitive api |
| 21 | |
| 22 | BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD) |
| 23 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 24 | PY_DIRS = api,businesslogic,features,framework,project,mrproto,search,services,sitewide,testing,tracker |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 25 | |
| 26 | _VERSION ?= $(shell ../../../infra/luci/appengine/components/tools/calculate_version.py) |
| 27 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 28 | RUN_CLOUD_TASKS := ../../cipd/cloud-tasks-emulator \ |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 29 | --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 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 41 | default: help |
| 42 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 43 | help: |
| 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 |
| 48 | prpc_proto_v0: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 49 | PATH=../../luci/appengine/components/tools:$(PATH) \ |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 50 | ../../cipd/bin/protoc \ |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 51 | --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/ |
| 54 | prpc_proto_v3: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 55 | PATH=../../luci/appengine/components/tools:$(PATH) \ |
Adrià Vilanova Martínez | f5e1039 | 2021-12-07 22:55:40 +0100 | [diff] [blame] | 56 | ../../cipd/bin/protoc \ |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 57 | --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 | |
| 61 | business_proto: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 62 | PATH=../../luci/appengine/components/tools:$(PATH) \ |
| 63 | ../../cipd/protoc \ |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 64 | --python_out=. --prpc-python_out=. mrproto/*.proto |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 65 | |
| 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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 70 | serve: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 71 | @echo "---[Starting SDK AppEngine Server]---" |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 72 | $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS) 2>&1 | grep -a -v 'AccessTokenRefreshError' | grep -a -v 'csp.do' \ |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 73 | & $(WEBPACK_PATH) --watch\ |
| 74 | & $(RUN_CLOUD_TASKS) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 75 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 76 | serve_email: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 77 | @echo "---[Starting SDK AppEngine Server]---" |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 78 | $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True\ |
| 79 | & $(WEBPACK_PATH) --watch\ |
| 80 | & $(RUN_CLOUD_TASKS) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 81 | |
| 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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 84 | serve_remote: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 85 | @echo "---[Starting SDK AppEngine Server]---" |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 86 | $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS)\ |
| 87 | & $(WEBPACK_PATH) --watch\ |
| 88 | & $(RUN_CLOUD_TASKS) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 89 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 90 | serve_remote_email: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 91 | @echo "---[Starting SDK AppEngine Server]---" |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 92 | $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS) --enable_sendmail=True\ |
| 93 | & $(WEBPACK_PATH) --watch\ |
| 94 | & $(RUN_CLOUD_TASKS) |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 95 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 96 | jsdeps: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 97 | rm -rf node_modules |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 98 | npm ci --no-save |
| 99 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 100 | jsbuild: |
| 101 | rm -f static/dist/* |
| 102 | rm -f templates/webpack-out/* |
| 103 | $(WEBPACK_PATH) --mode=production |
| 104 | |
| 105 | jstest: |
| 106 | npx karma start --debug |
| 107 | |
| 108 | jstest_coverage: |
| 109 | npx karma start --debug --coverage |
| 110 | |
| 111 | pytest: |
| 112 | vpython3 test.py |
| 113 | |
| 114 | pylint: |
| 115 | pylint --py3k *py {$(PY_DIRS)}{/,/test/}*py |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 116 | |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 117 | generate_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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 121 | deploy_dev: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 122 | $(eval BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)) |
| 123 | @echo "---[Dev $(DEVID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 124 | $(GAE_PY) upload --tag $(BRANCH_NAME) -A $(DEVID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 125 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 126 | # Build target used by LUCI CD and manual process to build frontend. |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 127 | build_frontend: jsdeps jsbuild |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 128 | |
| 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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 133 | deploy_staging: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 134 | @echo "---[Staging $(STAGEID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 135 | $(GAE_PY) upload -A $(STAGEID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 136 | |
| 137 | # This is our production server that users actually use. |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 138 | deploy_prod: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 139 | @echo "---[Deploying prod instance $(PRODID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 140 | $(GAE_PY) upload -A $(PRODID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 141 | |
| 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. |