Skip to content

Commit 4295e21

Browse files
authored
Merge pull request #33 from nyu-devops/sp25-updates
Updates for the Spring 2025 Semester
2 parents ff0313d + 5393eaa commit 4295e21

File tree

13 files changed

+1276
-1609
lines changed

13 files changed

+1276
-1609
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
# Image for a Python 3 development environment
2-
FROM python:3.11-slim
3-
4-
# Add any tools that are needed beyond Python 3.11
5-
RUN apt-get update && \
6-
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools && \
7-
apt-get autoremove -y && \
8-
apt-get clean -y
9-
10-
# Create a user for development
11-
ARG USERNAME=devops
12-
ARG USER_UID=1000
13-
ARG USER_GID=$USER_UID
14-
15-
# Create the user with passwordless sudo privileges
16-
RUN groupadd --gid $USER_GID $USERNAME \
17-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
18-
&& usermod -aG sudo $USERNAME \
19-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
20-
&& chmod 0440 /etc/sudoers.d/$USERNAME
2+
FROM rofrano/nyu-devops-base:sp25
213

224
# Set up the Python development environment
235
WORKDIR /app
24-
COPY pyproject.toml poetry.lock ./
25-
RUN python -m pip install -U pip poetry && \
26-
poetry config virtualenvs.create false && \
27-
poetry install
6+
COPY Pipfile Pipfile.lock ./
7+
RUN sudo python -m pip install -U pip pipenv && \
8+
sudo pipenv install --system --dev
289

29-
ENV PORT 8080
10+
ENV PORT=8080
3011
EXPOSE $PORT
31-
32-
# Enable color terminal for docker exec bash
33-
ENV TERM=xterm-256color
34-
35-
# Become a regular user
36-
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
"dockerComposeFile": "docker-compose.yml",
55
"service": "app",
66
"workspaceFolder": "/app",
7-
"remoteUser": "devops",
7+
"remoteUser": "vscode",
88
"customizations": {
99
"vscode": {
1010
"settings": {
1111
"cSpell.words": [
12-
"sqlalchemy",
13-
"psycopg",
12+
"wsgi",
13+
"Coudant",
14+
"CLOUDANT",
15+
"DBNAME",
16+
"petshop",
1417
"pytest",
18+
"restplus",
19+
"RESTX",
20+
"CSCI",
21+
"pipenv",
1522
"virtualenvs"
1623
],
1724
"[python]": {
@@ -47,8 +54,8 @@
4754
"cstrap.flask-snippets",
4855
"ms-vscode.makefile-tools",
4956
"yzhang.markdown-all-in-one",
50-
"bierner.github-markdown-preview",
5157
"davidanson.vscode-markdownlint",
58+
"bierner.github-markdown-preview",
5259
"hnw.vscode-auto-open-markdown-preview",
5360
"bierner.markdown-preview-github-styles",
5461
"tamasfe.even-better-toml",
@@ -57,7 +64,7 @@
5764
"hbenl.vscode-test-explorer",
5865
"LittleFoxTeam.vscode-python-test-adapter",
5966
"redhat.vscode-yaml",
60-
"rangav.vscode-thunder-client",
67+
"unjinjang.rest-api-client",
6168
"ms-azuretools.vscode-docker",
6269
"github.vscode-github-actions",
6370
"streetsidesoftware.code-spell-checker",

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
depends_on:
2323
- couchdb
2424

25-
# CouchDB Dashboard: http://127.0.0.1:5984/_utils"
25+
# The CouchDB Dashboard is at: http://127.0.0.1:5984/_utils"
2626
couchdb:
2727
image: couchdb:latest
2828
hostname: couchdb

.github/workflows/build.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,22 @@ jobs:
3434
--health-retries 5
3535
3636
steps:
37-
- uses: actions/checkout@v2
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
40+
- name: Install Python package dependencies
41+
run: |
42+
python -m pip install -U pip pipenv
43+
pipenv install --system --dev
3844
39-
- name: Install dependencies
45+
- name: Run Code Quality Checks
4046
run: |
41-
python -m pip install -U pip poetry
42-
poetry config virtualenvs.create false
43-
poetry install
47+
# stop the build if there are Python syntax errors or undefined names
48+
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
49+
# check for complexity. The GitHub editor is 127 chars wide
50+
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
51+
# Run pylint on the service
52+
pylint service tests --max-line-length=127
4453
4554
- name: Create the test database
4655
run: |
@@ -49,11 +58,16 @@ jobs:
4958
curl -X PUT http://admin:pass@couchdb:5984/test
5059
5160
- name: Run unit tests with pytest
52-
run: pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings
61+
run: pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings --cov-report=xml
5362
env:
5463
FLASK_APP: "wsgi:app"
5564
BINDING_CLOUDANT: '{"username":"admin","password":"pass","host":"couchdb","port":5984,"url":"http://admin:pass@couchdb:5984"}'
5665

57-
- name: Upload code coverage
58-
uses: codecov/codecov-action@v3.1.4
66+
- name: Install packages required by Codecov
67+
run: apt-get update && apt-get install -y git curl gpg
5968

69+
- name: Upload coverage reports to Codecov
70+
uses: codecov/codecov-action@v5
71+
with:
72+
token: ${{ secrets.CODECOV_TOKEN }}
73+
slug: nyu-devops/lab-flask-restplus-swagger

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ FROM python:3.11-slim
66
# Establish a working folder
77
WORKDIR /app
88

9-
# Establish dependencies
10-
COPY pyproject.toml poetry.lock ./
11-
RUN python -m pip install poetry && \
12-
poetry config virtualenvs.create false && \
13-
poetry install --without dev
9+
# Establish dependencies without dev tools
10+
COPY Pipfile Pipfile.lock ./
11+
RUN python -m pip install -U pip pipenv && \
12+
pipenv install --system
1413

1514
# Copy source files last because they change the most
1615
COPY wsgi.py .
@@ -23,7 +22,7 @@ USER flask
2322

2423
# Expose any ports the app is expecting in the environment
2524
ENV FLASK_APP=wsgi:app
26-
ENV PORT 8080
25+
ENV PORT=8080
2726
EXPOSE $PORT
2827

2928
ENV GUNICORN_BIND 0.0.0.0:$PORT

Pipfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
flask = "==3.1.0"
8+
flask-restx = "==1.3.0"
9+
cloudant = "==2.15.0"
10+
urllib3 = "==1.26.19" # DO NOT upgrade this!
11+
retry2 = "==0.9.5"
12+
python-dotenv = "==1.0.1"
13+
gunicorn = "==23.0.0"
14+
15+
[dev-packages]
16+
honcho = "~=2.0.0"
17+
pylint = "~=3.3.4"
18+
flake8 = "~=7.1.1"
19+
black = "~=25.1.0"
20+
pytest = "~=8.3.4"
21+
pytest-pspec = "~=0.0.4"
22+
pytest-cov = "~=6.0.0"
23+
factory-boy = "~=3.3.3"
24+
coverage = "~=7.6.12"
25+
httpie = "~=3.2.4"
26+
27+
[requires]
28+
python_version = "3.11"

0 commit comments

Comments
 (0)