Skip to content

Commit c228cde

Browse files
committed
Initial commit
0 parents  commit c228cde

210 files changed

Lines changed: 37012 additions & 0 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.

.devcontainer/devcontainer.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "vinta_schedule API",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../docker-compose.yml",
10+
"docker-compose.yml"
11+
],
12+
13+
// The 'service' property is the name of the service for the container that VS Code should
14+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15+
"service": "api",
16+
17+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
18+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
19+
"workspaceFolder": "/home/user/app",
20+
21+
// Features to add to the dev container. More info: https://containers.dev/features.
22+
// "features": {},
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
// "forwardPorts": [],
26+
27+
// Uncomment the next line if you want start specific services in your Docker Compose config.
28+
// "runServices": [],
29+
30+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
31+
// "shutdownAction": "none",
32+
33+
// Uncomment the next line to run commands after the container is created.
34+
"postCreateCommand": "poetry install --no-root --no-interaction --no-ansi --with=dev",
35+
36+
// Configure tool-specific properties.
37+
"customizations": {
38+
"vscode": {
39+
"extensions": [
40+
"adpyke.vscode-sql-formatter",
41+
"gruntfuggly.todo-tree",
42+
"mikestead.dotenv",
43+
"ms-python.python",
44+
"charliermarsh.ruff",
45+
"streetsidesoftware.code-spell-checker",
46+
"ms-python.mypy-type-checker",
47+
"eamodio.gitlens", // GitLens is a Git supercharged
48+
"GrapeCity.gc-excelviewer", // Excel/CSV Viewer
49+
"wmaurer.change-case", // Change text Case
50+
"njpwerner.autodocstring" // AutoDocstring
51+
],
52+
"settings": {
53+
"terminal.integrated.inheritEnv": true,
54+
"python.defaultInterpreterPath": "/home/user/app/.venv/bin/python",
55+
"python.analysis.autoImportCompletions": true,
56+
"python.analysis.typeCheckingMode": "off",
57+
"emmet.includeLanguages": {
58+
"django-html": "html"
59+
},
60+
"editor.defaultFormatter": "charliermarsh.ruff",
61+
"editor.formatOnSave": true,
62+
"editor.codeActionsOnSave": {
63+
"source.organizeImports": "always"
64+
},
65+
"[django-html]": {
66+
"editor.defaultFormatter": null
67+
},
68+
"python.linting.mypyEnabled": true,
69+
"python.linting.enabled": true,
70+
"cSpell.words": [
71+
"vinta_schedule",
72+
"idempotency",
73+
"mentee",
74+
"mentees",
75+
"MERCADOPAGO",
76+
"preapproval",
77+
"preheader",
78+
"viewset",
79+
"filterset"
80+
]
81+
}
82+
}
83+
}
84+
85+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
86+
// "remoteUser": "devcontainer"
87+
}

.devcontainer/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
services:
2+
# Update this to the name of the service you want to work with in your docker-compose.yml file
3+
api:
4+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
5+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
6+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
7+
# array). The sample below assumes your primary file is in the root of your project.
8+
#
9+
# build:
10+
# context: .
11+
# dockerfile: .devcontainer/Dockerfile
12+
13+
volumes:
14+
# Update this to wherever you want VS Code to mount the folder of your project
15+
- ..:/workspaces:cached
16+
17+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
18+
# cap_add:
19+
# - SYS_PTRACE
20+
# security_opt:
21+
# - seccomp:unconfined
22+
23+
# Overrides default command so things don't shut down after the process ends.
24+
command: sleep infinity

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.db
2+
node_modules
3+
npm-debug.log
4+
.venv

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
end_of_line = lf
12+
13+
[*.{js,jsx,ts,tsx,json,html,css,scss,md,yml,yaml,swcrc}]
14+
indent_size = 2
15+
16+
[*.md]
17+
trim_trailing_whitespace = false
18+
19+
[Makefile]
20+
indent_style = tab

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
DJANGO_SETTINGS_MODULE=vinta_schedule_api.settings.local
2+
CELERY_BROKER_URL=amqp://broker:5672//
3+
REDIS_URL=redis://result:6379
4+
DATABASE_URL=postgres://vinta_schedule_api:password@db:5432/vinta_schedule_api
5+
LOCALSTACK_ENDPOINT=http://localstack:4566
6+
LOCALSTACK_EXTERNAL_ENDPOINT=http://localhost:4566
7+
AWS_ACCESS_KEY_ID=test
8+
AWS_SECRET_ACCESS_KEY=test
9+
S3_BUCKET_NAME=vinta_schedule
10+
PYTHONBREAKPOINT=ipdb.set_trace
11+
SALT_KEY=TEST_SALT_KEY_123
12+
GOOGLE_CLIENT_ID=
13+
GOOGLE_CLIENT_SECRET=
14+
TWILLIO_ACCOUNT_SID=
15+
TWILIO_AUTH_TOKEN=
16+
TWILIO_NUMBER=
17+
TWILLIO_DEFAULT_BROADCAST_NUMBERS=

.github/workflows/main.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: main
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
name: Build vinta_schedule_api
7+
strategy:
8+
matrix:
9+
python: [3.13]
10+
env:
11+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test"
12+
REDIS_URL: "redis://localhost:6379"
13+
runs-on: ubuntu-latest
14+
services:
15+
postgres:
16+
image: postgres:15
17+
env:
18+
POSTGRES_PASSWORD: postgres
19+
POSTGRES_USER: postgres
20+
POSTGRES_DB: vinta_schedule_test
21+
ports:
22+
- 5432:5432
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
redis:
29+
image: redis:7
30+
ports:
31+
- 6379:6379
32+
options: >-
33+
--health-cmd "redis-cli ping"
34+
--health-interval 10s
35+
--health-timeout 5s
36+
--health-retries 5
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
- name: Store branch and latest SHA
41+
run: |
42+
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
43+
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
44+
id: git
45+
- name: Setup Python ${{ matrix.python }}
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: ${{ matrix.python }}
49+
- name: Cache pip
50+
uses: actions/cache@v4
51+
env:
52+
cache_name: pip-cache
53+
with:
54+
path: ~/.cache/pip
55+
key: build-${{ env.cache_name }}-${{ steps.git.outputs.branch }}-${{ steps.git.outputs.sha_short }}
56+
restore-keys: |
57+
build-${{ env.cache_name }}-${{ steps.git.outputs.branch }}-${{ steps.git.outputs.sha_short }}
58+
build-${{ env.cache_name }}-${{ steps.git.outputs.branch }}
59+
build-${{ env.cache_name }}
60+
- run: python -m pip install --upgrade pip
61+
- run: python -m pip install poetry==2.1.3
62+
- run: curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
63+
- run: sudo apt-get install git-lfs --upgrade
64+
- name: Install PostgreSQL client
65+
run: sudo apt-get update && sudo apt-get install -y postgresql-client
66+
- run: poetry install --with dev --no-root --no-interaction --no-ansi
67+
- name: Generate secret key
68+
run: echo '::set-output name=SECRET_KEY::`python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)"`'
69+
id: secret_id_generator
70+
- name: Linting
71+
run: poetry run ruff check ./
72+
env:
73+
DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.test"
74+
SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }}
75+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test"
76+
ALLOWED_HOSTS: ".example.com"
77+
SMTP_HOST: 'example.com'
78+
SMTP_USERNAME: "test"
79+
SMTP_PASSWORD: "test"
80+
REDIS_URL: "redis://localhost:6379"
81+
SITE_DOMAIN: 'example.com'
82+
API_DOMAIN: 'api.example.com'
83+
DEFAULT_BCC_EMAILS: 'hugo@example.com'
84+
AWS_STATIC_BUCKET_NAME: 'example-static'
85+
AWS_ACCESS_KEY_ID: 'test'
86+
AWS_SECRET_ACCESS_KEY: 'test'
87+
AWS_S3_ACCESS_KEY_ID: 'test'
88+
AWS_S3_SECRET_ACCESS_KEY: 'test'
89+
AWS_MEDIA_BUCKET_NAME: 'example-media'
90+
AWS_MEDIA_LOCATION: 'media'
91+
AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com'
92+
AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com'
93+
AWS_S3_REGION_NAME: 'us-east-1'
94+
AWS_CLOUDFRONT_KEY_ID: 'test'
95+
AWS_CLOUDFRONT_KEY: 'test'
96+
SALT_KEY: 'test_salt_key_123'
97+
TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID'
98+
TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID'
99+
TWILIO_NUMBER: '+12345678901'
100+
TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321'
101+
102+
103+
- run: poetry run pre-commit run --all-files
104+
env:
105+
SKIP: ruff,eslint,missing-migrations,backend-schema
106+
- run: poetry run python manage.py makemigrations --check --dry-run
107+
env:
108+
DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.production"
109+
SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }}
110+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test"
111+
ALLOWED_HOSTS: ".example.org"
112+
SMTP_HOST: 'example.org'
113+
SMTP_USERNAME: "test"
114+
SMTP_PASSWORD: "test"
115+
REDIS_URL: "redis://localhost:6379"
116+
SITE_DOMAIN: 'example.com'
117+
API_DOMAIN: 'api.example.com'
118+
DEFAULT_BCC_EMAILS: 'hugo@example.com'
119+
AWS_STATIC_BUCKET_NAME: 'example-static'
120+
AWS_ACCESS_KEY_ID: 'test'
121+
AWS_SECRET_ACCESS_KEY: 'test'
122+
AWS_S3_ACCESS_KEY_ID: 'test'
123+
AWS_S3_SECRET_ACCESS_KEY: 'test'
124+
AWS_MEDIA_BUCKET_NAME: 'example-media'
125+
AWS_MEDIA_LOCATION: 'media'
126+
AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com'
127+
AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com'
128+
AWS_S3_REGION_NAME: 'us-east-1'
129+
AWS_CLOUDFRONT_KEY_ID: 'test'
130+
AWS_CLOUDFRONT_KEY: 'test'
131+
SALT_KEY: 'test_salt_key_123'
132+
TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID'
133+
TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID'
134+
TWILIO_NUMBER: '+12345678901'
135+
TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321'
136+
- run: poetry run python manage.py check --deploy
137+
env:
138+
DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.production"
139+
SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }}
140+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test"
141+
ALLOWED_HOSTS: ".example.org"
142+
SMTP_HOST: 'example.org'
143+
SMTP_USERNAME: "test"
144+
SMTP_PASSWORD: "test"
145+
REDIS_URL: "redis://localhost:6379"
146+
SITE_DOMAIN: 'example.com'
147+
API_DOMAIN: 'api.example.com'
148+
DEFAULT_BCC_EMAILS: 'hugo@example.com'
149+
AWS_STATIC_BUCKET_NAME: 'example-static'
150+
AWS_ACCESS_KEY_ID: 'test'
151+
AWS_SECRET_ACCESS_KEY: 'test'
152+
AWS_S3_ACCESS_KEY_ID: 'test'
153+
AWS_S3_SECRET_ACCESS_KEY: 'test'
154+
AWS_MEDIA_BUCKET_NAME: 'example-media'
155+
AWS_MEDIA_LOCATION: 'media'
156+
AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com'
157+
AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com'
158+
AWS_S3_REGION_NAME: 'us-east-1'
159+
AWS_CLOUDFRONT_KEY_ID: 'test'
160+
AWS_CLOUDFRONT_KEY: 'test'
161+
SALT_KEY: 'test_salt_key_123'
162+
TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID'
163+
TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID'
164+
TWILIO_NUMBER: '+12345678901'
165+
TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321'
166+
- run: |
167+
poetry run pytest $(ARG) -vs -n auto --no-header --cov=. --cov-report=xml:junit/test-results.xml --junitxml=junit.xml -o junit_family=legacy
168+
env:
169+
DJANGO_SETTINGS_MODULE: "vinta_schedule_api.settings.test"
170+
SECRET_KEY: ${{ steps.secret_id_generator.outputs.SECRET_KEY }}
171+
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/vinta_schedule_test"
172+
ALLOWED_HOSTS: ".example.com"
173+
SMTP_HOST: 'example.com'
174+
SMTP_USERNAME: "test"
175+
SMTP_PASSWORD: "test"
176+
REDIS_URL: "redis://localhost:6379"
177+
SITE_DOMAIN: 'example.com'
178+
API_DOMAIN: 'api.example.com'
179+
DEFAULT_BCC_EMAILS: 'hugo@example.com'
180+
AWS_STATIC_BUCKET_NAME: 'example-static'
181+
AWS_ACCESS_KEY_ID: 'test'
182+
AWS_SECRET_ACCESS_KEY: 'test'
183+
AWS_S3_ACCESS_KEY_ID: 'test'
184+
AWS_S3_SECRET_ACCESS_KEY: 'test'
185+
AWS_MEDIA_BUCKET_NAME: 'example-media'
186+
AWS_MEDIA_LOCATION: 'media'
187+
AWS_MEDIA_S3_CUSTOM_DOMAIN: 'example.com'
188+
AWS_MEDIA_S3_ENDPOINT_URL: 'https://example.com'
189+
AWS_S3_REGION_NAME: 'us-east-1'
190+
AWS_CLOUDFRONT_KEY_ID: 'test'
191+
AWS_CLOUDFRONT_KEY: 'test'
192+
SALT_KEY: 'test_salt_key_123'
193+
TWILLIO_ACCOUNT_SID: 'FAKE_ACCOUNT_SID'
194+
TWILIO_AUTH_TOKEN: 'FAKE_ACCOUNT_SID'
195+
TWILIO_NUMBER: '+12345678901'
196+
TWILLIO_DEFAULT_BROADCAST_NUMBERS: '+12345678901,+10987654321'
197+
198+
- name: Archive code coverage results
199+
uses: actions/upload-artifact@v4
200+
with:
201+
name: code-coverage-report
202+
path: junit/test-results.xml
203+
204+
- name: Upload coverage to Codecov
205+
uses: codecov/codecov-action@v4
206+
with:
207+
env_vars: OS,PYTHON
208+
fail_ci_if_error: true
209+
files: ./junit/test-results.xml
210+
flags: unittests
211+
name: codecov-umbrella
212+
token: ${{ secrets.CODECOV_TOKEN }}
213+
verbose: true
214+
env:
215+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
216+
217+
- name: Upload test results to Codecov
218+
if: ${{ !cancelled() }}
219+
uses: codecov/test-results-action@v1
220+
with:
221+
token: ${{ secrets.CODECOV_TOKEN }}
222+
env:
223+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)