Skip to content

Commit c4c54d2

Browse files
authored
Merge branch 'develop' into housing-points
2 parents de9731d + 636dff4 commit c4c54d2

109 files changed

Lines changed: 6621 additions & 15800 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Dockerfile
22
.gitignore
3+
node_modules
4+
venv

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## What
2+
3+
_what the PR changes_
4+
5+
## Why
6+
7+
_why these changes were made_
8+
9+
## Test Plan
10+
11+
_how did you verify these changes did what you expected_
12+
13+
## Env Vars
14+
15+
_did you add, remove, or rename any environment variables_
16+
17+
## Checklist
18+
19+
- [ ] Tested all changes locally

.github/workflows/node-js.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
python-version: [3.8, 3.9]
18+
python-version: [3.12]
1919

2020
steps:
2121
- name: Install ldap dependencies

.github/workflows/sonarqube.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
9+
jobs:
10+
build:
11+
name: Build and analyze
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- uses: SonarSource/sonarqube-scan-action@v6
19+
env:
20+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
21+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.pylintrc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ disable =
99
duplicate-code,
1010
no-member,
1111
parse-error,
12-
bad-continuation,
1312
too-few-public-methods,
1413
global-statement,
1514
cyclic-import,
@@ -18,14 +17,11 @@ disable =
1817

1918
[REPORTS]
2019
output-format = text
21-
files-output = no
2220
reports = no
2321

2422
[FORMAT]
2523
max-line-length = 120
26-
max-statement-lines = 75
2724
single-line-if-stmt = no
28-
no-space-check = trailing-comma,dict-separator
2925
max-module-lines = 1000
3026
indent-string = ' '
3127

@@ -73,8 +69,6 @@ good-names=logger,id,ID
7369
# Bad variable names which should always be refused, separated by a comma
7470
bad-names=foo,bar,baz,toto,tutu,tata
7571

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

7973

8074
[DESIGN]
@@ -90,4 +84,4 @@ min-public-methods = 2
9084
max-public-methods = 20
9185

9286
[EXCEPTIONS]
93-
overgeneral-exceptions = Exception
87+
overgeneral-exceptions = builtins.Exception

Dockerfile

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
1-
FROM docker.io/python:3.8-buster
2-
MAINTAINER Devin Matte <matted@csh.rit.edu>
1+
FROM node:25-bookworm-slim AS build-frontend
32

43
RUN mkdir /opt/conditional
54

6-
ADD requirements.txt /opt/conditional
5+
WORKDIR /opt/conditional
6+
7+
RUN apt-get -yq update && \
8+
apt-get -yq install curl git
9+
10+
COPY package.json package-lock.json /opt/conditional/
11+
12+
RUN npm ci
13+
14+
COPY webpack.config.js /opt/conditional
15+
COPY frontend /opt/conditional/frontend
16+
17+
RUN npm run webpack
18+
19+
FROM docker.io/python:3.12-slim-bookworm
20+
MAINTAINER Computer Science House <webmaster@csh.rit.edu>
21+
22+
RUN mkdir /opt/conditional
23+
24+
COPY requirements.txt /opt/conditional
725

826
WORKDIR /opt/conditional
927

1028
RUN apt-get -yq update && \
11-
apt-get -yq install libsasl2-dev libldap2-dev libssl-dev gcc g++ make && \
29+
apt-get -yq install libsasl2-dev libldap2-dev libldap-common libssl-dev gcc g++ make && \
1230
pip install -r requirements.txt && \
1331
apt-get -yq clean all
1432

15-
ADD . /opt/conditional
33+
ARG PORT=8080
34+
ENV PORT=${PORT}
35+
EXPOSE ${PORT}
1636

17-
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
18-
apt-get -yq update && \
19-
apt-get -yq install nodejs && \
20-
npm install && \
21-
npm run production && \
22-
rm -rf node_modules && \
23-
apt-get -yq remove nodejs npm && \
24-
apt-get -yq clean all
37+
COPY conditional /opt/conditional/conditional
38+
COPY *.py package.json /opt/conditional
39+
COPY --from=build-frontend /opt/conditional/conditional/static /opt/conditional/conditional/static
2540

2641
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
2742

28-
CMD ["ddtrace-run", "gunicorn", "conditional:app", "--bind=0.0.0.0:8080", "--access-logfile=-", "--timeout=256"]
43+
CMD ["sh", "-c", "gunicorn"]
44+

README.md

Lines changed: 68 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,104 @@ A comprehensive membership evaluations solution for Computer Science House.
88
Development
99
-----------
1010

11-
To run the application, you must have the latest version of [Python 3](https://www.python.org/downloads/) and [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) installed. Once you have those installed, create a new virtualenv and install the Python dependencies:
11+
### Config
12+
13+
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.env.py` for an example.
1214

15+
#### Add OIDC Config
16+
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth
17+
```py
18+
# OIDC Config
19+
OIDC_ISSUER = "https://sso.csh.rit.edu/auth/realms/csh"
20+
OIDC_CLIENT_CONFIG = {
21+
'client_id': '',
22+
'client_secret': '',
23+
'post_logout_redirect_uris': ['http://0.0.0.0:6969/logout']
24+
}
1325
```
26+
27+
#### Database
28+
You can either develop using the dev database, or use the local database provided in the docker compose file
29+
30+
Using the local database is detailed below, but both options will require the dev database password, so you will have to ask an RTP for this too
31+
32+
### Run (Without Docker)
33+
34+
To run the application without using containers, you must have the latest version of [Python 3](https://www.python.org/downloads/) and [virtualenv](https://virtualenv.pypa.io/en/stable/installation/) installed. Once you have those installed, create a new virtualenv and install the Python dependencies:
35+
36+
```sh
1437
virtualenv .conditionalenv -p `which python3`
1538
source .conditionalenv/bin/activate
1639
pip install -r requirements.txt
17-
export FLASK_APP=app.py
1840
```
1941

20-
In addition, you must have Node, NPM, and Gulp CLI installed to properly execute the asset pipeline. If you don't have Node installed, we recommending installing with [NVM](https://github.com/creationix/nvm):
42+
In addition, you must have Node, NPM, and Weback CLI installed to properly execute the asset pipeline. If you don't have Node installed, we recommending installing with [NVM](https://github.com/creationix/nvm):
2143

22-
```
44+
```sh
2345
nvm install
2446
nvm use
25-
npm install -g gulp
47+
npm install -g webpack
2648
```
2749

28-
Then, install the pipeline and frontend dependencies:
50+
Then, install the pipeline and frontend dependencies: (do this in the `frontend` directory)
2951

30-
```
52+
```sh
3153
npm install
3254
```
3355

34-
### Config
56+
Once you have all of the dependencies installed, run
3557

36-
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.sample.py` for an example.
58+
```sh
59+
npm webpack
60+
```
3761

38-
#### Add OIDC Config
39-
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth
62+
This will build the frontend assets and put them in the correct place for use with flask
63+
64+
Finally, start the flask app with `gunicorn`
65+
66+
```sh
67+
gunicorn
4068
```
41-
# OIDC Config
42-
OIDC_ISSUER = "https://sso.csh.rit.edu/auth/realms/csh"
43-
OIDC_CLIENT_CONFIG = {
44-
'client_id': '',
45-
'client_secret': '',
46-
'post_logout_redirect_uris': ['http://0.0.0.0:6969/logout']
47-
}
69+
70+
or
71+
72+
```sh
73+
python -m gunicorn
4874
```
4975

50-
### Run
76+
### Run (containerized)
5177

52-
Once you have all of the dependencies installed, simply run:
78+
It is likely easier to use containers like `podman` or `docker` or the corresponding compose file
5379

54-
```
55-
npm start
80+
With podman, I have been using
81+
82+
```sh
83+
podman compose up --force-recreate --build
5684
```
5785

58-
This will run the asset pipeline, start the Python server, and start BrowserSync. Your default web browser will open automatically. If it doesn't, navigate to `http://127.0.0.1:3000`. Any changes made to the frontend files in `frontend` or the Jinja templates in `conditional/templates` will cause the browser to reload automatically.
86+
Which can be restarted every time changes are made
5987

6088
### Dependencies
6189

6290
To add new dependencies, add them to `requirements.in` and then run `pip-compile requirements.in` to produce a new locked `requirements.txt`. Do not edit `requirements.txt` directly as it will be overwritten by future PRs.
6391

92+
### Local database
93+
94+
You can run the database locally using the docker compose
95+
96+
To populate it with dev data for example, you can use the command
97+
98+
```sh
99+
PGPASSWORD='[DB PASSWORD]' pg_dump -h postgres.csh.rit.edu -p 5432 -U conditionaldev conditionaldev | PGPASSWORD='fancypantspassword' psql -h localhost -p 5432 -U conditional conditional
100+
```
101+
102+
This can be helpful for changing the database schema
103+
104+
To run migration commands in the local database, you can run the commands inside the docker container. Any migrations created will also be in the local repository since migrations are mounted in the docker compose
105+
```sh
106+
podman exec conditional flask db upgrade
107+
```
108+
64109
### Database Migrations
65110

66111
If the database schema is changed after initializing the database, you must migrate it to the new schema by running:

0 commit comments

Comments
 (0)