Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Linting and tests

on:
push:
branches: [master, mom/dev]
pull_request:
branches: [master, mom/dev]

jobs:
check:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.13]

steps:
- name: Install ldap dependencies
run: sudo apt-get update && sudo apt-get install libldap2-dev libsasl2-dev
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
mypy --non-interactive --install-types
- name: Lint with pylint
run: |
pylint app.py config.env.py eac
- name: Typecheck with mypy
run: |
mypy app.py config.env.py eac
- name: Format with yapf
run: |
yapf --diff -r app.py config.env.py eac

docker-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Build Image
run: |
docker build . --file Dockerfile
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
disable_error_code = import
disallow_untyped_defs = True
14 changes: 2 additions & 12 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,21 @@ disable =
duplicate-code,
no-member,
parse-error,
bad-continuation,
too-few-public-methods,
global-statement,
cyclic-import,
locally-disabled,
file-ignored

[REPORTS]
output-format = text
files-output = no
output-format = colorized
reports = no

[FORMAT]
max-line-length = 120
max-statement-lines = 75
single-line-if-stmt = no
no-space-check = trailing-comma,dict-separator
max-module-lines = 1000
indent-string = ' '
string-quote=single-avoid-escape
triple-quote=single
docstring-quote=double

[MISCELLANEOUS]
notes = FIXME,XXX,TODO
Expand Down Expand Up @@ -76,9 +69,6 @@ good-names=logger,id,ID
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata

# List of builtins function names that should not be used, separated by a comma
bad-functions=apply,input

[DESIGN]
max-args = 10
ignored-argument-names = _.*
Expand All @@ -92,4 +82,4 @@ min-public-methods = 2
max-public-methods = 20

[EXCEPTIONS]
overgeneral-exceptions = Exception
overgeneral-exceptions = builtins.Exception
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ RUN --mount=type=bind,source=requirements.txt,target=requirements.txt \
COPY . /opt/eac

RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
RUN git config --system --add safe.directory /opt/eac

ARG PORT=8080
ENV PORT=${PORT}
EXPOSE ${PORT}

CMD ["gunicorn app:application --bind=0.0.0.0:${PORT} --access-logfile=- --timeout=600"]
# --access-logfile - prints access log to stdout
# --error-log - prints errors to stdout
# --capture-output logging and print go to error log (stdout)
CMD ["sh", "-c", "gunicorn app:application --bind=0.0.0.0:${PORT} --access-logfile - --error-log - --capture-output --timeout=600"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ pip3 install -r requirements.txt

flask run -h localhost -p 5000
```

### Linting
```
# Install types
mypy --install-types

# Check linting
mypy app.py config.env.py eac
# Check Typing
pylint app.py config.env.py eac
# Format
yapf -ir app.py config.env.py eac
```
16 changes: 12 additions & 4 deletions config.env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
IP = os.environ.get('IP', '127.0.0.1')
PORT = os.environ.get('PORT', 5000)
SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000')
SECRET_KEY = os.environ.get('SESSION_KEY', default=''.join(secrets.token_hex(16)))
SECRET_KEY = os.environ.get('SESSION_KEY',
default=''.join(secrets.token_hex(16)))

# OpenID Connect SSO config
OIDC_ISSUER = os.environ.get('OIDC_ISSUER', 'https://sso.csh.rit.edu/auth/realms/csh')
OIDC_ISSUER = os.environ.get('OIDC_ISSUER',
'https://sso.csh.rit.edu/auth/realms/csh')
OIDC_CLIENT_CONFIG = {
'client_id': os.environ.get('OIDC_CLIENT_ID', ''),
'client_secret': os.environ.get('OIDC_CLIENT_SECRET', ''),
Expand All @@ -28,17 +30,23 @@
# GitHub secrets
GITHUB_CLIENT_ID = os.environ.get('GITHUB_ID', '')
GITHUB_SECRET = os.environ.get('GITHUB_SECRET', '')
ORG_TOKEN = os.environ.get('GITHUB_ORG_TOKEN', '')
GITHUB_APP_ID = os.environ.get('GITHUB_APP_ID', '')
GITHUB_APP_PRIVATE_KEY = os.environ.get('GITHUB_APP_PRIVATE_KEY', '')

# Twitch secrets
TWITCH_CLIENT_ID = os.environ.get('TWITCH_CLIENT_ID', '')
TWITCH_CLIENT_SECRET = os.environ.get('TWITCH_CLIENT_SECRET', '')

# Twitter secrets
TWITTER_CONSUMER_KEY = os.environ.get('TWITTER_OAUTH_CONSUMER_KEY', '')
TWITTER_CONSUMER_SECRET_KEY = os.environ.get('TWITTER_OAUTH_CONSUMER_SECRET_KEY', '')
TWITTER_CONSUMER_SECRET_KEY = os.environ.get(
'TWITTER_OAUTH_CONSUMER_SECRET_KEY', '')
TWITTER_TOKEN = os.environ.get('TWITTER_OAUTH_TOKEN', '')
TWITTER_TOKEN_SECRET = os.environ.get('TWITTER_OAUTH_TOKEN_SECRET', '')

# Common secrets
STATE = os.environ.get('STATE', 'auth')

# Connection controls
REQUEST_TIMEOUT = os.environ.get("EAC_REQUEST_TIMEOUT",
60) # default to a minute timeout
Loading