Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Image for a Python 3 development environment
FROM python:3.11-slim

# Add any tools that are needed beyond Python 3
# Add any tools that are needed beyond Python 3.11
RUN apt-get update && \
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools && \
apt-get autoremove -y && \
Expand All @@ -22,15 +22,14 @@ RUN groupadd --gid $USER_GID $USERNAME \

# Set up the Python development environment
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN sudo python -m pip install --upgrade pip poetry && \
sudo poetry config virtualenvs.create false && \
sudo poetry install
COPY Pipfile Pipfile.lock ./
RUN python -m pip install -U pip pipenv && \
pipenv install --system --dev

# Enable color terminal for docker exec bash
ENV TERM=xterm-256color

EXPOSE 5000
EXPOSE 8080

# Become a regular user for development
USER $USERNAME
13 changes: 10 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"customizations": {
"vscode": {
"settings": {
"cSpell.words": [
"wsgi",
"pytest",
"pipenv",
"Redis",
"testdb"
],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
Expand All @@ -44,6 +51,8 @@
"ms-python.pylint",
"ms-python.flake8",
"ms-python.black-formatter",
"njpwerner.autodocstring",
"wholroyd.jinja",
"ms-vscode.makefile-tools",
"yzhang.markdown-all-in-one",
"DavidAnson.vscode-markdownlint",
Expand All @@ -56,11 +65,9 @@
"github.vscode-github-actions",
"hbenl.vscode-test-explorer",
"LittleFoxTeam.vscode-python-test-adapter",
"njpwerner.autodocstring",
"wholroyd.jinja",
"redhat.vscode-yaml",
"unjinjang.rest-api-client",
"ms-azuretools.vscode-docker",
"rangav.vscode-thunder-client",
"streetsidesoftware.code-spell-checker",
"bbenoist.vagrant"
]
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ venv/
# Byte-compiled
__pycache__/
*.py[cod]
.pytest_cache/
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ jobs:

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.create false
poetry install
python -m pip install pipenv
pipenv install --system --dev

- name: Linting
run: |
Expand All @@ -44,8 +43,8 @@ jobs:
# Run pylint on the service
pylint service tests --max-line-length=127

- name: Run unit tests with PyTest
run: pytest
- name: Run unit tests and generate a coverage report
run: pytest --cov-report=xml
env:
DATABASE_URI: "redis://redis:6379/0"

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ db/*
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/

# C extensions
*.so
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM python:3.11-slim

# Create working folder and install dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN python -m pip install --upgrade pip poetry && \
poetry config virtualenvs.create false && \
poetry install --without dev

# Set up the Python development environment without dev tools
COPY Pipfile Pipfile.lock ./
RUN python -m pip install -U pip pipenv && \
pipenv install --system

# Copy the application contents
COPY wsgi.py .
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ all: help
.PHONY: clean
clean: ## Removes all dangling docker images
$(info Removing all dangling docker images..)
docker image prune -f
-docker image prune -f
-rm .coverage coverage.xml unittests.xml

.PHONY: venv
venv: ## Create a Python virtual environment
$(info Creating Python 3 virtual environment...)
poetry config virtualenvs.in-project true
poetry shell
pipenv shell

.PHONY: install
install: ## Install dependencies
$(info Installing dependencies...)
sudo poetry config virtualenvs.create false
sudo poetry install
pipenv install --dev

.PHONY: lint
lint: ## Run the linter
Expand Down
27 changes: 27 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
flask = "==3.1.0"
redis = "==5.2.1"
flask-redis = "==0.4.0"
retry2 = "==0.9.5"
python-dotenv = "==1.0.1"
gunicorn = "==23.0.0"

[dev-packages]
honcho = "~=2.0.0"
pylint = "~=3.3.4"
flake8 = "~=7.1.1"
black = "~=25.1.0"
pytest = "~=8.3.4"
pytest-pspec = "~=0.0.4"
pytest-cov = "~=6.0.0"
factory-boy = "~=3.3.3"
coverage = "~=7.6.12"
httpie = "~=3.2.4"

[requires]
python_version = "3.11"
Loading