-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docker * Added dev container * Update docs * Remove bash history from git * Fix git in dev container * Fix debug toolbar bug * Improve docs * Fix devcontainer envs * Add more extensions to dev container * Improve docs * Attempt readme link fix * Link fix didn't work :( * Update docker compose file version * Improve readme * Fix formatting in contributing * Remove old env * fix mypy outside container * Downgrade docker compose version * Fix envs copy * fix devcontainer * Improve devcontainer usability * Try fixing dev container * fix frontend port forward in dev container * try fix port forward again * Fix badges and add codespace * Improve readme * Improve readme layout * Correct logs commands * Add more account info to readme * Simplify envs * Fix config * Test code space automatic forwarding * Prevent browser open when reading node logs * Add healthcheck * Dumb idea to fix port forwarding * Didn't work :( * Update readme * Tslint (#91) * added typescript-eslint * updated code for eslint * Added prettier * Made docker container names consistent * Added prettier to pre-commit * Add node linting to ci * Try fix typescript action * Vote button (#92) * Make running django outside docker easier * Replace list of votes with number * Add server action for vote * Restructured lib/ * Added VoteButtons
- Loading branch information
Showing
80 changed files
with
2,123 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
# | ||
# .bashrc.override.sh | ||
# | ||
|
||
# persistent bash history | ||
HISTFILE=~/.bash_history | ||
PROMPT_COMMAND="history -a; $PROMPT_COMMAND" | ||
|
||
# set some django env vars | ||
source /entrypoint | ||
|
||
# restore default shell options | ||
set +o errexit | ||
set +o pipefail | ||
set +o nounset | ||
|
||
# start ssh-agent | ||
# https://code.visualstudio.com/docs/remote/troubleshooting | ||
eval "$(ssh-agent -s)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// For format details, see https://containers.dev/implementors/json_reference/ | ||
{ | ||
"name": "democrasite_dev", | ||
"dockerComposeFile": ["../docker-compose.local.yml"], | ||
"init": true, | ||
"mounts": [ | ||
{ | ||
"source": "./.devcontainer/bash_history", | ||
"target": "/home/dev-user/.bash_history", | ||
"type": "bind" | ||
}, | ||
{ | ||
"source": "~/.ssh", | ||
"target": "/home/dev-user/.ssh", | ||
"type": "bind" | ||
} | ||
], | ||
// Tells devcontainer.json supporting services / tools whether they should run | ||
// /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command | ||
"overrideCommand": false, | ||
"service": "django", | ||
// Only run direct dependencies of the selected service | ||
"runServices": ["node"], | ||
// "remoteEnv": {"PATH": "/home/dev-user/.local/bin:${containerEnv:PATH}"}, | ||
"remoteUser": "dev-user", | ||
"workspaceFolder": "/app", | ||
"forwardPorts": [3000, 8000], | ||
// Still holding out hope that one day autodiscovery will work in codespaces | ||
"portsAttributes": { | ||
"3000": { | ||
"label": "Frontend" | ||
}, | ||
"8000": { | ||
"label": "Backend" | ||
} | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} | ||
}, | ||
// Set *default* container specific settings.json values on container create. | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"editor.formatOnSave": true, | ||
"[python]": { | ||
"analysis.autoImportCompletions": true, | ||
"analysis.typeCheckingMode": "basic", | ||
"defaultInterpreterPath": "/usr/local/bin/python", | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "always" | ||
}, | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"languageServer": "Pylance", | ||
"linting.enabled": true, | ||
"linting.mypyEnabled": true, | ||
"linting.mypyPath": "/usr/local/bin/mypy" | ||
} | ||
}, | ||
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"davidanson.vscode-markdownlint", | ||
"mrmlnc.vscode-duplicate", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"visualstudioexptteam.intellicode-api-usage-examples", | ||
// python | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"charliermarsh.ruff", | ||
"matangover.mypy", | ||
// django | ||
"batisteo.vscode-django", | ||
"tamasfe.even-better-toml", | ||
"trond-snekvik.simple-rst" | ||
] | ||
} | ||
}, | ||
// Uncomment the next line if you want to keep your containers running after VS Code shuts down. | ||
// "shutdownAction": "none", | ||
"initializeCommand": "cp -rn .envs.template/ .envs/ || echo '.envs/ already exists'", | ||
"postCreateCommand": "cat .devcontainer/bashrc.override.sh >> ~/.bashrc && git config --global --add safe.directory /app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.editorconfig | ||
.gitattributes | ||
.github | ||
.gitignore | ||
.gitlab-ci.yml | ||
.idea | ||
.pre-commit-config.yaml | ||
.readthedocs.yml | ||
.travis.yml | ||
venv | ||
.git | ||
.envs/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copy the .envs.template directory to .envs to provide custom configuration for | ||
# docker-compose.local.yml. Don't forget to set the API keys in this file and .node if | ||
# you want to use authentication | ||
|
||
# General | ||
# ------------------------------------------------------------------------------ | ||
USE_DOCKER=yes | ||
IPYTHONDIR=/app/.ipython | ||
|
||
# Redis | ||
# ------------------------------------------------------------------------------ | ||
REDIS_URL=redis://redis:6379/0 | ||
|
||
# Celery | ||
# ------------------------------------------------------------------------------ | ||
|
||
# Flower | ||
CELERY_FLOWER_USER=user | ||
CELERY_FLOWER_PASSWORD=password | ||
|
||
# Social Auth | ||
# ------------------------------------------------------------------------------ | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_SECRET= | ||
GITHUB_CLIENT_ID= | ||
GITHUB_SECRET= | ||
|
||
# Webiscite | ||
# ------------------------------------------------------------------------------ | ||
GITHUB_WEBHOOK_SECRET= | ||
GITHUB_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# democrasite-frontend/ | ||
|
||
# lib/api | ||
# ------------------------------------------------------------------------------ | ||
BASE_API_URL=http://django:8000 | ||
|
||
# NextAuth | ||
# ------------------------------------------------------------------------------ | ||
GITHUB_CLIENT_ID= | ||
GITHUB_SECRET= | ||
NEXTAUTH_SECRET=secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# PostgreSQL | ||
# ------------------------------------------------------------------------------ | ||
POSTGRES_HOST=postgres | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=democrasite | ||
POSTGRES_USER=user | ||
POSTGRES_PASSWORD=password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
linter: | ||
# Doesn't require docker | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code Repository | ||
|
@@ -29,51 +30,50 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
# Consider using pre-commit.ci for open source project | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
|
||
# With no caching at all the entire ci process takes 4m 30s to complete! | ||
pytest: | ||
# Since these don't run from the root they are difficult to add to pre-commit | ||
typescript: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./democrasite-frontend/ | ||
steps: | ||
- name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "21.x" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
services: | ||
redis: | ||
image: redis:6 | ||
ports: | ||
- 6379:6379 | ||
postgres: | ||
image: postgres:15 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
|
||
env: | ||
CELERY_BROKER_URL: "redis://localhost:6379/0" | ||
# postgres://user:password@host:port/database | ||
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" | ||
- name: Run eslint and tsc | ||
run: npm run lint | ||
|
||
# With no caching at all the entire ci process takes 4m 30s to complete! | ||
pytest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
cache: pip | ||
cache-dependency-path: | | ||
requirements/base.txt | ||
requirements/local.txt | ||
- name: Copy environment files | ||
run: cp -r .envs.template .envs | ||
|
||
- name: Build the Stack | ||
run: docker compose -f docker-compose.local.yml build django | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements/local.txt | ||
- name: Run DB Migrations | ||
run: docker compose -f docker-compose.local.yml run --rm django python manage.py migrate | ||
|
||
- name: Test with pytest and coverage | ||
run: coverage run -m pytest | ||
- name: Run Django Tests | ||
run: docker compose -f docker-compose.local.yml run django pytest | ||
|
||
- name: Send coverage report to codecov | ||
uses: codecov/codecov-action@v3 | ||
- name: Tear down the Stack | ||
run: docker compose -f docker-compose.local.yml down |
Oops, something went wrong.