diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 27f461c..b0faa65 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index df669d1..18d71b7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,8 @@ "psycopg", "pytest", "onupdate", - "testdb" + "testdb", + "petstore" ], "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 943efa8..b1725f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index bfb557d..6ca88bf 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Pipfile b/Pipfile index e3f528d..d789783 100644 --- a/Pipfile +++ b/Pipfile @@ -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] diff --git a/setup.cfg b/setup.cfg index b19a387..f6237be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,6 +47,9 @@ exclude_lines = if __name__ == .__main__.: ignore_errors = true +[coverage:xml] +output=./coverage.xml + [coverage:html] title = 'Test Coverage Report'