Skip to content

Commit

Permalink
Merge pull request #112 from SEL-Columbia/0.3.9-dev
Browse files Browse the repository at this point in the history
update, fix portier error, fix security probs
  • Loading branch information
jmbott authored Aug 11, 2021
2 parents dbabf17 + bc96dea commit 546ab12
Show file tree
Hide file tree
Showing 17 changed files with 2,064 additions and 4,092 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "presets": [ "es2015" ] }
{ "presets": [ "@babel/preset-env" ] }
58 changes: 58 additions & 0 deletions .github/workflows/minigrid-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: full minigrid tests

on: [push]

jobs:

build:
name: Build
runs-on: ubuntu-latest

steps:
# downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v2
# setup latest firefox version
- name: Setup latest firefox
uses: browser-actions/setup-firefox@latest
# setup database
- name: Install postgresql
run: |
sudo apt-get install postgresql-13 libpq-dev
sudo service postgresql start
pg_isready
- name: Change from peer to md5 authentication
run: |
sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/13/main/pg_hba.conf
sudo service postgresql@13-main restart
- name: create the minigrid database
run: |
psql -U postgres -c 'create database minigrid;'
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev/requirements.txt
pip install -r requirements.txt
pip install coveralls
- name: Set up Node 14
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install node dependencies
run: |
npm install
node node_modules/webpack/bin/webpack.js --mode=production
- name: Analysing the code with flake8
run: |
flake8 .
- name: Analysing the code with pydocstyle
run: |
python3 -m pydocstyle .
- name: install xvfb
run: sudo apt-get install xvfb
- name: run xvfb for python tests
run: xvfb-run --server-args="-screen 0, 1280x1280x16" tests/python/coverage_run.sh
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM python:3.7
FROM python:3.9
COPY . /minigrid-server
WORKDIR /minigrid-server
RUN set -x \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& npm install \
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@ Shared Solar server

### Native

* make sure `postgresql` is installed and the service is running
* create the `minigrid` database if it doesn't already exist

```
% psql postgres
psql (13.3)
Type "help" for help.
postgres=# CREATE DATABASE minigrid;
CREATE DATABASE
```
$ python3.7 -m venv venv

* install the requirements and test the server

```
$ python3.9 -m venv venv
$ source venv/bin/activate
(venv) $ pip install -r requirements.txt -r dev/requirements.txt
(venv) $ ./dev/run.sh
Expand All @@ -15,8 +29,13 @@ Listening on port 8889
[I 170329 16:07:16 server:50] Application started
```

* view the webapp at `http://localhost:8889/`


### Docker

* make sure the docker daemon is running

```
$ docker-compose -f dev/docker-compose.yml up -d
$ docker-compose -f dev/docker-compose.yml ps
Expand All @@ -27,25 +46,33 @@ dev_minigrid_1 ./dev/run.sh --db_host=db ... Up 0.0.0.0:8889->8889/tcp
dev_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
```

* check the container logs if one fails to come up `docker logs <container name>`
* remove all stopped containers with `docker container prune`
* check you have removed old conflicting images, `docker rmi <image>`
* view the webapp at `http://localhost:8889/`


## Adding an initial user locally

Note that the login flow is quicker with a gmail.com e-mail address.


### Native

```
(venv) $ ./dev/commands.py create_user --kwarg email=<your_email_address>
Created user with e-mail your_email_address
```


### Docker

```
$ docker exec dev_minigrid_1 dev/commands.py create_user --db_host=db --kwarg email=<your_email_address>
Created user with e-mail your_email_address
```


## Restoring Database from backup

* download backup, from S3 or otherwise
Expand Down
6 changes: 3 additions & 3 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
version: '3.9'
services:
minigrid:
build:
Expand All @@ -13,9 +13,9 @@ services:
- redis
- db
db:
image: postgres:9.6
image: postgres:13
environment:
POSTGRES_DB: minigrid
POSTGRES_HOST_AUTH_METHOD: "trust"
redis:
image: redis:5.0
image: redis:6.2.5
14 changes: 7 additions & 7 deletions dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
codecov==2.0.22
fakeredis==1.4.0
flake8==3.7.9
pyflakes==2.1.1 # temporary requirement to make flake8 happy
pydocstyle==5.0.2
coverage==5.0.4
beautifulsoup4==4.9.0
codecov==2.1.12
fakeredis==1.5.2
flake8==3.9.2
pyflakes==2.3.1 # temporary requirement to make flake8 happy
pydocstyle==6.1.1
coverage==5.5
beautifulsoup4==4.9.3
selenium==3.141.0
2 changes: 1 addition & 1 deletion dev/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
echo "Installing dependencies..."
pip install -r requirements.txt 1&> /dev/null
npm install
node node_modules/webpack/bin/webpack.js
node node_modules/webpack/bin/webpack.js --mode=development
echo "Installing dependencies done"
python server.py \
--application_debug=True \
Expand Down
7 changes: 4 additions & 3 deletions minigrid/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def get(self):
def post(self):
"""Erase card."""
erase_card(self.session, cache)
self.redirect(f'/cards')
self.redirect('/cards')


class MinigridHandler(BaseHandler):
Expand Down Expand Up @@ -639,7 +639,7 @@ def post(self, minigrid_id):
.get(maintenance_card_id))
session.delete(maintenance_card)
message = (
f'Maintenance card'
'Maintenance card'
' {maintenance_card.maintenance_card_name} removed')
except UnmappedInstanceError:
message = 'The requested maintenance_card no longer exists'
Expand Down Expand Up @@ -709,7 +709,8 @@ async def post(self):
broker_url,
cache)
except ValueError as exc:
raise minigrid.error.LoginError(reason=str(exc))
raise minigrid.error.LoginError(
reason=f'ValueError: {exc}')
try:
user = (
self.session
Expand Down
Loading

0 comments on commit 546ab12

Please sign in to comment.