Skip to content

Commit 25f624c

Browse files
authored
Merge pull request #11 from nyu-devops/spring24-updates
Updates for Spring 2024 Semester
2 parents de94f2b + 66b0cac commit 25f624c

File tree

22 files changed

+1733
-559
lines changed

22 files changed

+1733
-559
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Image for a Python 3 development environment
2-
FROM python:3.9-slim
2+
FROM python:3.11-slim
33

44
# Add any tools that are needed beyond Python
55
RUN apt-get update && \
@@ -21,8 +21,10 @@ RUN groupadd --gid $USER_GID $USERNAME \
2121

2222
# Set up the Python development environment
2323
WORKDIR /app
24-
RUN python -m pip install --upgrade pip && \
25-
pip install --upgrade wheel
24+
COPY pyproject.toml poetry.lock ./
25+
RUN sudo python -m pip install --upgrade pip poetry && \
26+
sudo poetry config virtualenvs.create false && \
27+
sudo poetry install
2628

2729
# Enable color terminal for docker exec bash
2830
ENV TERM=xterm-256color

.devcontainer/devcontainer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
// cSpell: disable
12
{
23
"name": "Python 3 & Redis",
34
"dockerComposeFile": "docker-compose.yml",
45
"service": "app",
56
"workspaceFolder": "/app",
67
"remoteUser": "devops",
7-
88
"customizations": {
99
"vscode": {
1010
"settings": {
@@ -14,11 +14,11 @@
1414
},
1515
"markdown-preview-github-styles.colorTheme": "light",
1616
"makefile.extensionOutputFolder": "/tmp",
17+
"python.testing.unittestEnabled": false,
18+
"python.testing.pytestEnabled": true,
1719
"python.testing.pytestArgs": [
1820
"tests"
1921
],
20-
"python.testing.unittestEnabled": false,
21-
"python.testing.pytestEnabled": true,
2222
"files.exclude": {
2323
"**/.git": true,
2424
"**/.DS_Store": true,
@@ -33,18 +33,18 @@
3333
"ms-python.pylint",
3434
"ms-python.flake8",
3535
"ms-python.black-formatter",
36-
"njpwerner.autodocstring",
37-
"wholroyd.jinja",
3836
"ms-vscode.makefile-tools",
39-
"tamasfe.even-better-toml",
4037
"yzhang.markdown-all-in-one",
4138
"hnw.vscode-auto-open-markdown-preview",
42-
"bierner.markdown-preview-github-styles",
4339
"davidanson.vscode-markdownlint",
40+
"bierner.markdown-preview-github-styles",
41+
"tamasfe.even-better-toml",
4442
"donjayamanne.githistory",
4543
"GitHub.vscode-pull-request-github",
4644
"hbenl.vscode-test-explorer",
4745
"LittleFoxTeam.vscode-python-test-adapter",
46+
"njpwerner.autodocstring",
47+
"wholroyd.jinja",
4848
"redhat.vscode-yaml",
4949
"ms-azuretools.vscode-docker",
5050
"ms-kubernetes-tools.vscode-kubernetes-tools",
@@ -55,5 +55,5 @@
5555
]
5656
}
5757
},
58-
"postCreateCommand": "sudo pip install -r requirements.txt"
58+
// "postCreateCommand": "bash /app/.devcontainer/scripts/post-install.sh"
5959
}

.github/workflows/ci.yaml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,51 @@ on:
33
push:
44
branches:
55
- master
6+
paths-ignore:
7+
- 'README.md'
68
pull_request:
79
branches:
810
- master
11+
paths-ignore:
12+
- 'README.md'
913

1014
jobs:
1115
build:
1216
runs-on: ubuntu-latest
13-
container: python:3.9-slim
17+
container: python:3.11-slim
1418

1519
# Required services
1620
services:
1721
redis:
1822
image: redis:6-alpine
1923
ports:
2024
- 6379:6379
25+
options: >-
26+
--health-cmd "redis-cli ping"
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
2130
2231
steps:
2332
- name: Checkout code
24-
uses: actions/checkout@v2
25-
33+
uses: actions/checkout@v3
34+
2635
- name: Install Python dependencies
2736
run: |
28-
python -m pip install --upgrade pip wheel
29-
pip install -r requirements.txt
37+
python -m pip install --upgrade pip poetry
38+
poetry config virtualenvs.create false
39+
poetry install
3040
3141
- name: Linting
3242
run: |
33-
# stop the build if there are Python syntax errors or undefined names
3443
flake8 service --count --select=E9,F63,F7,F82 --show-source --statistics
35-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3644
flake8 service --count --max-complexity=10 --max-line-length=127 --statistics
45+
pylint service --max-line-length=127
3746
38-
- name: Run unit tests with nose
39-
run: nosetests -v --with-spec --spec-color --with-coverage --cover-package=app
47+
- name: Run unit tests with PyTest
48+
run: pytest --pspec --cov=service --cov-fail-under=95
4049
env:
41-
DATABASE_URI: "redis://redis:6379/0"
50+
DATABASE_URI: "redis://redis:6379"
4251

4352
- name: Upload code coverage
44-
uses: codecov/codecov-action@v2
45-
with:
46-
files: ./coverage.xml
47-
flags: unittests
48-
version: "v0.1.13"
53+
uses: codecov/codecov-action@v3.1.4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ celerybeat-schedule
9999
.env
100100

101101
# virtualenv
102+
.venv/
102103
venv/
103104
ENV/
104105

.pylintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ all: help
77

88
venv: ## Create a Python virtual environment
99
$(info Creating Python 3 virtual environment...)
10-
python3 -m venv .venv
10+
poetry shell
1111

1212
install: ## Install dependencies
1313
$(info Installing dependencies...)
14-
sudo pip install -r requirements.txt
14+
sudo poetry install
1515

1616
lint: ## Run the linter
1717
$(info Running linting...)
1818
flake8 service --count --select=E9,F63,F7,F82 --show-source --statistics
1919
flake8 service --count --max-complexity=10 --max-line-length=127 --statistics
20+
pylint service --max-line-length=127
2021

2122
test: ## Run the unit tests
22-
$(info Running tests...)
23-
nosetests --with-spec --spec-color
23+
$(info Running unit tests...)
24+
pytest
2425

2526
run: ## Run the service
2627
$(info Starting service...)

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: gunicorn --bind 0.0.0.0:$PORT --log-level=info service:app
1+
web: gunicorn --bind 0.0.0.0:$PORT --log-level=info wsgi:app

0 commit comments

Comments
 (0)