Skip to content

Commit 890f6d8

Browse files
authored
Merge pull request #312 from DurianPy-Davao-Python-User-Group/main
chore: merge durianpy diff
2 parents d1d60a0 + 1801ec1 commit 890f6d8

281 files changed

Lines changed: 27676 additions & 17572 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.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy stage to main
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
deploy-stage-to-main:
8+
name: Deploy stage to main
9+
runs-on: ubuntu-latest
10+
defaults:
11+
run:
12+
working-directory: ./frontend
13+
permissions:
14+
issues: write
15+
contents: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
ref: stage
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: "22.15"
25+
cache: "npm"
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Check Code Format
31+
run: npm run format:check:ci
32+
33+
- name: Build Project
34+
run: npm run build:dummy
35+
36+
- name: Await Manual Approval
37+
uses: trstringer/manual-approval@v1
38+
with:
39+
secret: ${{ secrets.GITHUB_TOKEN }}
40+
approvers: ArJSarmiento,ASPactores,seangaaab
41+
minimum-approvals: 1
42+
issue-title: "Deploying stage to main"
43+
issue-body: "Please approve or deny the deployment."
44+
45+
- name: Sync stage to main
46+
uses: connor-baer/action-sync-branch@main
47+
with:
48+
branch: main
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
force: true
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Deploy PR to stage
2+
3+
on:
4+
push:
5+
branches: [stage]
6+
pull_request:
7+
branches: [stage]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-deploy:
12+
name: Build and Deploy PR to stage
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./frontend
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: "22.15"
23+
cache: "npm"
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Check Code Format
29+
run: npm run format:check:ci
30+
31+
- name: Build Project
32+
run: npm run build:dummy
33+
34+
- name: Deploy to Amplify
35+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
36+
run: |
37+
curl -X POST -d '{}' "${{ secrets.AMPLIFY_WEBHOOK_URL }}" -H "Content-Type:application/json"
Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
name: Deploy SPARCS Events Service
1+
name: Deploy DurianPy Events Service
22
on:
33
push:
44
paths:
55
- backend/**
66
branches:
77
- main
88
- stage
9+
workflow_dispatch:
10+
11+
permissions:
12+
id-token: write
13+
contents: read
914

1015
jobs:
1116
deploy:
@@ -15,36 +20,50 @@ jobs:
1520
- name: Checkout
1621
uses: actions/checkout@v3
1722

18-
- name: Configure AWS Credentials
19-
uses: aws-actions/configure-aws-credentials@v1
23+
- name: Set ARN for Role to Assume
24+
run: |
25+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
26+
echo "AWS_OIDC_ROLE_ARN=${{ secrets.AWS_OIDC_ROLE_ARN_PROD }}" >> $GITHUB_ENV
27+
elif [[ "${{ github.ref }}" == "refs/heads/stage" ]]; then
28+
echo "AWS_OIDC_ROLE_ARN=${{ secrets.AWS_OIDC_ROLE_ARN_STAGE }}" >> $GITHUB_ENV
29+
fi
2030
31+
- name: Configure AWS Credentials
32+
uses: aws-actions/configure-aws-credentials@v4.1.0
2133
with:
22-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34+
audience: sts.amazonaws.com
2435
aws-region: ap-southeast-1
36+
role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }}
37+
role-session-name: GithubActionSession
2538

2639
- name: Set up Python
27-
uses: actions/setup-python@v2
40+
uses: actions/setup-python@v5
2841
with:
29-
python-version: 3.8
42+
python-version-file: "backend/.python-version"
43+
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v6
3046

3147
- name: Install dependencies
3248
run: |
33-
python3 -m pip install pipenv==2023.4.29
34-
pipenv install
49+
uv sync --locked --all-extras --dev
3550
working-directory: backend
3651

3752
- name: Install Serverless Framework
3853
run: |
3954
npm install
40-
npm install -g serverless@3.39.0
55+
npm install -g serverless@3.40.0
56+
working-directory: backend
57+
58+
- name: Create requirements.txt
59+
run: uv export --format requirements-txt --no-hashes --output-file requirements.txt --no-dev
4160
working-directory: backend
4261

43-
- name: Deploy with Serverless
62+
- name: Deploy with Serverless v3
4463
run: |
4564
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
4665
sls deploy --stage prod --verbose
4766
elif [[ "${{ github.ref }}" == "refs/heads/stage" ]]; then
48-
sls deploy --stage dev --verbose
67+
sls deploy --stage staging --verbose
4968
fi
5069
working-directory: backend

.github/workflows/formatting_backend.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ jobs:
2525

2626
- name: Run Formatters
2727
run: |
28-
flake8 --max-line-length=120 --ignore=E203,E266,E501,W503,F403,F401,E402,F841,C901,F722,F405,F811
29-
black --check . --line-length=120 --skip-string-normalization
3028
ruff check .
3129
working-directory: backend

.github/workflows/formatting_frontend.yml

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ my.secrets
88
.DS_STORE
99

1010
.ruff_cache
11+
.DS_Store
12+
13+
*.xlsx

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = aws,boto3,botocore,constants,controller,external_gateway,fastapi,fastapi_cloudauth,lambda_decorators,lambdawarmer,mangum,model,pydantic,pynamodb,pytz,repository,requests,starlette,ulid,usecase,utils
2+
known_third_party = PIL,aws,boto3,botocore,constants,controller,dotenv,external_gateway,fastapi,fastapi_cloudauth,httpx,lambda_decorators,lambdawarmer,mangum,model,openpyxl,pandas,pydantic,pynamodb,pytz,repository,requests,starlette,typing_extensions,ulid,usecase,utils

amplify.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 1
2+
applications:
3+
- frontend:
4+
phases:
5+
preBuild:
6+
commands:
7+
- npm ci --cache .npm --prefer-offline
8+
- |
9+
if [ "$AWS_BRANCH" = "dev" ]; then
10+
STAGE=dev
11+
elif [ "$AWS_BRANCH" = "stage" ]; then
12+
STAGE=staging
13+
elif [ "$AWS_BRANCH" = "main" ]; then
14+
STAGE=prod
15+
else
16+
STAGE=dev
17+
fi
18+
echo "Using STAGE=$STAGE (branch=$AWS_BRANCH, region=$AWS_REGION)"
19+
20+
npm run generate "$STAGE" --region "$AWS_REGION"
21+
build:
22+
commands:
23+
- npm run build
24+
artifacts:
25+
baseDirectory: dist
26+
files:
27+
- "**/*"
28+
cache:
29+
paths:
30+
- ".npm/**/*"
31+
- node_modules/**/*
32+
runtime-versions:
33+
nodejs: 22.15
34+
appRoot: frontend

backend/.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ repos:
2828
args: [ --fix ]
2929
# Run the formatter.
3030
- id: ruff-format
31+
32+
# mypy
33+
# - repo: https://github.com/pre-commit/mirrors-mypy
34+
# rev: 'v1.17.0'
35+
# hooks:
36+
# - id: mypy
37+
# detect-secrets
38+
- repo: https://github.com/Yelp/detect-secrets
39+
rev: v1.5.0
40+
hooks:
41+
- id: detect-secrets
42+
args: ['--baseline', './backend/.secrets.baseline']
43+
exclude: package.lock.json
44+
# commitizen
45+
- repo: https://github.com/commitizen-tools/commitizen
46+
rev: v4.8.3
47+
hooks:
48+
- id: commitizen
49+
- id: commitizen-branch
50+
stages: [manual]

backend/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.10
1+
3.11

0 commit comments

Comments
 (0)