Skip to content

Commit a118eef

Browse files
authored
Merge pull request #36 from nyu-devops/su24-updates
Updates for Summer 2024 Semester
2 parents bd0d253 + 93937a2 commit a118eef

File tree

14 files changed

+553
-421
lines changed

14 files changed

+553
-421
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM python:3.11-slim
33

44
# Add any tools that are needed beyond Python 3.9
55
RUN apt-get update && \
6-
apt-get install -y sudo vim make git zip tree curl wget jq && \
6+
apt-get install -y sudo vim make git zip tree curl wget jq procps net-tools && \
77
apt-get autoremove -y && \
88
apt-get clean -y
99

@@ -17,10 +17,12 @@ RUN groupadd --gid $USER_GID $USERNAME \
1717
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
1818
&& usermod -aG sudo $USERNAME \
1919
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
20-
&& chmod 0440 /etc/sudoers.d/$USERNAME
20+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
21+
&& chown -R $USERNAME:$USERNAME /home/$USERNAME
2122

2223
# Install poetry stand alone
23-
# RUN curl -sSL https://install.python-poetry.org | python3 -
24+
# RUN curl -sSL https://install.python-poetry.org | python3 - && \
25+
# poetry config virtualenvs.create false
2426

2527
# Set up the Python development environment
2628
WORKDIR /app

.devcontainer/devcontainer.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"customizations": {
99
"vscode": {
1010
"settings": {
11+
"cSpell.words": [
12+
"sqlalchemy",
13+
"psycopg",
14+
"pytest",
15+
"onupdate",
16+
"testdb"
17+
],
1118
"[python]": {
1219
"editor.defaultFormatter": "ms-python.black-formatter",
1320
"editor.formatOnSave": true
@@ -30,27 +37,26 @@
3037
"extensions": [
3138
"ms-python.python",
3239
"ms-python.vscode-pylance",
33-
"VisualStudioExptTeam.vscodeintellicode",
3440
"ms-python.pylint",
3541
"ms-python.flake8",
3642
"ms-python.black-formatter",
43+
"njpwerner.autodocstring",
44+
"wholroyd.jinja",
3745
"ms-vscode.makefile-tools",
3846
"yzhang.markdown-all-in-one",
39-
"hnw.vscode-auto-open-markdown-preview",
4047
"davidanson.vscode-markdownlint",
48+
"bierner.github-markdown-preview",
49+
"hnw.vscode-auto-open-markdown-preview",
4150
"bierner.markdown-preview-github-styles",
4251
"tamasfe.even-better-toml",
4352
"donjayamanne.githistory",
4453
"GitHub.vscode-pull-request-github",
4554
"hbenl.vscode-test-explorer",
4655
"LittleFoxTeam.vscode-python-test-adapter",
47-
"njpwerner.autodocstring",
48-
"wholroyd.jinja",
4956
"redhat.vscode-yaml",
5057
"rangav.vscode-thunder-client",
51-
"redhat.fabric8-analytics",
52-
"streetsidesoftware.code-spell-checker",
5358
"ms-azuretools.vscode-docker",
59+
"redhat.fabric8-analytics",
5460
"github.vscode-github-actions",
5561
"streetsidesoftware.code-spell-checker",
5662
"bbenoist.vagrant"

.devcontainer/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
FLASK_APP: wsgi:app
1717
FLASK_DEBUG: "True"
1818
GUNICORN_BIND: "0.0.0.0:8000"
19-
DATABASE_URI: postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/postgres
19+
DATABASE_URI: postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/petstore
2020
networks:
2121
- dev
2222
depends_on:
@@ -28,6 +28,7 @@ services:
2828
# - 5432:5432
2929
environment:
3030
POSTGRES_PASSWORD: pgs3cr3t
31+
POSTGRES_DB: petstore
3132
volumes:
3233
- postgres:/var/lib/postgresql/data
3334
networks:

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
poetry config virtualenvs.create false
4949
poetry install
5050
51-
- name: Linting
51+
- name: Run Code Quality Checks
5252
run: |
5353
# stop the build if there are Python syntax errors or undefined names
5454
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
@@ -57,11 +57,11 @@ jobs:
5757
# Run pylint on the service
5858
pylint service tests --max-line-length=127
5959
60-
- name: Run unit tests with green
60+
- name: Run unit tests with pytest
6161
run: |
62-
export FLASK_APP=service:app
6362
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings
6463
env:
64+
FLASK_APP: "wsgi:app"
6565
DATABASE_URI: "postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/testdb"
6666

6767
- name: Upload code coverage

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,37 @@ all: help
1010

1111
##@ Development
1212

13+
.PHONY: venv
1314
venv: ## Create a Python virtual environment
1415
$(info Creating Python 3 virtual environment...)
1516
poetry shell
1617

18+
.PHONY: install
1719
install: ## Install Python dependencies
1820
$(info Installing dependencies...)
1921
poetry config virtualenvs.create false
2022
poetry install
2123

24+
.PHONY: lint
2225
lint: ## Run the linter
2326
$(info Running linting...)
2427
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
2528
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
2629
pylint service tests --max-line-length=127
2730

31+
.PHONY: test
2832
test: ## Run the unit tests
2933
$(info Running tests...)
30-
pytest --disable-warnings
34+
export RETRY_COUNT=1; pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings
3135

32-
db-create: ## Creates the database tables
36+
.PHONY: db-init
37+
db-init: ## Initializes the database tables
3338
$(info Creating database tables...)
3439
@flask db-create
3540

3641
##@ Runtime
3742

43+
.PHONY: run
3844
run: ## Run the service
3945
$(info Starting service...)
4046
honcho start

lab/status.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# HTTP status codes
1+
"""
2+
HTTP status codes
3+
"""
4+
25
HTTP_200_OK = 200
36
HTTP_201_CREATED = 201
47
HTTP_204_NO_CONTENT = 204

lab/test_counter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- The API must be RESTful.
66
- The endpoint must be called `/counters`.
77
- When creating a counter, you must specify the name in the path.
8+
- The data returned should be this {"name":"some_name", "counter:0}
89
- Duplicate names must return a 409 conflict error code.
910
- The service must be able to update a counter by name.
1011
- The service must be able to get a counter's current value.

0 commit comments

Comments
 (0)