crazyrex / playhvz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This is not an official Google product.

Icon made by Freepik from www.flaticon.com

Humans vs Zombies

Full stack solution leveraging Firebase, Polymer, and a Python Flask server on App Engine to create a live action game. Learn more at https://humansvszombies.org/

Contributing

Pull requests very welcome and encouraged, to help you get started we have broken it down to the level you want to test against. As mentioned in CONTRIBUTING.md, we do need you to submit a CLA first, but that should be an easy process.

Local Development

You may run against the fake JS server (do nothing), run against production, or create your own Firebase project.

Quick Start

Clone this project and follow the setup section if you are missing any dependencies

cd web
npm install
bower install
./node_modules/firebase-tools/bin/firebase login
./node_modules/firebase-tools/bin/firebase use --add trogdors-29fa4

If the last line fails with an "Invalid project selection" error, then run ./node_modules/firebase-tools/bin/firebase login to make sure you are logged in using the right account.

Copy the first relevant part of web/config_.json to web/config.json (i.e., remove the underscore)

npm start

Visit localhost:5000

Stop your webserver via Ctrl-C to abort

Installing a Polymer component

Run bower install paper-button under web directory

Running against prod

  1. Copy the first relevant part of web/config_.json to web/config.json (i.e., remove the underscore)
  2. Restart your web server
  3. Go to localhost:5000/?bridge=remote

Your own Firebase project and backend

These are one time firebase setup instructions along with backend configuration

Front End (/web)

  1. Change config.json's backendUrl to be "http://localhost:8080/"

  2. Create a firebase project

  3. Open authentication using the left hand pane and enable (1) Google and (2) Email/Password

  4. Open the users tab, create 8 users listed below

    Use the same password (write it down, you'll need it if you want to run webdrivers)

  5. Hit the copy button next to zella's name and put that into your config.py and config.json

    Repeat for the remaining seven fake users.

  6. In Firebase, open the web config and have these values ready to copy into the config.json file

  7. In your project make a new web/config.json file, similar to the examples in web/config_.json and copy over the values

  8. Run ./node_modules/firebase-tools/bin/firebase use --add ...your project...

(If this command fails with an "Invalid project selection" error, then run ./node_modules/firebase-tools/bin/firebase login to make sure you are logged in using the right account.)

  1. Restart your development environment and visit localhost:5000/?bridge=remote
Fake Users
zella@playhvz.com
deckerd@playhvz.com
zeke@playhvz.com
moldavi@playhvz.com
jack@playhvz.com
minny@playhvz.com
reggie@playhvz.com
drake@playhvz.com

Back End (/backend)

  1. Open your Firebase account page and use the gear icon to select the settings
  2. Make a copy of config_.py and name it config.py (remove the underscore)
  3. Back in Firebase copy your webconfig and place a copy into your newly created config.py
  4. Click on the Service Accounts tab and navigate to the Database Secrets sub tab.
  5. Show your the secrets key and copy it over for the FIREBASE_SECRET value in config.py.
  6. You can now run your server with dev_appserver.py app.yaml
  7. You can also navigate your front end to use this server with localhost:5000/?bridge=remote as long as you setup your front end config's backend URL (config.json)

Setup

Front End

Install Node and NPM https://www.npmjs.com/get-npm

Mac - webdriver tests

Add this to your ~/.bash_profile: export PATH=$PATH:[ghvz folder path here]/web/tests/macdrivers for example: export PATH=$PATH:/Users/verdagon/Desktop/ghvz/web/tests/macdrivers

source ~/.bash_profile

(continue in the common section below)

Linux - webdriver tests

Navigate to web/tests/linuxdrivers. Run chmod +x chromedriver to make the chromedriver executable.

Note: If the default chromedriver does not work, you can download the latest version here.

Add this to your ~/.bashrc: export PATH=$PATH:[ghvz folder path here]/web/tests/linuxdrivers for example: export PATH=$PATH:/Users/verdagon/Desktop/ghvz/web/tests/linuxdrivers

(continue in the common section below)

Front End common

cd web/tests
pip install selenium

Back End

Linux

sudo goobuntu-add-repo -e cloud-sdk-trusty
sudo apt-get update
sudo apt-get install google-cloud-sdk
sudo apt-get install google-cloud-sdk-app-engine-python

(continue in the common section below)

Mac

  1. Go to https://cloud.google.com/appengine/downloads
  2. Click Python
  3. Click DOWNLOAD AND INSTALL THE CLOUD SDK
  4. Download and install that SDK.

(continue in the common section below)

Back End Common

cd backend
gcloud init

Set project to humansvszombies-24348 (You should have access to this, but if you don't see this or don't have access to this, ask someone on the team)

pip install -r requirements.txt -t lib

Copy config_.py to config.py

If you're running your server against the prod firebase instance, replace FIREBASE_SECRET with the key from https://console.firebase.google.com/project/trogdors-29fa4/settings/serviceaccounts/databasesecrets and replace the FIREBASE_CONFIG map with the map from clicking on "Web Setup" link at https://console.firebase.google.com/u/0/project/trogdors-29fa4/authentication

Start up the local server with dev_appserver.py app.yaml

Testing

Front End

Make sure you have webdriver setup by following instructions in the setup section above

First, start up your local server; the webdrivers assume something is running at localhost:5000

To run the webdrivers:

cd web/tests

python run.py --p PASSWORD [--url TARGET_URL] [SPECIFIC_TEST_NAMES] [-d|m] [-l|r] [-s|-max MAX_PARALLEL] [-cp NEW_PASSWORD] [-cmp MAX_PARALLEL] [-rr] [-rf]

Replacing ALLCAPS'd segments with your values.

  • PASSWORD is the password for your fake account. To get passwords for fake test accounts, please ask someone on the team.
  • SPECIFIC_TEST_NAMES maps to test file names, minus the .py. This list of tests may have any number of elements. If no tests are specified, by default all are run.
  • If the first element in SPECIFIC_TEST_NAMES is not, all tests will be run EXCEPT those specified
  • -d uses desktop window sizing. Omitting this flag will run with mobile sizing instead.
  • -m uses mobile window sizing (default behavior).
  • -l indicates local server testing, and will rely on in-memory state rather than a database. User accounts defined in config.json will be used for tests.
  • -r indicates remote server testing, and will use your firebase and user account settings from config.json.
  • -s runs the tests sequentially (rather than in parallel)
  • -max specifies the maximum number of tests which can be run in parallel at a time (default is 3)
  • -cp changes the default password if the password flag is not provided.
  • -cmp changes maxParallel default - the default number of tests which will run together at a time
  • -rr reruns the same tests run last time run.py was run
  • -rf reruns tests that failed the last time run.py was run

Note: Bracketed segments are optional.

Back End

WARNING: This test will nuke our prod firebase. This is fine, everyone knows that that data could disappear at any moment. Though if two people run this test at the same time, it could fail. There's an open task on go/hvz-milestones (#201) to fix these particular inconveniences.

First, get a local backend server running. Then:

cd backend/
pip install requests
python backend_test.py

Deploying to Prod

Deploying back end

To launch a new version (once you have gcloud hooked in to the right app engine account):

gcloud app deploy app.yaml cron.yaml queue.yaml

Set up Firebase

  • This is for historical reasons only, you should never need to do this.
  • firebase init
  • (left database, functions, and hosting all checked, hit enter)
  • selected Zeds
  • let it use database.rules.json
  • let it install dependencies
  • for public directory, put client/
  • when it asks about single page app, say no

./node_modules/firebase-tools/bin/firebase use --add trogdors-29fa4 (make sure you have the access to this project)

./node_modules/firebase-tools/bin/firebase deploy

About

License:Apache License 2.0


Languages

Language:HTML 44.3%Language:Python 32.3%Language:JavaScript 19.5%Language:Java 2.1%Language:Swift 1.6%Language:Shell 0.2%Language:Ruby 0.0%