Skip to content

Commit

Permalink
Merge branch 'master' into 927-recruitment-rejection-email
Browse files Browse the repository at this point in the history
  • Loading branch information
emsoraffa committed Sep 21, 2024
2 parents 963d28b + df4e06f commit af07a69
Show file tree
Hide file tree
Showing 375 changed files with 11,277 additions and 10,657 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ indent_size = 2

[*.{yml,yaml}]
indent_size = 2

[.eslintrc]
indent_size = 2
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @emilte @Mathias-a @robines @Snorre98
backend/ @robines @Snorre98
frontend/ @robines @Snorre98
backend/ @Mathias-a @robines @Snorre98
frontend/ @Mathias-a @robines @Snorre98
55 changes: 55 additions & 0 deletions .github/ISSUE_TEMPLATE/1-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 🚀 Feature Request
description: Suggest an idea for this project
title: "[FEATURE] <title>"
labels: ["feature"]
body:
- type: checkboxes
attributes:
label: 👀 Is there an existing feature request for this?
description: Please search to see if a feature request already exists for the feature you are suggesting.
options:
- label: I have searched the existing feature requests
required: true
- type: textarea
attributes:
label: 🌟 Feature statement
description: What is your feature request? Please describe.
placeholder: A clear and concise description of what the feature is.
validations:
required: true
- type: textarea
attributes:
label: 👨‍👩‍👦 Is the feature related to some other issue or PR?
description: Pleas give the isse or PR-number.
placeholder: "#issue-number" or "#PR-number"
validations:
required: false
- type: textarea
attributes:
label: 💡 Proposed Solution
description: Describe the solution you'd like
placeholder: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: 🔦 Additional Context
description: Add any other context or screenshots about the feature request here.
validations:
required: false
- type: textarea
attributes:
label: 🗺️ Where on Samfundet4 do you want the feature?
description: Pleas give a file, or general "area" of Samfundet4
validations:
required: true
- type: dropdown
attributes:
label: Priority
description: How important is this feature to you?
options:
- Nice to have
- Important
- Critical
validations:
required: true
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/2-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 🐞 Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: ["Bug"]
body:
- type: checkboxes
attributes:
label: 👀 Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: 🚫 Current Behavior
description: A concise description of what you're experiencing.
validations:
required: true
- type: textarea
attributes:
label: ✅ Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: 🧩 Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
1. With this config...
1. Run '...'
1. See error...
validations:
required: true
- type: textarea
attributes:
label: 🐼 Environment
description: |
examples:
- **OS**: Ubuntu 20.04
- **Node**: 13.14.0
- **npm**: 7.6.3
value: |
- OS:
- Node:
- npm:
render: markdown
validations:
required: false
- type: textarea
attributes:
label: 🦮 Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: true
43 changes: 26 additions & 17 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,41 @@ jobs:

- name: Install dependencies
run: |
python -V
PY=$(which python)
echo $PY
python -m pip install --upgrade pip
python -m pip install poetry
python -m poetry install
source aliases.sh
pip-upgrade
pip-install-poetry
poetry-sync-pipeline
- name: Run ruff
run: |
source aliases.sh
poetry-run-ruff-check
- name: Check ruff format
run: python -m poetry run ruff format --check .
run: |
source aliases.sh
poetry-run-ruff-format-check
- name: Verify migrations
run: |
python -m poetry run python manage.py makemigrations --check --dry-run --noinput --verbosity 2
python -m poetry run python manage.py migrate
source aliases.sh
poetry-run-migrations-verify
poetry-run-migrations-apply
- name: Run tests
run: python -m poetry run pytest

- name: Run ruff
run: python -m poetry run ruff check .
run: |
source aliases.sh
poetry-run-pytest-run
- name: Run mypy
run: python -m poetry run mypy --config-file mypy.ini .
run: |
source aliases.sh
poetry-run-mypy-run
- name: Run seeds
run: python -m poetry run python manage.py seed
run: |
source aliases.sh
poetry-run-seed
job_verify_docker:
name: Verify docker
Expand Down Expand Up @@ -126,8 +135,8 @@ jobs:
- name: Install modules
run: yarn install

- name: Run ESLint
run: yarn run eslint:check
- name: Run Biome
run: yarn run biome:ci

- name: Run stylelint
run: yarn run stylelint:check
Expand Down
2 changes: 0 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
"esbenp.prettier-vscode",
"alexcvzz.vscode-sqlite",
"batisteo.vscode-django",
"dbaeumer.vscode-eslint",
"ms-python.vscode-pylance",
"editorconfig.editorconfig",
"yzhang.markdown-all-in-one",
"stylelint.vscode-stylelint",
"ms-python.mypy-type-checker",
"rvest.vs-code-prettier-eslint",
"visualstudioexptteam.vscodeintellicode"
]
}
7 changes: 0 additions & 7 deletions .vscode/settings.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@
// ================================
// Frontend
// ================================
"eslint.enable": true,
"eslint.format.enable": true,
"html.format.enable": false,
"prettier.configPath": "frontend/.prettierrc.js",
"prettier.ignorePath": "frontend/.prettierignore",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript][javascriptreact][typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.organizeImports": "always"
}
},
"eslint.workingDirectories": ["frontend"],
"[css][scss]": {
"editor.defaultFormatter": "stylelint.vscode-stylelint"
},
Expand Down
7 changes: 0 additions & 7 deletions .vscode/settings.emil.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@
// ================================
// Frontend
// ================================
"eslint.enable": true,
"eslint.format.enable": true,
"html.format.enable": false,
"prettier.configPath": "frontend/.prettierrc.js",
"prettier.ignorePath": "frontend/.prettierignore",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.workingDirectories": ["frontend"],
"[javascript][javascriptreact][typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.organizeImports": "always"
Expand Down
32 changes: 16 additions & 16 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ ENV POETRY_VIRTUALENVS_IN_PROJECT=1
# System dependencies #
##################################
# sqlite3: dependency for billig development database.
# gcc, libpq-dev: psycopg-dependencies.
RUN apt-get update
RUN apt-get install sqlite3 gcc libpq-dev -y
RUN export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH
# gcc, libpq-dev, python3-dev: psycopg-dependencies.
RUN set -eux && \
apt-get update && \
apt-get install -y --no-install-recommends sqlite3 gcc libpq-dev python3-dev && \
python -m pip install poetry && \
rm -rf /var/lib/apt/lists/* && \
export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH


##################################
# Alias #
##################################
RUN echo 'alias la="ls -la"' >> ~/.bashrc
# Useful alias shortcuts for django.
RUN echo 'alias migrate="poetry run python /app/manage.py migrate"' >> ~/.bashrc
RUN echo 'alias makemigrations="poetry run python /app/manage.py makemigrations"' >> ~/.bashrc
RUN echo 'alias seed="poetry run python /app/manage.py seed"' >> ~/.bashrc
RUN echo 'alias collectstatic="poetry run python /app/manage.py collectstatic --noinput"' >> ~/.bashrc
RUN echo 'alias pipeline="poetry run /app/run-pipeline.sh"' >> ~/.bashrc
RUN echo 'alias la="ls -la"' >> ~/.bashrc && \
# Useful alias shortcuts for django.
echo 'alias migrate="poetry run python /app/manage.py migrate"' >> ~/.bashrc && \
echo 'alias makemigrations="poetry run python /app/manage.py makemigrations"' >> ~/.bashrc && \
echo 'alias seed="poetry run python /app/manage.py seed"' >> ~/.bashrc && \
echo 'alias collectstatic="poetry run python /app/manage.py collectstatic --noinput"' >> ~/.bashrc && \
echo 'alias pipeline="poetry run /app/run-pipeline.sh"' >> ~/.bashrc && \
echo 'source aliases.sh' >> ~/.bashrc


# Make directories.
RUN mkdir /app
WORKDIR /app

# Prepare virtual environment.
RUN mkdir .venv
RUN python -m pip install poetry

# Install venv dependecies.
COPY pyproject.toml poetry.lock* ./
RUN python -m poetry install
RUN mkdir .venv && poetry install --sync

# Copy remaining.
COPY . /app
Expand Down
80 changes: 80 additions & 0 deletions backend/aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

##########################
# README: #
##########################
# This is a list of all commands commonly used in the project.
# It was made because poetry doesn't support builtin alias like Pipfile and package.json. Seemed better than installing 3rd party alias tool.
# Preferably this list should be used in all scenarios, but not all environments are alias fiendly (e.g. Dockerfile and non-interactive-shell).
# If you find yourself running a command repeatedly, consider adding it here to share with other developers.


# Pros:
# + Overview of possible commands.
# + Easier to search and find commands used in the project.
# + Autocomplete in terminal, shorter, and easier to use.
# + Ensure developers actually use the same commands.
# + Compatible with "all" tools and package managers.

# Cons:
# - Without more setup, must be sourced manually.
# - Slight risk of overriding personal aliases.

# Run this to apply aliases:
# source aliases.sh


##########################
# _setup: #
##########################
# Enable aliases in CI/CD environments, only available in bash. https://github.com/actions/toolkit/issues/766#issuecomment-928305811
shopt -s expand_aliases


##########################
# misc: #
##########################
alias git-has-change='git diff --quiet' # <filepath>
alias la='ls -la'
alias pip-upgrade='python -m pip install --upgrade pip'
alias pip-install-poetry='python -m pip install poetry'


##########################
# poetry: #
##########################
alias poetry-info='poetry env info'
alias poetry-where='poetry-info' # Find location of environment.
alias poetry-sync='poetry install --sync' # Install the exact dependencies from lockfile.
alias poetry-i='poetry-sync' # Shorter alias for 'poetry-sync'.
alias poetry-s='poetry-sync' # Shorter alias for 'poetry-sync'.
alias poetry-lock='poetry lock --no-update' # Locks current dependencies according to the rules in pyproject.toml. Use to make sure current state is valid. This will not update to latest minors etc. IMPORTANT: it doesn't install anything in venv, use 'poetry-sync' for that.
alias poetry-update='poetry lock' # Updates lock on dependencies according to the rules in pyproject.toml. The file 'poetry.lock' will likely change. IMPORTANT: it doesn't install anything in venv, use 'poetry-sync' for that.
alias poetry-u='poetry-update' # Alias for 'poetry-update'.
alias poetry-sync-prod='poetry install --sync --only main' # Sync of dependencies in production.
alias poetry-sync-pipeline='poetry-lock-check && poetry-sync' # Sync of dependencies in pipeline. Fails if outdated lockfile.
alias poetry-lock-check='(poetry check --lock > /dev/null && poetry-lock > /dev/null; git-has-change poetry.lock) || (echo "Outdated poetry.lock"; exit 1) ' # Utilises builtin (insufficient) check, then performs an actual lock to check diff. This should not result in a changed file.
alias poetry-graph="poetry show --tree" # Show dependency graph.
alias poetry-rm="poetry env remove --all" # Completely remove virtual environment.
alias poetry-shell="poetry shell" # Opens a shell within the virtual environment.
alias poetry-outdated="poetry show --outdated" # Show outdated dependencies.


##########################
# poetry run: #
##########################
# Scripts piped through poetry environment.
alias poetry-run-ruff-check='poetry run ruff check .' # Run ruff check linter on project.
alias poetry-run-ruff-apply='poetry run ruff check --fix .' # Apply ruff linter on project.
alias poetry-run-ruff-format-check='poetry run ruff format --check .' # Dry ruff format on all files in the project.
alias poetry-run-ruff-format-apply='poetry run ruff format .' # Apply ruff format on all files in the project.
alias poetry-run-mypy-run='poetry run mypy --config-file mypy.ini .' # Run mypy on project.

alias poetry-run-migrations-make='poetry run python manage.py makemigrations --noinput' # makemigrations
alias poetry-run-migrations-verify='poetry run python manage.py makemigrations --check --dry-run --noinput --verbosity 2' # Verify that migrations are up-to-date and valid.
alias poetry-run-migrations-apply='poetry run python manage.py migrate' # Apply migrations.
alias poetry-run-collectstatic='poetry run python manage.py collectstatic --noinput' # Collect static files from apps to root of project.

alias poetry-run-pytest-run='poetry run pytest' # Run pytest on project.
alias poetry-run-pipeline='poetry-mypy-run && poetry-ruff-check && poetry-ruff-format-check && poetry-migrations-verify && poetry-pytest-run' # Run all checks in pipeline.
alias poetry-run-seed='poetry run python manage.py seed' # Apply seed of database.
3 changes: 3 additions & 0 deletions backend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

from __future__ import annotations

import os
import sys


def main() -> None:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'root.settings')
try:
from django.core.management import execute_from_command_line

except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
Expand Down
Loading

0 comments on commit af07a69

Please sign in to comment.