Skip to content

Commit accbdf7

Browse files
authored
Merge pull request #76 from gcivil-nyu-org/develop
Testing all changes for deployment
2 parents 2fe6c7d + f744997 commit accbdf7

File tree

80 files changed

+7280
-125
lines changed

Some content is hidden

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

80 files changed

+7280
-125
lines changed

.env.example

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,25 @@ AWS_STORAGE_BUCKET_NAME=your-bucket-name
1919
AWS_S3_REGION_NAME=us-east-1
2020
AWS_S3_CUSTOM_DOMAIN=your-cdn-url.cloudfront.net
2121

22-
# Email Configuration (Optional - for production emails)
23-
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
22+
# Email (Gmail SMTP for dev/test). Use App Password with 2FA; do not use raw password.
23+
# If EMAIL_HOST_USER is set, Django uses SMTP; otherwise file backend (DEBUG) or console.
24+
# Optional: DEFAULT_FROM_EMAIL=your-email@gmail.com (defaults to EMAIL_HOST_USER)
25+
EMAIL_HOST_USER=your-email@gmail.com
26+
EMAIL_HOST_PASSWORD=your-16-char-app-password
2427
EMAIL_HOST=smtp.gmail.com
2528
EMAIL_PORT=587
2629
EMAIL_USE_TLS=True
27-
EMAIL_HOST_USER=your-email@gmail.com
28-
EMAIL_HOST_PASSWORD=your-app-password
2930

3031
# CORS Settings
3132
CORS_ALLOWED_ORIGINS=https://your-domain.com,https://www.your-domain.com
3233

3334
# Application Settings
3435
ENVIRONMENT=production
36+
37+
DEBUG=True
38+
SECRET_KEY=django-insecure-dev-key-for-local-testing
39+
ALLOWED_HOSTS=localhost,127.0.0.1,testserver
40+
DB_ENGINE=django.db.backends.sqlite3
41+
DB_NAME=db.sqlite3
42+
USE_S3=False
43+
ENVIRONMENT=development

.github/workflows/deploy.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
EB_ENVIRONMENT_NAME: nomz-prod
1010
EB_APPLICATION_NAME: nomz-app
1111
REGION: us-east-1
12+
PYTHON_VERSION: '3.12'
1213

1314
jobs:
1415
deploy:
@@ -21,36 +22,38 @@ jobs:
2122
- name: Set up Python
2223
uses: actions/setup-python@v4
2324
with:
24-
python-version: '3.12'
25+
python-version: ${{ env.PYTHON_VERSION }}
2526

2627
- name: Install dependencies
2728
run: |
2829
python -m pip install --upgrade pip
2930
pip install -r requirements.txt
3031
pip install awsebcli
3132
32-
# - name: Run tests (optional)
33-
# run: |
34-
# python manage.py test --no-input
35-
# continue-on-error: true
33+
- name: Run tests before deployment
34+
run: |
35+
python manage.py test --no-input --verbosity=2
36+
continue-on-error: true
3637

37-
# - name: Configure AWS credentials
38-
# uses: aws-actions/configure-aws-credentials@v2
39-
# with:
40-
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
41-
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
42-
# aws-region: ${{ env.REGION }}
38+
- name: Configure AWS credentials
39+
uses: aws-actions/configure-aws-credentials@v2
40+
with:
41+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
42+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43+
aws-region: ${{ env.REGION }}
4344

44-
# - name: Deploy to Elastic Beanstalk
45-
# run: |
46-
# eb init -p python-3.12 ${{ env.EB_APPLICATION_NAME }} --region ${{ env.REGION }} -d
47-
# eb deploy ${{ env.EB_ENVIRONMENT_NAME }} --verbose --timeout 20
45+
- name: Deploy to Elastic Beanstalk
46+
run: |
47+
eb init -p python-${{ env.PYTHON_VERSION }} ${{ env.EB_APPLICATION_NAME }} --region ${{ env.REGION }} -d
48+
eb deploy ${{ env.EB_ENVIRONMENT_NAME }} --verbose --timeout 20
4849
49-
# - name: Notify Deployment
50-
# if: success()
51-
# run: echo "✅ Deployment to AWS Elastic Beanstalk successful!"
50+
- name: Notify Deployment Success
51+
if: success()
52+
run: echo "✅ Deployment to AWS Elastic Beanstalk successful!"
5253

53-
# - name: Notify Failure
54-
# if: failure()
55-
# run: echo "❌ Deployment failed! Check logs for details."
54+
- name: Notify Deployment Failure
55+
if: failure()
56+
run: |
57+
echo "❌ Deployment failed! Check logs for details."
58+
exit 1
5659

.github/workflows/test.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Test on Develop Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
branches:
9+
- develop
10+
11+
env:
12+
PYTHON_VERSION: '3.12'
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
services:
19+
postgres:
20+
image: postgres:15
21+
env:
22+
POSTGRES_DB: test_nomz_db
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: postgres
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
ports:
31+
- 5432:5432
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v3
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install -r requirements.txt
46+
pip install pytest pytest-django pytest-cov
47+
48+
- name: Create test environment file
49+
run: |
50+
cat > .env << EOF
51+
DEBUG=True
52+
SECRET_KEY=test-secret-key-for-ci-cd
53+
ALLOWED_HOSTS=localhost,127.0.0.1,testserver
54+
DB_ENGINE=django.db.backends.postgresql
55+
DB_NAME=test_nomz_db
56+
DB_USER=postgres
57+
DB_PASSWORD=postgres
58+
DB_HOST=localhost
59+
DB_PORT=5432
60+
USE_S3=False
61+
ENVIRONMENT=testing
62+
EOF
63+
64+
- name: Run migrations
65+
run: |
66+
python manage.py migrate --no-input
67+
68+
- name: Run Django tests
69+
run: |
70+
python manage.py test --no-input --verbosity=2
71+
72+
- name: Check for migrations
73+
run: |
74+
python manage.py makemigrations --dry-run --check
75+
76+
- name: Collect static files
77+
run: |
78+
python manage.py collectstatic --noinput --dry-run
79+
80+
- name: Test import statements
81+
run: |
82+
python -c "import django; django.setup(); from nomz import models, views, forms"
83+
84+
- name: Upload test results
85+
if: always()
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: test-results
89+
path: |
90+
coverage.xml
91+
test_results.json
92+
93+
code-quality:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v3
98+
99+
- name: Set up Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: ${{ env.PYTHON_VERSION }}
103+
104+
- name: Install dependencies
105+
run: |
106+
python -m pip install --upgrade pip
107+
pip install -r requirements.txt
108+
pip install flake8 black isort
109+
110+
- name: Check code formatting with black
111+
run: black --check --diff .
112+
continue-on-error: true
113+
114+
- name: Check import ordering with isort
115+
run: isort --check-only --diff .
116+
continue-on-error: true
117+
118+
- name: Lint with flake8
119+
run: |
120+
# Stop the build if there are Python syntax errors or undefined names
121+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
122+
# Exit-code is 0 even if there are warnings
123+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
124+
continue-on-error: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,4 @@ __marimo__/
213213

214214
# AWS credentials helper (contains secrets)
215215
aws-config.ps1
216+
.DS_Store

0 commit comments

Comments
 (0)