Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # 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 | |
| 9 | DEVID = monorail-dev |
| 10 | STAGEID= monorail-staging |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 11 | PRODID= avm99963-bugs |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 12 | |
| 13 | GAE_PY?= python gae.py |
| 14 | DEV_APPSERVER_FLAGS?= --watcher_ignore_re="(.*/lib|.*/node_modules|.*/third_party|.*/venv)" |
| 15 | |
| 16 | WEBPACK_PATH := ./node_modules/webpack-cli/bin/cli.js |
| 17 | |
| 18 | TARDIR ?= "/workspace" |
| 19 | |
| 20 | FRONTEND_MODULES?= default |
| 21 | BACKEND_MODULES?= besearch latency-insensitive api |
| 22 | |
| 23 | BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD) |
| 24 | |
| 25 | PY_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 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 29 | default: help |
| 30 | |
| 31 | check: |
| 32 | ifndef NPM_VERSION |
| 33 | $(error npm not found. Install from nodejs.org or see README) |
| 34 | endif |
| 35 | |
| 36 | help: |
| 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 |
| 41 | prpc_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/ |
| 49 | prpc_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ínez | f5e1039 | 2021-12-07 22:55:40 +0100 | [diff] [blame] | 53 | ../../cipd/bin/protoc \ |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 54 | --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 | |
| 58 | business_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 | |
| 65 | test: |
| 66 | ../../test.py test appengine/monorail |
| 67 | |
| 68 | test_no_coverage: |
| 69 | ../../test.py test appengine/monorail --no-coverage |
| 70 | |
| 71 | coverage: |
| 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. |
| 77 | test_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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 85 | serve: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 86 | @echo "---[Starting SDK AppEngine Server]---" |
| 87 | $(GAE_PY) devserver -A monorail-staging -- $(DEV_APPSERVER_FLAGS)& $(WEBPACK_PATH) --watch |
| 88 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 89 | serve_email: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 90 | @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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 95 | serve_remote: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 96 | @echo "---[Starting SDK AppEngine Server]---" |
| 97 | $(GAE_PY) devserver -A monorail-staging -o -- $(DEV_APPSERVER_FLAGS)& $(WEBPACK_PATH) --watch |
| 98 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 99 | serve_remote_email: |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 100 | @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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 103 | serve_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 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 119 | run: serve |
| 120 | |
| 121 | deps: node_deps |
| 122 | rm -f static/dist/* |
| 123 | |
| 124 | build_js: |
| 125 | $(WEBPACK_PATH) --mode=production |
| 126 | |
| 127 | clean_deps: |
| 128 | rm -rf node_modules |
| 129 | |
| 130 | node_deps: |
| 131 | npm ci --no-save |
| 132 | |
| 133 | dev_deps: |
| 134 | python -m pip install --no-deps -r requirements.dev.txt |
| 135 | |
| 136 | karma: |
| 137 | npx karma start --debug --coverage |
| 138 | |
| 139 | karma_debug: |
| 140 | npx karma start --debug |
| 141 | |
| 142 | pylint: |
| 143 | pylint -f parseable *py {$(PY_DIRS)}{/,/test/}*py |
| 144 | |
| 145 | py3lint: |
| 146 | pylint --py3k *py {$(PY_DIRS)}{/,/test/}*py |
| 147 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 148 | deploy_dev: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 149 | $(eval BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)) |
| 150 | @echo "---[Dev $(DEVID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 151 | $(GAE_PY) upload --tag $(BRANCH_NAME) -A $(DEVID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 152 | |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 153 | # Build target used by LUCI CD and manual process to build frontend. |
| 154 | build_frontend: clean_deps deps build_js |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 155 | |
| 156 | package_release: |
| 157 | rsync -aLK . $(TARDIR)/package |
| 158 | |
| 159 | |
| 160 | |
| 161 | lsbuilds: |
| 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ínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 168 | deploy_staging: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 169 | @echo "---[Staging $(STAGEID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 170 | $(GAE_PY) upload -A $(STAGEID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 171 | |
| 172 | # This is our production server that users actually use. |
Adrià Vilanova Martínez | 2d5457a | 2022-01-13 13:25:39 +0100 | [diff] [blame] | 173 | deploy_prod: build_frontend |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 174 | @echo "---[Deploying prod instance $(PRODID)]---" |
Adrià Vilanova Martínez | 515639b | 2021-07-06 16:43:59 +0200 | [diff] [blame] | 175 | $(GAE_PY) upload -A $(PRODID) $(FRONTEND_MODULES) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 176 | |
| 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. |