Skip to content

Commit 42d1155

Browse files
authored
Merge pull request #983 from hngprojects/dev
merge dev to main
2 parents 15836d0 + 82f8e2f commit 42d1155

438 files changed

Lines changed: 69779 additions & 992 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Ignore node_modules directory
2+
node_modules
3+
4+
# Ignore Python virtual environment directories
5+
venv
6+
.venv
7+
8+
# Ignore MacOS system files
9+
.DS_Store
10+
11+
# Ignore Git directories and files
12+
.git
13+
.gitignore
14+
15+
# Ignore log files
16+
*.log
17+
18+
# Ignore temporary files
19+
*.tmp
20+
*.swp
21+
*~
22+
23+
# Ignore build directories
24+
build/
25+
dist/
26+
27+
# Ignore compiled Python files
28+
__pycache__/
29+
*.pyc
30+
31+
# Ignore Docker-related files (uncomment if needed)
32+
# Dockerfile
33+
# docker-compose.yml
34+
35+
# Ignore coverage reports
36+
coverage/
37+
*.cover
38+
39+
# Ignore IDE and editor-specific files
40+
.vscode/
41+
.idea/
42+
*.iml
43+
44+
# Ignore test results
45+
test-output/
46+
reports/

.env.sample

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ MYSQL_DRIVER=
1010
DB_URL=postgresql://username:password@localhost:5432/test
1111
SECRET_KEY = ""
1212
ALGORITHM = HS256
13-
ACCESS_TOKEN_EXPIRE_MINUTES = 10
14-
JWT_REFRESH_EXPIRY=5
13+
ACCESS_TOKEN_EXPIRE_MINUTES = 3000
14+
JWT_REFRESH_EXPIRY=7
1515
APP_URL=
16+
17+
GOOGLE_CLIENT_ID=""
18+
GOOGLE_CLIENT_SECRET=""
19+
20+
FRONTEND_URL='http://127.0.0.1:3000/login-success'
21+
22+
TESTING=''
23+
24+
MAIL_USERNAME=""
25+
MAIL_PASSWORD=""
26+
MAIL_FROM="dummy@gmail.com"
27+
MAIL_PORT=465
28+
MAIL_SERVER="smtp.gmail.com"
29+
30+
TWILIO_ACCOUNT_SID="MOCK_ACCOUNT_SID"
31+
TWILIO_AUTH_TOKEN="MOCK_AUTH_TOKEN"
32+
TWILIO_PHONE_NUMBER="TWILIO_PHONE_NUMBER"
33+
34+
FLUTTERWAVE_SECRET=""
35+
PAYSTACK_SECRET=""
36+
37+
STRIPE_SECRET_KEY=""
38+
STRIPE_WEBHOOK_SECRET=""
39+
40+
MAILJET_API_KEY='MAIL JET API KEY'
41+
MAILJET_API_SECRET='SECRET KEY'

.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md renamed to .github/PULL_REQUEST_TEMPLATE.md

File renamed without changes.

.github/workflows/cd.dev.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Dev Deployment
2+
3+
on:
4+
# push:
5+
# branches: [dev]
6+
# paths-ignore:
7+
# - "README.md"
8+
# - ".github/workflows/**"
9+
workflow_dispatch:
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Use SSH Action
19+
uses: appleboy/ssh-action@v0.1.8
20+
with:
21+
host: ${{ secrets.HOST }}
22+
username: ${{ secrets.USERNAME }}
23+
password: ${{ secrets.PASSWORD }}
24+
script: |
25+
cd hng_boilerplate_python_fastapi_web/dev
26+
git add .
27+
git stash
28+
git pull origin dev
29+
source venv/bin/activate
30+
pip install -r requirements.txt
31+
alembic revision --autogenerate
32+
alembic upgrade head

.github/workflows/cd.dev.yml

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

.github/workflows/cd.prod.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Prod Branch Deployment
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- "README.md"
8+
- ".github/workflows/**"
9+
workflow_dispatch:
10+
11+
jobs:
12+
on-success:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Archive application build
19+
run: |
20+
tar -czf python.tar.gz .
21+
22+
- name: Copy Artifacts to server
23+
run: |
24+
sshpass -p ${{ secrets.PASSWORD }} scp -o StrictHostKeyChecking=no python.tar.gz ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/tmp/python
25+
rm -f python.tar.gz
26+
27+
- name: Use SSH Action
28+
uses: appleboy/ssh-action@v0.1.8
29+
with:
30+
host: ${{ secrets.HOST }}
31+
username: ${{ secrets.USERNAME }}
32+
password: ${{ secrets.PASSWORD }}
33+
script: |
34+
cd backend/python
35+
tar -xzf /tmp/python/python.tar.gz -C .
36+
rm -f /tmp/python/python.tar.gz
37+
source venv/bin/activate
38+
pip install -r requirements.txt
39+
alembic revision --autogenerate
40+
alembic upgrade head

.github/workflows/cd.prod.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: Staging Branch Deployment
22

33
on:
4-
workflow_run:
5-
workflows: ["CI"]
6-
types:
7-
- completed
4+
push:
85
branches: [staging]
6+
paths-ignore:
7+
- "README.md"
8+
- ".github/workflows/**"
9+
workflow_dispatch:
910

1011
jobs:
11-
on-success:
12+
deploy:
1213
runs-on: ubuntu-latest
13-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v3
@@ -22,16 +22,11 @@ jobs:
2222
username: ${{ secrets.USERNAME }}
2323
password: ${{ secrets.PASSWORD }}
2424
script: |
25-
cd python/staging_source_code/
25+
cd hng_boilerplate_python_fastapi_web/staging
26+
git add .
27+
git stash
2628
git pull origin staging
27-
source .venv/bin/activate
29+
source venv/bin/activate
2830
pip install -r requirements.txt
29-
# alembic upgrade head
30-
31-
32-
33-
on-failure:
34-
runs-on: ubuntu-latest
35-
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
36-
steps:
37-
- run: echo 'The triggering workflow failed'
31+
alembic revision --autogenerate
32+
alembic upgrade head

.github/workflows/ci.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: [main, staging, dev, devops-main]
64
pull_request:
7-
branches: [main, staging, dev, devops-main]
5+
types: [opened, synchronize, reopened]
6+
paths-ignore:
7+
- "README.md"
8+
# - ".github/workflows/**"
89

910
jobs:
1011
build-and-test:
@@ -14,21 +15,28 @@ jobs:
1415
postgres:
1516
image: postgres:latest
1617
env:
17-
POSTGRES_USER: 'username'
18+
POSTGRES_USER: "username"
1819
POSTGRES_PASSWORD: "password"
1920
POSTGRES_DB: "test"
2021
ports:
2122
- 5432:5432
2223

2324
steps:
2425
- name: Checkout code
25-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
2627

2728
- name: Set up Python
2829
uses: actions/setup-python@v4
2930
with:
30-
python-version: "3.9"
31-
virtual-environment: venv
31+
python-version: "3.10"
32+
33+
- name: Cache dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
3240
3341
- name: Install dependencies
3442
run: |
@@ -50,13 +58,11 @@ jobs:
5058
exit 1
5159
fi
5260
61+
- name: Run migrations
62+
run: |
63+
alembic revision --autogenerate
64+
alembic upgrade head
5365
54-
# - name: Run migrations
55-
# run: |
56-
# activate
57-
# alembic upgrade head
58-
59-
# - name: Run tests
60-
# run: |
61-
# activate
62-
# pytest
66+
- name: Run tests
67+
run: |
68+
PYTHONPATH=. pytest
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PR Deploy
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened, closed]
5+
6+
7+
jobs:
8+
deploy-pr:
9+
environment:
10+
name: preview
11+
url: ${{ steps.deploy.outputs.preview-url }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout to branch
15+
uses: actions/checkout@v4
16+
- name: Copy .env.sample to .env
17+
run: cp .env.sample .env
18+
- id: deploy
19+
name: Pull Request Deploy
20+
uses: hngprojects/pr-deploy@main
21+
with:
22+
server_host: ${{ secrets.HOST }}
23+
server_username: ${{ secrets.USERNAME }}
24+
server_password: ${{ secrets.PASSWORD }}
25+
comment: true
26+
context: '.'
27+
dockerfile: 'Dockerfile'
28+
exposed_port: '7001'
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Print Preview Url
31+
run: |
32+
echo "Preview Url: ${{ steps.deploy.outputs.preview-url }}"

0 commit comments

Comments
 (0)