Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer committed May 10, 2024
0 parents commit b91f098
Show file tree
Hide file tree
Showing 103 changed files with 3,546 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Django Docker Environment",
"remoteUser": "vscode",
"postCreateCommand": "git config --global --add safe.directory /home/web/project",
"dockerComposeFile": [
"../deployment/docker-compose.yml",
"../deployment/docker-compose.override.devcontainer.yml"
],
"service": "dev",
"workspaceFolder": "/home/web/project",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
},
"runArgs": [
"--env-file",
"../deployment/.env"
],
"portsAttributes": {
"9000": {
"label": "Frontend",
"onAutoForward": "notify"
}
},
"forwardPorts": [8000, 9000],
"extensions": ["ms-python.python", "ms-azuretools.vscode-docker"],
"shutdownAction": "stopCompose"
}
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deployment/volumes
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use nix
layout python3
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
exclude = */docs/*,*/.tox/*,*/.venv/*,.pycharm_helpers/*,*/migrations/*,docs/*,*/__init__.py,scripts/*,deployment/*,django_project/initialize.py
max-line-length = 79

# E12x continuation line indentation
# E251 no spaces around keyword / parameter equals
# E303 too many blank lines (3)
# F405 name may be undefined, or defined from star imports: module
ignore = E125,E126,E251,E303,F405,W504,W605,F901,D105,W503
extend-exclude=django_project/frontend/node_modules/,django_project/core/settings/secret.py
16 changes: 16 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
98 changes: 98 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Context Layer Management.
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
flake8_py3:
name: Python Lint
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
architecture: x64
- name: Checkout PyTorch
uses: actions/checkout@master
- name: Install flake8
run: pip install flake8
- name: Install flake8-docstrings
run: pip install flake8-docstrings
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'Python Lint' # NOTE: this needs to be the same as the job name
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
django_app_test:
name: 'Django App'
runs-on: ubuntu-latest
env:
APP_IMAGE: kartoza/context_layer_management
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build test image
uses: docker/build-push-action@v2
with:
context: .
file: deployment/docker/Dockerfile
push: false
load: true
target: dev
tags: ${{ env.APP_IMAGE }}:dev
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=test

- name: Run docker-compose services
working-directory: deployment
run: |
echo "Override docker-compose for testing purposes"
cp docker-compose.test.yml docker-compose.override.yml
cp .template.env .env
cd ../
make dev
make wait-db
make dev-entrypoint
make dev-runserver
make dev-load-demo-data
make sleep
- name: Test production config ready
run: make production-check

- name: Test django endpoint
run: |
curl http://localhost:5000/
if [ $? -ne 0 ]; then
echo "Curl command failed"
exit 1
fi
- name: Test E2E
working-directory: ./playwright/ci-test
run: |
npm install
npm ci
npx playwright install --with-deps
npx playwright test --workers 1
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright/ci-test/playwright-report/
retention-days: 30

- name: Test backend
run: make dev-test
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.idea
.venv
.iml
deployment/.env
deployment/docker-compose.override.yml
deployment/volumes

__pycache__/

django_project/.pycharm_helpers/
celerybeat-schedule*
node_modules/
webpack-stats.*
secret.py
coverage.xml

django_project/.env
django_project/tmp/
django_project/frontend/bundles/
django_project/frontend/stats.json
django_project/frontend/package-lock.json
django_project/frontend/webpack-stats.dev.json
django_project/frontend/webpack-stats.prod.json

docs/site/*
docks/mkdocs.yml
.direnv
docs/mkdocs.yml
7 changes: 7 additions & 0 deletions .run/DJANGO+REACT.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="DJANGO+REACT" type="CompoundRunConfigurationType">
<toRun name="Run Server" type="Python.DjangoServer" />
<toRun name="start" type="js.build_tools.npm" />
<method v="2" />
</configuration>
</component>
27 changes: 27 additions & 0 deletions .run/Run Server.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Server" type="Python.DjangoServer" factoryName="Django server">
<module name="django-react-base" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
<env name="DJANGO_SETTINGS_MODULE" value="core.settings.dev" />
</envs>
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/deployment/docker-compose.yml, $PROJECT_DIR$/deployment/docker-compose.override.yml]:dev/python" />
<option name="SDK_NAME" value="KARTOZA_DJANGO_REACT_BASE" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="launchJavascriptDebuger" value="false" />
<option name="port" value="8000" />
<option name="host" value="0.0.0.0" />
<option name="additionalOptions" value="" />
<option name="browserUrl" value="" />
<option name="runTestServer" value="false" />
<option name="runNoReload" value="false" />
<option name="useCustomRunCommand" value="false" />
<option name="customRunCommand" value="" />
<method v="2" />
</configuration>
</component>
12 changes: 12 additions & 0 deletions .run/serve.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="serve" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/django_project/frontend/package.json" />
<command value="run" />
<scripts>
<script value="serve" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
43 changes: 43 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}/django_project/frontend",
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
}
},
{
"name": "Django: Run server",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/django_project/manage.py",
"args": [
"runserver", "8000"
],
"django": true,
"justMyCode": true,
},
{
"command": "npm run serve",
"name": "React: Run webpack-dev-server",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}/django_project/frontend",
},
],
"compounds": [
{
"name": "Django + React",
"configurations": ["Django: Run server", "React: Run webpack-dev-server"],
"stopAll": true
}
]
}
46 changes: 46 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "React: Install dependencies",
"type": "shell",
"command": "npm install",
"options": {
"cwd": "${workspaceFolder}/django_project/frontend"
},
"group": "build",
"problemMatcher": []
},
{
"label": "React: Webpack-dev-server",
"type": "shell",
"command": "npm run serve",
"port": 9000,
"options": {
"cwd": "${workspaceFolder}/django_project/frontend"
},
"group": "build",
"problemMatcher": []
},
{
"label": "Django: Migrate",
"type": "shell",
"command": "python manage.py migrate",
"group": "build",
"options": {
"cwd": "${workspaceFolder}/django_project"
},
"problemMatcher": []
},
{
"label": "Django: Make Migrations",
"type": "shell",
"command": "python manage.py makemigrations",
"group": "build",
"options": {
"cwd": "${workspaceFolder}/django_project"
},
"problemMatcher": []
},
]
}
Loading

0 comments on commit b91f098

Please sign in to comment.