Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade major version to 3 #402

Merged
merged 84 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f94cc1c
Fix INTERNAL_IPS to support container
injoonH Jan 8, 2023
9387216
Merge pull request #377 from sparcs-kaist/refactor/djdt-container
injoonH Apr 6, 2023
2eea1c6
Optimize Dockerfile
TriangleYJ Apr 1, 2023
ee78884
Merge pull request #382 from sparcs-kaist/feature/action-bap
injoonH Apr 6, 2023
ab0d39c
Format article model following Django coding style
injoonH May 4, 2023
1de5fd4
Change BoardNameType to NameType
retroinspect May 10, 2023
5578d1d
Add Article.topped_at field
injoonH May 11, 2023
086a9dd
Format board model following Django coding style
injoonH May 11, 2023
e93a3dd
Add Board.top_threshold field
injoonH May 11, 2023
4a3774e
Top an article when positive count > threshold
injoonH May 11, 2023
da8a28f
Add endpoints & Edit admin view
injoonH May 11, 2023
7af4c89
Fix to let client set name_type of article
retroinspect May 18, 2023
627ab0f
Update test according to API updates
retroinspect May 18, 2023
40f4c0f
Refactor to seperate tests
retroinspect May 18, 2023
6b096f0
Update manual migration script atomic & add author
retroinspect May 18, 2023
d764cad
Update github action config
retroinspect May 25, 2023
8989178
Merge pull request #384 from sparcs-kaist/feature/integrate-talk
retroinspect May 25, 2023
acbd067
Update Django to 4.2
retroinspect May 25, 2023
d276b99
Update python version
retroinspect May 25, 2023
5b059cf
Update mysql version to 8.0
retroinspect May 25, 2023
443bc45
Order top articles
injoonH Jun 21, 2023
fb4d0ec
Update magic numbers to http status codes
injoonH Jun 21, 2023
eff817b
Move the test user generator function to utils
injoonH Jun 21, 2023
e449462
Add single test user generator
injoonH Jun 21, 2023
ffa47bd
Update run.sh
TriangleYJ Jun 25, 2023
432a239
Merge pull request #387 from sparcs-kaist/dx-patch-1
TriangleYJ Jun 25, 2023
eaa3db8
Add tests for top articles
injoonH Jun 28, 2023
b041006
Wrap docstring
injoonH Jun 28, 2023
a99c25f
Merge branch 'develop' into feat/top-articles
injoonH Jul 2, 2023
7f51f7e
Fix BoardNameType to NameType
injoonH Jul 2, 2023
f53e72d
Fix migration numberings
injoonH Jul 2, 2023
5d8937a
Merge pull request #385 from sparcs-kaist/feat/top-articles
injoonH Jul 2, 2023
15c4057
Upgrade python version to 3.11
injoonH Jul 2, 2023
c54c253
Refactor .editorconfig
injoonH Jul 3, 2023
48596b1
Alter rest_framework_filters using django_filters
injoonH Jul 3, 2023
6361774
Alter drf_yasg using drf_spectacular
injoonH Jul 3, 2023
94a6a40
Import cached_property from django
injoonH Jul 3, 2023
2752291
Remove UserProfile.extra_preferences
injoonH Jul 4, 2023
c6a7398
Use django.db.models.JSONField
injoonH Jul 4, 2023
ba9e502
Remove unused user related serializers
injoonH Jul 4, 2023
646edc4
Use rest_framework.filters for OrderingFilter
injoonH Jul 4, 2023
6d1f57e
Fix sanitizer frozenset tags union
injoonH Jul 4, 2023
4166288
Refactor deprecated dependancies
injoonH Jul 4, 2023
549790e
Use pipenv for package management
injoonH Jul 4, 2023
3f5c3e5
Remove venv legacy
injoonH Jul 4, 2023
787583f
Merge branch 'develop' into refactor/upgrades
injoonH Jul 4, 2023
cc36342
Use DJANGO_ENV for tests
injoonH Jul 5, 2023
6f062ec
Install pipenv in Dockerfile
injoonH Jul 5, 2023
58ba908
Add CSRF_TRUSTED_ORIGINS
TriangleYJ Jul 5, 2023
e707cd1
Update CSRF trusted origins
injoonH Jul 5, 2023
8e2c499
remove venv in run.sh
TriangleYJ Jul 7, 2023
27a9aca
remove venv in run.sh
TriangleYJ Jul 7, 2023
0d7a126
Fix swagger & redoc
injoonH Jul 10, 2023
4a9793f
Fix real name handling logic
injoonH Jul 10, 2023
bfabefb
Remove PyOTP
injoonH Jul 10, 2023
97e612d
Fix portal crawler
injoonH Jul 10, 2023
c839f17
Remove unused AWS SES
injoonH Jul 10, 2023
2b25626
Add user profile sso info's default value
injoonH Jul 10, 2023
f34f493
Squash user profile migration files
injoonH Jul 12, 2023
9f5ed57
Bring back django-ses
injoonH Jul 12, 2023
a70f392
Merge pull request #388 from sparcs-kaist/refactor/upgrades
injoonH Jul 12, 2023
f8f65ef
Remove board descriptions
injoonH Jul 17, 2023
1534028
Remove topic descriptions & Merge migrations
injoonH Jul 17, 2023
099b522
Remove schema.yml file
injoonH Jul 17, 2023
9efd9e7
Refactor board & topic serializers
injoonH Jul 17, 2023
6778ff2
Remove typing Union & Optional
injoonH Jul 19, 2023
adda79a
Specify pyyaml version to 5.3.1
injoonH Jul 20, 2023
f331773
Merge pull request #391 from sparcs-kaist/refactor/serializers
injoonH Jul 21, 2023
1280b5e
Add board slug to article filter parameter
injoonH Jul 21, 2023
e01792d
Merge pull request #392 from sparcs-kaist/feat/article-filter
injoonH Jul 21, 2023
92de15c
Use slug for board detail lookup
injoonH Jul 21, 2023
77dc579
Merge pull request #393 from sparcs-kaist/feat/board-detail-slug
injoonH Jul 21, 2023
42ad47b
feat(board): rm banner url & make desc not null
injoonH Jul 21, 2023
c6c7f84
feat(board): add board group model
injoonH Jul 21, 2023
f7a53a5
feat(board): set board group as foreign key
injoonH Jul 22, 2023
7702f71
docs(readme): update readme pipenv
injoonH Jul 23, 2023
5c34129
feat(board): add board group serializer & viewset
injoonH Jul 24, 2023
285132f
Merge pull request #395 from sparcs-kaist/feat/board-group
injoonH Jul 24, 2023
ffa36c7
feat(board): use detail serializer for GET method
injoonH Jul 24, 2023
a92c4a1
Merge pull request #396 from sparcs-kaist/feat/board-detail
injoonH Jul 24, 2023
fbaec44
fix(comment): allow admin post anonymous comments
injoonH Jul 26, 2023
484c4b2
Merge pull request #398 from sparcs-kaist/fix/admin-anonymous-comment
injoonH Jul 26, 2023
537cc86
feat(article): include attachments details
injoonH Jul 31, 2023
e33c15f
Merge pull request #400 from sparcs-kaist/feat/attachments
injoonH Jul 31, 2023
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
20 changes: 14 additions & 6 deletions .docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

set -ex

Expand All @@ -19,12 +19,20 @@ done


if [ "$1" = "test" ]; then
venv/bin/python manage.py compilemessages -l en -l ko
venv/bin/pytest tests --verbose
python3 manage.py compilemessages -l en -l ko
pytest tests --verbose
elif [ "$1" = "dx" ]; then
if [ ! -f .init.lock.log ]; then
python manage.py collectstatic --noinput
python manage.py migrate --no-input
python manage.py compilemessages -l en -l ko
touch .init.lock.log
fi
sleep infinity
else
venv/bin/python manage.py collectstatic --noinput
venv/bin/python manage.py migrate --no-input
venv/bin/python manage.py compilemessages -l en -l ko
python3 manage.py collectstatic --noinput
python3 manage.py migrate --no-input
python3 manage.py compilemessages -l en -l ko
ln -s /newara/www/.docker/supervisor-app.conf /etc/supervisor/conf.d/ || true
exec supervisord -n
fi
4 changes: 2 additions & 2 deletions .docker/supervisor-app.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[program:gunicorn]
command=/newara/www/venv/bin/gunicorn -b 0.0.0.0:9000 -w 3 --timeout 120 ara.wsgi:application
command=gunicorn -b 0.0.0.0:9000 -w 3 --timeout 120 ara.wsgi:application
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:celery-beat]
command=/newara/www/venv/bin/celery -A ara beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
command=celery -A ara beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
directory=/newara/www
stdout_logfile=/var/log/newara/celery-beat.log
stderr_logfile=/var/log/newara/celery-beat.log
2 changes: 1 addition & 1 deletion .docker/supervisor-celery-worker.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:celery-worker]
command = /newara/www/venv/bin/celery -A ara worker -l info
command=celery -A ara worker -l info
directory=/newara/www
stdout_logfile=/var/log/newara/celery-worker.log
stderr_logfile=/var/log/newara/celery-worker.log
17 changes: 6 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Set default charset
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[.env]
insert_final_newline = false

# 4 space indentation
[*.py]
indent_size = 4
indent_style = space
indent_size = 4

[.env]
insert_final_newline = false
12 changes: 6 additions & 6 deletions .github/workflows/generate-docker-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ if [ ! -z $GITHUB_REF ]; then
export PUSH=true
if [ $NAME = "master" ]; then
export DOCKER_TAG=prod
export CACHE_DOCKER_TAG=prod
export DJANGO_ENV=production
echo $FIREBASE_SERVICE_ACCOUNT_KEY_PROD > firebaseServiceAccountKey.json
elif [ $NAME = "develop" ]; then
# Docker tag에 /가 들어갈 수 없어서 -로 변경
export DOCKER_TAG=develop
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json
else
export DOCKER_TAG=manual
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
export PUSH=true
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json
fi
elif [ $TRIGGER_TYPE = "tags" ]; then
export PUSH=true
export DOCKER_TAG=$NAME
export CACHE_DOCKER_TAG=prod
export DJANGO_ENV=production
echo $FIREBASE_SERVICE_ACCOUNT_KEY_PROD > firebaseServiceAccountKey.json

elif [ $TRIGGER_TYPE = "pull" ]; then
export PUSH=true
export DOCKER_TAG="pr$NAME"
export CACHE_DOCKER_TAG=develop
export DJANGO_ENV=development
echo $FIREBASE_SERVICE_ACCOUNT_KEY_DEV > firebaseServiceAccountKey.json

fi
fi

echo $PUSH $TRIGGER_TYPE $CACHE_DOCKER_TAG $DOCKER_TAG
echo $PUSH $TRIGGER_TYPE $DJANGO_ENV $DOCKER_TAG
9 changes: 4 additions & 5 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ env:
jobs:
deploy:
name: Run Tests
# runs-on: ubuntu-20.04
runs-on: [self-hosted]
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -49,11 +48,11 @@ jobs:
. .github/workflows/generate-docker-tag.sh
echo "PUSH=$PUSH" >> $GITHUB_ENV
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
echo "CACHE_DOCKER_TAG=$CACHE_DOCKER_TAG" >> $GITHUB_ENV
docker pull $ECR/$PROJECT_NAME:$CACHE_DOCKER_TAG || true
echo "DJANGO_ENV=$DJANGO_ENV" >> $GITHUB_ENV
docker pull $ECR/$PROJECT_NAME:$DJANGO_ENV || true
- name: Build
run: |
docker build --build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY) --cache-from $ECR/$PROJECT_NAME:$CACHE_DOCKER_TAG -t $PROJECT_NAME .
docker build --build-arg AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID --build-arg AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY) --cache-from $ECR/$PROJECT_NAME:$DJANGO_ENV -t $PROJECT_NAME .

- name: Run test
run: |
Expand Down
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ repos:
hooks:
- id: isort
args: [--profile=black]

- repo: https://github.com/python-poetry/poetry
rev: 1.3.1
hooks:
- id: poetry-check
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM python:3.7
FROM python:3.11

RUN pip install --upgrade pip virtualenv awscli
RUN apt update && apt install netcat-openbsd supervisor gettext -y

ENV VIRTUAL_ENV=/newara/www/venv
RUN virtualenv -p python3 $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /newara/www

RUN apt-get update && apt-get install netcat-openbsd supervisor vim gettext -y
COPY Pipfile Pipfile.lock ./

ADD ./ /newara/www
RUN pip install pipenv
RUN pipenv requirements > requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

WORKDIR /newara/www
RUN pip install poetry
RUN poetry config virtualenvs.create false && poetry install
COPY . .

RUN mkdir -p /var/log/newara/
RUN chmod +x /newara/www/.docker/run.sh
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ run:
python manage.py runserver 0.0.0.0:9000

shell:
python manage.py shell -i bpython
python manage.py shell -i ipython

migrate:
python manage.py makemigrations --merge
Expand Down Expand Up @@ -64,3 +64,6 @@ elasticsearch_index:

show_sql:
python manage.py shell_plus --print-sql

schema:
python3 manage.py spectacular --color --file schema.yml
50 changes: 50 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "~=4.2"
djangorestframework = "~=3.14"
python-dotenv = "*"
awscli = "*"
gunicorn = "*"
celery = "*"
django-environ = "*"
firebase-admin = "*"
sentry-sdk = "*"
redis = "*"
django-filter = "*"
django-extensions = "*"
django-s3-storage = "*"
django-celery-beat = "*"
django-celery-results = "*"
drf-spectacular = "*"
django-cacheops = "*"
django-elasticsearch-dsl = "~=7.3"
mysqlclient = "*"
beautifulsoup4 = "*"
bleach = "*"
django-redis = "*"
pillow = "*"
html5lib = "*"
pytest = "*"
pytest-django = "*"
django-cors-headers = "*"
django-debug-toolbar = "*"
django-debug-toolbar-force = "*"
pyyaml = "~=5.3.1"
uritemplate = "*"
tqdm = "*"
lxml = "*"
django-ses = "*"

[dev-packages]
black = "*"
isort = "*"
pre-commit = "*"
ipython = "*"
pytest-cov = "*"

[requires]
python_version = "3.11"
Loading