Skip to content

Commit 7865e43

Browse files
authored
Merge pull request #122 from SADiLaR/develop
Merge existing work into main branch
2 parents 1423e77 + 173f335 commit 7865e43

File tree

148 files changed

+7707
-70
lines changed

Some content is hidden

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

148 files changed

+7707
-70
lines changed

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SECRET_KEY=''
2+
DEBUG=True
3+
DB_HOST=db
4+
DB_PORT=5432
5+
DB_NAME=term_db
6+
DB_USER=sadilar
7+
DB_PASSWORD=sadilar
8+
LOGGING_FILE=debug.log
9+
LOGGING_HANDLERS_LEVEL=INFO
10+
LOGGING_LOGGERS_LEVEL=INFO
11+
LOGGING_LOGGERS_DJANGO_LEVEL=INFO
12+
TESTING_DIR=/app/general/tests/files/
13+
EMAIL_HOST=''
14+
EMAIL_PORT=587
15+
EMAIL_USE_TLS=True
16+
EMAIL_HOST_USER=''
17+
EMAIL_HOST_PASSWORD=''
18+
DEFAULT_FROM_EMAIL=''
19+
SERVER_EMAIL=''
20+
EMAIL_SUBJECT_PREFIX=''
21+
EMAIL_BACKEND_CONSOLE='True/False'
22+
SECRET_KEY=''

.env.testing

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SECRET_KEY='django-insecure-w!h85bp^$$e8gm%c23r!0%9i7yzd=6w$$s&ic+6!%306&kj8@k*5'
2+
DEBUG=True
3+
DB_HOST=localhost
4+
DB_PORT=5432
5+
DB_NAME=term_db
6+
DB_USER=sadilar
7+
DB_PASSWORD=sadilar
8+
LOGGING_FILE=debug.log
9+
LOGGING_HANDLERS_LEVEL=INFO
10+
LOGGING_LOGGERS_LEVEL=INFO
11+
LOGGING_LOGGERS_DJANGO_LEVEL=INFO
12+
TESTING_DIR=/home/runner/work/term_platform/term_platform/app/general/tests/files/

.github/workflows/main.yml renamed to .github/workflows/develop.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://docs.docker.com/build/ci/github-actions/push-multi-registries/
2-
name: docker_push
2+
name: docker_push_deploy_test
33

44
on:
55
workflow_dispatch:
@@ -8,7 +8,7 @@ on:
88
- "develop"
99

1010
jobs:
11-
docker:
11+
deploy_test:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
@@ -34,4 +34,4 @@ jobs:
3434
with:
3535
url: https://api.bitbucket.org/2.0/repositories/team_sadilar/ansible/pipelines/
3636
headers: '{"Authorization": "Bearer ${{ secrets.BITBUCKET_PIPELINE_SECRET }}"}'
37-
body: '{"target": {"ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "master", "selector": {"type": "custom", "pattern": "deploy_term_platform" } }}'
37+
body: '{"target": {"ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "master", "selector": {"type": "custom", "pattern": "deploy_term_platform_test" } }}'

.github/workflows/production.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# https://docs.docker.com/build/ci/github-actions/push-multi-registries/
2+
name: docker_push_prod
3+
4+
on:
5+
push:
6+
tags:
7+
- v**
8+
9+
jobs:
10+
docker_push:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v3
17+
- name: Login to SADiLaR Container Registry
18+
uses: docker/login-action@v3
19+
with:
20+
registry: docker.sadilar.org
21+
username: ${{ vars.SADILAR_DOCKER_REPOSITORY_USER }}
22+
password: ${{ secrets.SADILAR_DOCKER_REPOSITORY_SECRET }}
23+
- name: Build and push
24+
uses: docker/build-push-action@v5
25+
with:
26+
context: .
27+
platforms: linux/amd64
28+
push: true
29+
tags: |
30+
docker.sadilar.org/term_platform:prod

.github/workflows/testing.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Testing Django
2+
on: [ pull_request, push ] # activates the workflow when there is a push or pull request in the repo
3+
jobs:
4+
test_project:
5+
runs-on: ubuntu-latest # operating system your code will run on
6+
services:
7+
postgres:
8+
image: postgres:16
9+
env:
10+
POSTGRES_USER: sadilar
11+
POSTGRES_PASSWORD: sadilar
12+
POSTGRES_DB: test_db_1
13+
ports:
14+
- 5432:5432
15+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-python@v2
19+
- name: Install Dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements-test.txt
23+
sudo apt-get install -y gettext
24+
- name: Run linting tools
25+
run: |
26+
cd app/
27+
ruff format .
28+
- name: Create logging folder
29+
run: |
30+
sudo mkdir -p /logging
31+
sudo chown runner:runner /logging
32+
- name: Compile Translation Messages
33+
run: |
34+
cp .env.testing app/.env
35+
cd app/
36+
python manage.py makemessages --all
37+
python manage.py compilemessages
38+
- name: Run validate_templates
39+
run: |
40+
export DJANGO_TEST_PROCESSES=1
41+
cp .env.testing app/.env
42+
cd app/
43+
mkdir -p static_files
44+
python manage.py validate_templates --ignore-app django_filters
45+
- name: Run Tests
46+
run: |
47+
cp .env.testing app/.env
48+
cd app/
49+
mkdir -p static_files
50+
python manage.py test
51+
env:
52+
DJANGO_SETTINGS_MODULE: app.settings
53+
DATABASE_URL: postgres://sadilar:sadilar@localhost:5432/test_db
54+
- name: Manager Check
55+
run: |
56+
cd app/
57+
python manage.py check

.gitignore

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,41 @@
1-
# These are some examples of commonly ignored file patterns.
2-
# You should customize this list as applicable to your project.
3-
# Learn more about .gitignore:
4-
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
5-
6-
# Node artifact files
7-
node_modules/
8-
dist/
9-
10-
# Compiled Java class files
11-
*.class
12-
13-
# Compiled Python bytecode
14-
*.py[cod]
15-
161
# Log files
172
*.log
183

19-
# Package files
20-
*.jar
21-
22-
# Maven
23-
target/
24-
dist/
25-
264
# JetBrains IDE
275
.idea/
286

29-
# Unit test reports
30-
TEST*.xml
31-
32-
# Generated by MacOS
33-
.DS_Store
34-
357
# Generated by Windows
368
Thumbs.db
379

38-
# Applications
39-
*.app
40-
*.exe
41-
*.war
42-
43-
# Large media files
44-
*.mp4
45-
*.tiff
46-
*.avi
47-
*.flv
48-
*.mov
49-
*.wmv
50-
10+
# Django template
11+
*.pot
12+
*.mo
13+
*.pyc
14+
__pycache__/
15+
local_settings.py
16+
db.sqlite3
17+
db.sqlite3-journal
18+
media
19+
20+
# General Files
21+
.DS_Store
22+
.AppleDouble
23+
.LSOverride
24+
25+
# Environments
26+
.env
27+
.venv
28+
env/
29+
venv/
30+
ENV/
31+
env.bak/
32+
venv.bak/
33+
34+
#folders
35+
app/static_files/
36+
/app/documents/
37+
app/media/
38+
/app/logging/
39+
/logging/
40+
/pdf_uploads/
41+
/pdf_upload_completed/

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
# Linting and formatting for Python.
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
# Ruff version.
5+
rev: v0.2.2
6+
hooks:
7+
# Run the linter.
8+
- id: ruff
9+
args: [ --diff ]
10+
# Run the formatter.
11+
- id: ruff-format
12+
args: [ --diff ]
13+
14+
# Automatically sort python imports
15+
- repo: https://github.com/PyCQA/isort
16+
rev: 5.13.2
17+
hooks:
18+
- id: isort
19+
args: [ --profile, black ]
20+
21+
# Lint: YAML
22+
- repo: https://github.com/adrienverge/yamllint
23+
rev: v1.35.1
24+
hooks:
25+
- id: yamllint
26+
args: ["-d {extends: relaxed, rules: {line-length: disable}}", "-s"]
27+
files: \.(yaml|yml)$

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# A minimalist image usable as a base for a production deployment.
2+
FROM python:3.12
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
SHELL ["/bin/bash", "-c"]
9+
10+
# Set work directory
11+
WORKDIR /app
12+
13+
# Install dependencies
14+
COPY requirements.txt /app/
15+
16+
RUN <<EOF
17+
set -exo pipefail
18+
apt-get update
19+
apt-get -y upgrade
20+
apt-get install -y --no-install-recommends libmagic1 gettext
21+
pip install --upgrade pip
22+
pip install -r requirements.txt
23+
EOF
24+
25+
# Copy project
26+
COPY ./app /app/
27+
COPY ./entrypoint.sh /
28+
29+
# Run the application
30+
ENTRYPOINT ["bash", "/entrypoint.sh"]

Dockerfile-dev

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# A development image with extras for development.
2+
# Don't use in production.
3+
FROM python:3.12
4+
5+
# Set environment variables
6+
ENV PYTHONDONTWRITEBYTECODE 1
7+
ENV PYTHONUNBUFFERED 1
8+
9+
SHELL ["/bin/bash", "-c"]
10+
11+
# Set work directory
12+
WORKDIR /app
13+
14+
# Install dependencies
15+
COPY requirements.txt requirements-dev.txt /app/
16+
17+
RUN <<EOF
18+
set -exo pipefail
19+
apt-get update
20+
apt-get -y upgrade
21+
apt-get install -y --no-install-recommends libmagic1 gettext graphviz graphviz-dev
22+
pip install --upgrade pip
23+
pip install -r requirements-dev.txt
24+
EOF
25+
26+
# Copy project
27+
COPY ./app /app/
28+
29+
# Run the application
30+
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

0 commit comments

Comments
 (0)