Skip to content

Commit

Permalink
Merge pull request #6 from City-of-Turku/server-main-to-master
Browse files Browse the repository at this point in the history
Merge django upgrade to master.
  • Loading branch information
terhisalonen authored Feb 21, 2024
2 parents 2490fb7 + a7e5a37 commit de8618c
Show file tree
Hide file tree
Showing 46 changed files with 1,124 additions and 388 deletions.
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ParkkiHubi",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
"service": "runserver",
"workspaceFolder": "/home/bew/bew",
"runServices": [
"runserver",
"postgresql",
"memcached"
],
"shutdownAction": "stopCompose",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"donjayamanne.githistory",
"eamodio.gitlens",
"davidanson.vscode-markdownlint",
"dakara.transformer"
]
}
},
"postCreateCommand": "cp -n local_settings.py.tpl_dev local_settings.py"
}
5 changes: 5 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
version: '3'
services:
runserver:
command: /bin/sh -c "while sleep 1000; do :; done"
27 changes: 15 additions & 12 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
tests:
strategy:
matrix:
python: ["3.5", "3.6", "3.8"]
runs-on: ubuntu-20.04
container: "python:${{matrix.python}}-slim-buster"
python: ["3.10"] #3.10
runs-on: ubuntu-22.04 #ubuntu:jammy-20231004
# container: "python:${{matrix.python}}-slim-buster"
steps:
- uses: actions/checkout@v3

- name: Update apt-get sources
run: apt-get update
run: sudo apt-get update

- name: Install PostgreSQL, PostGIS and GDAL
run: >
apt-get install -y
sudo apt-get install -y
gdal-bin
python3-gdal
postgis
Expand All @@ -32,14 +32,14 @@ jobs:
build-essential
- name: Start PostgreSQL server
run: /etc/init.d/postgresql start
run: sudo /etc/init.d/postgresql start

- name: Allow root to create PostgreSQL databases
run: su - postgres -c "createuser --createdb root"
- name: Allow runner to create PostgreSQL databases
run: sudo su - postgres -c "createuser --createdb runner"

- name: Create PostGIS extension
run: >
su - postgres
sudo su - postgres
-c "psql template1 -c 'create extension postgis'"
- name: Install Tox and tox-gh-actions
Expand All @@ -52,7 +52,7 @@ jobs:
uses: codecov/codecov-action@v3

test-dockerization:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

Expand All @@ -62,6 +62,9 @@ jobs:
- name: Build Docker image of the app
run: docker-compose build

- name: Copy default configuration as active
run: cp -n local_settings.py.tpl_dev local_settings.py

- name: Start the services with docker-compose up
run: docker-compose up -d

Expand All @@ -72,14 +75,14 @@ jobs:
strategy:
matrix:
toxenv: [style, requirements, sanitizer]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04 #ubuntu:jammy-20231004
steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.5"
python-version: "3.10" #3.10

- name: Install GDAL
run: sudo apt-get install -y gdal-bin
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ tags
# Linux trash folder which might appear on any partition or disk
.Trash-*

# User files
.ssh

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS template
Expand Down Expand Up @@ -56,6 +59,7 @@ Temporary Items
__pycache__/
*.py[cod]
*$py.class
*.pyc

# C extensions
*.so
Expand Down Expand Up @@ -107,6 +111,9 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
mediaroot/
staticroot/
database.db

# Flask stuff:
instance/
Expand Down Expand Up @@ -201,6 +208,9 @@ fabric.properties
Thumbs.db
ehthumbs.db

# New Relic configuration file
newrelic.ini

# Folder config file
Desktop.ini

Expand Down
133 changes: 84 additions & 49 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,86 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django runserver",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": ["runserver"],
"django": true,
"justMyCode": false
},
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"purpose": ["debug-test"],
"justMyCode": false
},
{
"name": "Python: Attach to docker container",
"type": "python",
"request": "attach",
"connect": {"host": "localhost", "port": 5678},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"justMyCode": false
},
{
"name": "Docker: Python - Django",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "django",
"django": true,
"justMyCode": false
}
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Django: Runserver",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"0.0.0.0:8000"
],
"django": true,
"justMyCode": false,
"subProcess": true
},
{
"name": "Django: Runserver - nonthreading",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--nothreading",
"0.0.0.0:8000"
],
"django": true,
"justMyCode": false,
"subProcess": true
},
{
"name": "Django: Shell",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"shell"
],
"django": true,
"justMyCode": false
},
{
"name": "Django: Migrate",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"migrate"
],
"django": true,
"justMyCode": false
},
{
"name": "Django: Make migrations",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"makemigrations"
],
"django": true,
"justMyCode": false
},
{
"name": "Django: Collectstatic",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"collectstatic",
"--no-input"
],
"django": true,
"justMyCode": false
},
{
"name": "Run pytest",
"type": "python",
"request": "launch",
"module": "pytest",
"args": [],
"django": true,
"justMyCode": false
}
]
}
23 changes: 15 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"python.testing.pytestEnabled": true,
"python.testing.cwd": "${workspaceFolder}",
"python.testing.pytestPath": "${workspaceFolder}/run-pytest",
"python.testing.pytestArgs": [
"-vv",
// Uncomment --create-db to refresh test database (after model changes)
// "--create-db",
],
"python.defaultInterpreterPath": "../.venv/bin/python3",
"git.autofetch": true,
"git.autoStash": true,
"git.fetchOnPull": true,
"editor.renderWhitespace": "all",
"editor.renderControlCharacters": true,
"files.trimTrailingWhitespace": true,
"zenMode.hideLineNumbers": false,
"zenMode.centerLayout": false,
"zenMode.fullScreen": false,
"gitlens.codeLens.enabled": false,
"gitlens.currentLine.enabled": false,
"[python]": {
"editor.tabSize": 2
}
}
Loading

0 comments on commit de8618c

Please sign in to comment.