Skip to content

Commit 79d3783

Browse files
authored
Merge pull request #41 from nyu-devops/sp25-updates
Updates for Spring 2025
2 parents f19d26f + 0c58ca2 commit 79d3783

File tree

17 files changed

+1318
-1808
lines changed

17 files changed

+1318
-1808
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ RUN cd /tmp; bash ./install-tools.sh
1111

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

.devcontainer/devcontainer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"Rofrano",
1313
"sqlalchemy",
1414
"psycopg",
15+
"wsgi",
16+
"dotenv",
1517
"pytest",
1618
"tekton",
1719
"creds",
@@ -24,6 +26,7 @@
2426
"git.mergeEditor": true,
2527
"markdown-preview-github-styles.colorTheme": "light",
2628
"makefile.extensionOutputFolder": "/tmp",
29+
"makefile.configureOnOpen": false,
2730
"python.testing.unittestEnabled": false,
2831
"python.testing.pytestEnabled": true,
2932
"python.testing.pytestArgs": [
@@ -49,6 +52,8 @@
4952
"ms-python.pylint",
5053
"ms-python.flake8",
5154
"ms-python.black-formatter",
55+
"njpwerner.autodocstring",
56+
"wholroyd.jinja",
5257
"ms-vscode.makefile-tools",
5358
"yzhang.markdown-all-in-one",
5459
"DavidAnson.vscode-markdownlint",
@@ -61,14 +66,11 @@
6166
"github.vscode-github-actions",
6267
"hbenl.vscode-test-explorer",
6368
"LittleFoxTeam.vscode-python-test-adapter",
64-
"njpwerner.autodocstring",
65-
"wholroyd.jinja",
6669
"redhat.vscode-yaml",
67-
"redhat.fabric8-analytics",
70+
"unjinjang.rest-api-client",
6871
"ms-azuretools.vscode-docker",
6972
"ms-kubernetes-tools.vscode-kubernetes-tools",
7073
"inercia.vscode-k3d",
71-
"rangav.vscode-thunder-client",
7274
"alexkrechik.cucumberautocomplete",
7375
"Zignd.html-css-class-completion",
7476
"streetsidesoftware.code-spell-checker",
@@ -77,6 +79,7 @@
7779
}
7880
},
7981
// Setup the lab environment after container is created
82+
"forwardPorts": [8080],
8083
"postCreateCommand": "bash /app/.devcontainer/scripts/setup-lab.sh",
8184
"features": {
8285
"ghcr.io/devcontainers/features/docker-in-docker:2": {},

.devcontainer/scripts/setup-lab.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# Setup the lab environment after container is started using:
44
# "postCreateCommand": "bash /app/.devcontainer/scripts/setup-lab.sh"
55
#
6+
echo "**********************************************************************"
67
echo "Setting up Flask BDD lab environment..."
8+
echo "**********************************************************************\n"
79

810
# Create .env file if it doesn't exist
911
if [ ! -f .env ]; then
@@ -20,4 +22,6 @@ sudo bash -c "echo '127.0.0.1 cluster-registry' >> /etc/hosts"
2022
# Make git stop complaining about unsafe folders
2123
git config --global --add safe.directory /app
2224

25+
echo "\n**********************************************************************"
2326
echo "Setup complete"
27+
echo "**********************************************************************"

.github/workflows/bdd-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
jobs:
1919
build:
2020
runs-on: ubuntu-latest
21-
container: rofrano/pipeline-selenium:latest
21+
container: quay.io/rofrano/pipeline-selenium:sp25
2222

2323
services:
2424
postgres:
@@ -41,9 +41,8 @@ jobs:
4141

4242
- name: Install dependencies
4343
run: |
44-
python -m pip install -U pip poetry
45-
poetry config virtualenvs.create false
46-
poetry install
44+
python -m pip install -U pip pipenv
45+
pipenv install --system --dev
4746
4847
- name: Run the service locally
4948
run: |

.github/workflows/tdd-tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ jobs:
4242

4343
- name: Install dependencies
4444
run: |
45-
python -m pip install -U pip poetry
46-
poetry config virtualenvs.create false
47-
poetry install
45+
python -m pip install -U pip pipenv
46+
pipenv install --system --dev
4847
4948
- name: Run Code Quality Checks
5049
run: |
@@ -57,10 +56,12 @@ jobs:
5756
5857
- name: Run unit tests with pytest
5958
run: |
60-
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings
59+
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings --cov-report=xml
6160
env:
6261
FLASK_APP: "wsgi:app"
6362
DATABASE_URI: "postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/testdb"
6463

6564
- name: Upload code coverage
6665
uses: codecov/codecov-action@v3.1.4
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}

Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
##################################################
22
# Create production image
33
##################################################
4-
FROM python:3.11-slim
4+
# cSpell: disable
5+
FROM quay.io/rofrano/python:3.11-slim
56

6-
# Establish a working folder
7+
# Set up the Python production environment
78
WORKDIR /app
9+
COPY Pipfile Pipfile.lock ./
10+
RUN python -m pip install --upgrade pip pipenv && \
11+
pipenv install --system --deploy
812

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
14-
15-
# Copy source files last because they change the most
13+
# Copy the application contents
1614
COPY wsgi.py .
1715
COPY service ./service
1816

@@ -23,9 +21,9 @@ USER flask
2321

2422
# Expose any ports the app is expecting in the environment
2523
ENV FLASK_APP=wsgi:app
26-
ENV PORT 8080
24+
ENV PORT=8080
2725
EXPOSE $PORT
2826

29-
ENV GUNICORN_BIND 0.0.0.0:$PORT
27+
ENV GUNICORN_BIND=0.0.0.0:$PORT
3028
ENTRYPOINT ["gunicorn"]
3129
CMD ["--log-level=info", "wsgi:app"]

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@ clean: ## Removes all dangling build cache
2727

2828
venv: ## Create a Python virtual environment
2929
$(info Creating Python 3 virtual environment...)
30-
poetry shell
30+
pipenv shell
3131

3232
install: ## Install Python dependencies
3333
$(info Installing dependencies...)
34-
poetry config virtualenvs.create false
35-
poetry install
34+
sudo pipenv install --system --dev
3635

3736
.PHONY: lint
3837
lint: ## Run the linter
3938
$(info Running linting...)
40-
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
41-
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
42-
pylint service tests --max-line-length=127
39+
-flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
40+
-flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
41+
-pylint service tests --max-line-length=127
4342

4443
.PHONY: test
4544
test: ## Run the unit tests
@@ -61,12 +60,12 @@ secret: ## Generate a secret hex key
6160
.PHONY: cluster
6261
cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
6362
$(info Creating Kubernetes cluster with a registry and 1 node...)
64-
k3d cluster create nyu-devops --agents 1 --registry-create cluster-registry:0.0.0.0:5000 --port '8080:80@loadbalancer'
63+
k3d cluster create $(CLUSTER) --agents 1 --registry-create cluster-registry:0.0.0.0:5000 --port '8080:80@loadbalancer'
6564

6665
.PHONY: cluster-rm
6766
cluster-rm: ## Remove a K3D Kubernetes cluster
6867
$(info Removing Kubernetes cluster...)
69-
k3d cluster delete nyu-devops
68+
k3d cluster delete $(CLUSTER)
7069

7170
##@ Deploy
7271

Pipfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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-sqlalchemy = "~=3.1.1"
9+
psycopg = {extras = ["binary"], version = "~=3.2.4"}
10+
retry2 = "~=0.9.5"
11+
python-dotenv = "~=1.0.1"
12+
gunicorn = "~=23.0.0"
13+
14+
[dev-packages]
15+
honcho = "~=2.0.0"
16+
httpie = "~=3.2.4"
17+
18+
# Code Quality
19+
pylint = "~=3.3.4"
20+
flake8 = "~=7.1.1"
21+
black = "~=25.1.0"
22+
23+
# Test-Driven Development
24+
pytest = "~=8.3.4"
25+
pytest-pspec = "~=0.0.4"
26+
pytest-cov = "~=6.0.0"
27+
factory-boy = "~=3.3.3"
28+
coverage = "~=7.6.12"
29+
30+
# Behavior-Driven Development
31+
behave = "~=1.2.6"
32+
selenium = "==4.16.0" # newer versions do not work
33+
requests = "~=2.31.0"
34+
compare3 = "~=1.0.4"
35+
36+
[requires]
37+
python_version = "3.11"

0 commit comments

Comments
 (0)