Skip to content

Updates for Summer 2025 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 8, 2025
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
28 changes: 3 additions & 25 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
# Image for a Python 3 development environment
FROM python:3.11-slim

# 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 && \
apt-get clean -y

# Create a user for development
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user with passwordless sudo privileges
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
&& usermod -aG sudo $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown -R $USERNAME:$USERNAME /home/$USERNAME
FROM quay.io/rofrano/nyu-devops-base:su25

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

ENV PORT=8000
EXPOSE $PORT

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

# Become a regular user
USER $USERNAME
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"psycopg",
"pytest",
"onupdate",
"testdb"
"testdb",
"petstore"
],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,21 @@ jobs:
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
# check for complexity. The GitHub editor is 127 chars wide
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
# Run pylint on the service
# Run pylint on the service package
pylint service tests --max-line-length=127

- name: Run unit tests with pytest
run: |
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings --cov-report=xml
env:
FLASK_APP: "wsgi:app"
DATABASE_URI: "postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/testdb"

- name: Upload code coverage
uses: codecov/codecov-action@v3.1.4
- name: Install packages for Codecov to work
run: apt update && apt install -y git curl gpg

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: nyu-devops/lab-flask-tdd
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ all: help
.PHONY: venv
venv: ## Create a Python virtual environment
$(info Creating Python 3 virtual environment...)
poetry shell
pipenv shell

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

.PHONY: lint
lint: ## Run the linter
Expand Down
16 changes: 8 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ flask = "==3.1.1"
flask-sqlalchemy = "==3.1.1"
psycopg = {extras = ["binary"], version = "==3.2.4"}
retry2 = "==0.9.5"
python-dotenv = "==1.0.1"
gunicorn = "==23.0.0"
python-dotenv = "~=1.1.0"
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"
coverage = "~=7.8.2"
flake8 = "~=7.2.0"
pylint = "~=3.3.7"
pytest = "~=8.3.5"
pytest-pspec = "~=0.0.4"
pytest-cov = "~=6.0.0"
pytest-cov = "~=6.1.1"
factory-boy = "~=3.3.3"
coverage = "~=7.6.12"
honcho = "~=2.0.0"
httpie = "~=3.2.4"

[requires]
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ exclude_lines =
if __name__ == .__main__.:
ignore_errors = true

[coverage:xml]
output=./coverage.xml

[coverage:html]
title = 'Test Coverage Report'