Skip to content

Commit

Permalink
Merge branch 'main' into dev-issue-25
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpyWasHere authored Jan 13, 2025
2 parents a36eef6 + 2ba2e46 commit 057e405
Show file tree
Hide file tree
Showing 50 changed files with 1,579 additions and 992 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/alembic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Alembic Upgrade Head
on: pull_request

jobs:
alembic_upgrade_head:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U runner"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: runner
POSTGRES_DB: main
POSTGRES_HOST_AUTH_METHOD: trust

steps:
- uses: actions/checkout@v4

- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432 -U runner; do
echo "Waiting for PostgreSQL..."
sleep 1
done
- name: Install dependencies
run: |
# for python3.11 (dear internet gods: we'll update to 3.13 or something in a year, i promise)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.11 python3.11-venv
python3.11 -m pip install --upgrade pip
python3.11 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
# This will fail if there are divergent heads and alembic gets confused;
# e.g., un-sanitarily merging main into a dev branch.
- name: Run alembic upgrade head
run: |
source ./venv/bin/activate
cd src
alembic upgrade head
4 changes: 2 additions & 2 deletions .github/workflows/pytest_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Unit Tests
on: pull_request

jobs:
test:
unit_tests:
runs-on: ubuntu-latest
timeout-minutes: 5

Expand Down Expand Up @@ -31,4 +31,4 @@ jobs:
- name: Run unit tests
run: |
source ./venv/bin/activate
pytest ./tests/unit -v
pytest ./tests/unit -v
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ jobs:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
version: 0.4.4
version: 0.6.9
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ google_key.json
__pycache__/
*.py[cod]
*$py.class

.venv
.DS_Store
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The backend & REST API for the CSSS website. Anything the website frontend does

## Local Development

See [the csss-backend wiki](https://github.com/CSSS/csss-site-backend/wiki/Local-Setup) for details on how to run the REST API locally on your own machine.
See [the csss-backend wiki](https://github.com/CSSS/csss-site-backend/wiki/1.-Local-Setup) for details on how to run the REST API locally on your own machine.

If you're planning to read through the source code, please check out this project's [naming conventions](https://github.com/CSSS/csss-site-backend/wiki/Naming-conventions).
If you're planning to read through the source code, please check out this project's [naming conventions](https://github.com/CSSS/csss-site-backend/wiki/Style-Guide#naming-conventions).

## Important Directories

Expand All @@ -25,3 +25,7 @@ If you're planning to read through the source code, please check out this projec
- `misc/` for anything that can't be easily categorized or is very small
- `officers/` for officer contact information + photos
- `test/` for html pages which interact with the backend's local api

## Linter

We use `ruff 0.6.9` as our linter, which you can run with `ruff check --fix`. If you use a different version, it may be inconsistent with our CI checks.
1 change: 0 additions & 1 deletion config/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
# run the daily script at 1am every morning
# TODO: make sure timezone is PST
crontab -l | { cat; echo "0 1 * * * /home/csss-site/csss-site-backend/src/cron/daily.py"; } | crontab -

14 changes: 0 additions & 14 deletions config/csss-site.service

This file was deleted.

10 changes: 0 additions & 10 deletions config/export_secrets.sh

This file was deleted.

30 changes: 0 additions & 30 deletions config/nginx.conf

This file was deleted.

2 changes: 0 additions & 2 deletions config/sudoers.conf

This file was deleted.

28 changes: 0 additions & 28 deletions config/update_config.sh

This file was deleted.

8 changes: 0 additions & 8 deletions deploy.sh

This file was deleted.

135 changes: 0 additions & 135 deletions fresh_setup.sh

This file was deleted.

12 changes: 6 additions & 6 deletions gunicorn_start.sh → junicorn_start_dev.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash

NAME=csss-site
DIR=/home/csss-site/csss-site-backend/src
USER=csss-site
GROUP=csss-site
DIR= # fill this out yourself
USER= # fill this out yourself
GROUP= # fill this out yourself
WORKERS=2 # TODO: should we increase this?
WORKER_CLASS=uvicorn.workers.UvicornWorker
VENV=/home/csss-site/.venv/bin/activate
BIND=unix:/var/www/gunicorn.sock
VENV= # fill this out yourself
BIND= # e.g., unix:/var/www/gunicorn.sock
LOG_LEVEL=error

cd $DIR
source $VENV

exec gunicorn main:app \
gunicorn main:app \
--name $NAME \
--workers $WORKERS \
--worker-class $WORKER_CLASS \
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# major
fastapi==0.109.1
fastapi==0.115.6
gunicorn==21.2.0
uvicorn[standard]==0.27.1
sqlalchemy==2.0.27
sqlalchemy[asyncio]==2.0.27
asyncpg==0.29.0
alembic==1.13.1
google-api-python-client==2.143.0
Expand All @@ -13,9 +13,10 @@ xmltodict==0.13.0 # for parsing responses from sfu it's auth api
requests==2.31.0

# dev
ruff
ruff==0.6.9
# pre-commit

# test
pytest
pytest-asyncio
httpx
Empty file added src/__init__.py
Empty file.
Loading

0 comments on commit 057e405

Please sign in to comment.