Skip to content

Commit

Permalink
Merge pull request #30 from testdrivenio/updates
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
mjhea0 authored Mar 19, 2023
2 parents 47d3551 + 30171e2 commit ede52f0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 40 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Continuous Integration and Delivery
on: [push]

env:
IMAGE: docker.pkg.github.com/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/summarizer
IMAGE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/summarizer

jobs:

Expand All @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
with:
ref: main
- name: Log in to GitHub Packages
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull images
Expand Down Expand Up @@ -47,11 +47,11 @@ jobs:
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
with:
ref: main
- name: Log in to GitHub Packages
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull images
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
-p 5003:8765 \
${{ env.IMAGE }}-final:latest
- name: Install requirements
run: docker exec fastapi-tdd pip install black==22.10.0 flake8==5.0.4 isort==5.10.1 pytest==7.2.0
run: docker exec fastapi-tdd pip install black==23.1.0 flake8==6.0.0 isort==5.12.0 pytest==7.2.2
- name: Pytest
run: docker exec fastapi-tdd python -m pytest .
- name: Flake8
Expand All @@ -98,15 +98,15 @@ jobs:
runs-on: ubuntu-latest
needs: [build, test]
env:
HEROKU_APP_NAME: guarded-eyrie-00742
HEROKU_APP_NAME: radiant-everglades-49858
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/summarizer
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
with:
ref: main
- name: Log in to GitHub Packages
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull images
Expand Down
2 changes: 1 addition & 1 deletion project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pull official base image
FROM python:3.10.8-slim-buster
FROM python:3.11.2-slim-buster

# set working directory
WORKDIR /usr/src/app
Expand Down
8 changes: 4 additions & 4 deletions project/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###########

# pull official base image
FROM python:3.10.8-slim-buster as builder
FROM python:3.11.2-slim-buster as builder

# install system dependencies
RUN apt-get update \
Expand All @@ -24,7 +24,7 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requir

# lint
COPY . /usr/src/app/
RUN pip install black==22.10.0 flake8==5.0.4 isort==5.10.1
RUN pip install black==23.1.0 flake8==6.0.0 isort==5.12.0
RUN flake8 .
RUN black --exclude=migrations .
RUN isort .
Expand All @@ -35,7 +35,7 @@ RUN isort .
#########

# pull official base image
FROM python:3.10.8-slim-buster
FROM python:3.11.2-slim-buster

# create directory for the app user
RUN mkdir -p /home/app
Expand Down Expand Up @@ -65,7 +65,7 @@ COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
RUN pip install "uvicorn[standard]==0.19.0"
RUN pip install "uvicorn[standard]==0.21.1"

# add app
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion project/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pull official base image
FROM postgres:14-alpine
FROM postgres:15

# run create.sql on init
ADD create.sql /docker-entrypoint-initdb.d
10 changes: 5 additions & 5 deletions project/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
black==22.10.0
flake8==5.0.4
isort==5.10.1
pytest==7.2.0
black==23.1.0
flake8==6.0.0
isort==5.12.0
pytest==7.2.2
pytest-cov==4.0.0
pytest-xdist==3.0.2
pytest-xdist==3.2.1

-r requirements.txt
8 changes: 4 additions & 4 deletions project/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
aerich==0.7.1
asyncpg==0.27.0
fastapi==0.85.1
fastapi==0.94.1
gunicorn==20.1.0
httpx==0.23.3
newspaper3k==0.2.8
requests==2.28.1
tortoise-orm==0.19.2
uvicorn==0.19.0
tortoise-orm==0.19.3
uvicorn==0.21.1
2 changes: 0 additions & 2 deletions project/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_app():
app = create_application()
app.dependency_overrides[get_settings] = get_settings_override
with TestClient(app) as test_client:

# testing
yield test_client

Expand All @@ -38,7 +37,6 @@ def test_app_with_db():
add_exception_handlers=True,
)
with TestClient(app) as test_client:

# testing
yield test_client

Expand Down
19 changes: 5 additions & 14 deletions project/tests/test_summaries_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@


def test_create_summary(test_app, monkeypatch):
def mock_generate_summary(summary_id, url):
return None

monkeypatch.setattr(summaries, "generate_summary", mock_generate_summary)

test_request_payload = {"url": "https://foo.bar"}
test_response_payload = {"id": 1, "url": "https://foo.bar"}

Expand All @@ -15,11 +20,6 @@ async def mock_post(payload):

monkeypatch.setattr(crud, "post", mock_post)

def mock_generate_summary(summary_id, url):
return None

monkeypatch.setattr(summaries, "generate_summary", mock_generate_summary)

response = test_app.post(
"/summaries/",
data=json.dumps(test_request_payload),
Expand Down Expand Up @@ -220,12 +220,3 @@ async def mock_put(id, payload):
response = test_app.put(f"/summaries/{summary_id}/", data=json.dumps(payload))
assert response.status_code == status_code
assert response.json()["detail"] == detail


def test_update_summary_invalid_url(test_app):
response = test_app.put(
"/summaries/1/",
data=json.dumps({"url": "invalid://url", "summary": "updated!"}),
)
assert response.status_code == 422
assert response.json()["detail"][0]["msg"] == "URL scheme not permitted"

0 comments on commit ede52f0

Please sign in to comment.