Skip to content

Commit

Permalink
Changes for Summer 2023 Semester
Browse files Browse the repository at this point in the history
  • Loading branch information
rofrano committed Jul 17, 2023
1 parent e8f265e commit c3beed4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Image for a Python 3 development environment
FROM rofrano/nyu-devops-base:sp23
FROM rofrano/nyu-devops-base:su23

# Set up the Python development environment
WORKDIR /app
Expand Down
9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ms-python.pylint",
"ms-python.vscode-pylance",
"wholroyd.jinja",
"alexkrechik.cucumberautocomplete",
"ms-python.black-formatter",
"yzhang.markdown-all-in-one",
"bierner.github-markdown-preview",
"hnw.vscode-auto-open-markdown-preview",
Expand All @@ -24,13 +24,15 @@
"hbenl.vscode-test-explorer",
"LittleFoxTeam.vscode-python-test-adapter",
"njpwerner.autodocstring",
"github.vscode-github-actions",
"rangav.vscode-thunder-client",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"inercia.vscode-k3d",
"bbenoist.vagrant",
"IBM.ibmcloud-account",
"streetsidesoftware.code-spell-checker"
]
]
}
},

Expand All @@ -40,8 +42,7 @@
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
"ghcr.io/rio/features/skaffold:2": {}
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: python:3.9-slim
container: python:3.11-slim

# Required services
services:
Expand Down Expand Up @@ -53,20 +53,18 @@ jobs:
- name: Linting
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
# Run pylint on the service
pylint service
pylint service tests --max-line-length=127
- name: Run unit tests with nose
run: |
export FLASK_APP=service:app
nosetests
green
env:
DATABASE_URI: "postgresql://postgres:pgs3cr3t@postgres:5432/testdb"

- name: Upload code coverage
uses: codecov/codecov-action@v2
with:
version: "v0.1.13"
uses: codecov/[email protected]
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-slim
FROM python:3.11-slim

# Added libraries for PostgreSQL before pip install
RUN apt-get update && apt-get install -y gcc libpq-dev
Expand All @@ -13,8 +13,8 @@ RUN pip install -U pip wheel && \
COPY service/ ./service/

# Switch to a non-root user
RUN useradd --uid 1000 vagrant && chown -R vagrant /app
USER vagrant
RUN useradd --uid 1001 flask && chown -R flask /app
USER flask

# Expose any ports the app is expecting in the environment
ENV FLASK_APP=service:app
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lint: ## Run the linter
.PHONY: test
test: ## Run the unit tests
$(info Running tests...)
nosetests --with-spec --spec-color
green -vvv --processes=1 --run-coverage --termcolor --minimum-coverage=95

.PHONY: run
run: ## Run the service
Expand Down
14 changes: 7 additions & 7 deletions deploy/postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ spec:
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
# resources:
# limits:
# cpu: "0.20"
# memory: "64Mi"
# requests:
# cpu: "0.10"
# memory: "32Mi"
resources:
limits:
cpu: "0.50"
memory: "256Mi"
requests:
cpu: "0.25"
memory: "128Mi"
volumes:
- name: postgres-storage
emptyDir: {}
Expand Down
14 changes: 5 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Pinned dependencies that cause breakage
Werkzeug==2.2.3
Werkzeug==2.3.3
SQLAlchemy==2.0.0

# Runtime dependencies
Flask==2.2.3
Flask==2.3.2
Flask-SQLAlchemy==3.0.2
psycopg2==2.9.5
python-dotenv==0.21.1

# Runtime dependencies
# Runtime tools
gunicorn==20.1.0
honcho==1.1.0

Expand All @@ -18,13 +18,9 @@ flake8==6.0.0
black==23.1.0

# Testing dependencies
nose==1.3.7
pinocchio==0.4.3
green==3.4.3
factory-boy==3.2.1

# Code Coverage
coverage==7.1.0
codecov==2.1.12

# Utilities
httpie==3.2.1
httpie==3.2.1
45 changes: 30 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
[nosetests]
verbosity=2
with-spec=1
spec-color=1
with-coverage=1
cover-erase=1
cover-package=service
exe=1
cover-xml=1
cover-xml-file=./coverage.xml
# with-xunit=1
# xunit-file=./unittests.xml

[coverage:report]
show_missing = True
[green]
verbose=3
processes=1
run-coverage=1
termcolor=1
minimum-coverage=95
junit-report=./unittests.xml

[flake8]
max-line-length = 127
per-file-ignores =
*/__init__.py: F401 E402

[pylint.'MESSAGES CONTROL']
disable=E1101

[coverage:run]
source = service
omit =
venv/*
.venv/*

[coverage:report]
show_missing = true
exclude_lines =
pragma: no cover
pragma: no branch
pass
subprocess.CalledProcessError
sys.exit
if __name__ == .__main__.:
ignore_errors = true

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

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

0 comments on commit c3beed4

Please sign in to comment.