Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyproject.toml #24

Merged
merged 11 commits into from
Dec 31, 2024
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@ jobs:
uses: psf/[email protected]
- name: isort Lint
uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt requirements-test.txt"
- name: flake8 Lint
uses: py-actions/flake8@v2
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
python-version: "3.10"
- name: Install requirements
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install .
pip install --use-deprecated=legacy-resolver . '.[dev]'
- name: Run pytest
run: pytest
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Byte-compiled / optimized / DLL files
*$py.class
*.py[cod]
__pycache__/

# C extensions
*.so

# Distribution / packaging
*.egg
*.egg-info/
*.py[cod]
*.so
.Python
.eggs/
.installed.cfg
.venv
.venv/
__pycache__/
build/
develop-eggs/
dist/
Expand All @@ -25,4 +21,5 @@ parts/
sdist/
src/
var/
venv/
wheels/
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD
# =====
FROM ubuntu:22.04 as buildstep

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
LABEL maintainer="Richard Bullington-McGuire <[email protected]>"

RUN apt-get update \
Expand All @@ -10,8 +10,9 @@

RUN mkdir -p /build/wheels
RUN pip3 install --upgrade pip setuptools wheel
ADD requirements.txt /tmp/requirements.txt
RUN pip3 wheel -r /tmp/requirements.txt --wheel-dir=/build/wheels
ADD pyproject.toml /tmp
WORKDIR /tmp
RUN pip3 wheel --wheel-dir=/build/wheels .

ADD . /app
WORKDIR /app
Expand All @@ -20,7 +21,7 @@

# DEPLOY
# =====
FROM ubuntu:22.04 as deploystep

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
LABEL maintainer="Richard Bullington-McGuire <[email protected]>"

RUN apt-get update \
Expand All @@ -32,7 +33,9 @@

RUN pip3 install --upgrade pip setuptools wheel
COPY --from=buildstep /build/wheels /tmp/wheels
RUN pip3 install /tmp/wheels/*
# Thanks https://stackoverflow.com/a/74634740/424301 for the tip on
# using --use-deprecated=legacy-resolver
RUN pip3 install --use-deprecated=legacy-resolver /tmp/wheels/*

EXPOSE 8000
ENTRYPOINT gunicorn --bind 0.0.0.0:8000 'freezing.nq.app:make_app()'

Check warning on line 41 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
2 changes: 1 addition & 1 deletion freezing/nq/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def publish_message(self, message: Any, dest: DefinedTubes):

:param message: A message object that can be serialized with json.dumps()
"""
queue = greenstalk.Client(host=self.host, port=self.port, use=dest.value)
queue = greenstalk.Client((self.host, self.port), use=dest.value)
try:
queue.put(self.serialize_message(message))
except Exception as ex:
Expand Down
75 changes: 75 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,77 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "freezing-nq"
version = "0.4.3"
description = "Freezing Saddles activity receive and enqueue worker"
readme = "README.md"
authors = [
{name = "Hans Lellelid", email = "[email protected]"},
{name = "Richard Bullington-McGuire", email = "[email protected]"},
]
maintainers = [
{name = "Richard Bullington-McGuire", email="[email protected]"},
]
license = {text = "Apache License (2.0)"}
dependencies = [
"arrow==1.3.0",
"envparse==0.2.0",
"falcon==4.0.2",
"freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.11.2.tar.gz",
"greenstalk==2.0.2",
"gunicorn==22.0.0",
"python-mimeparse==1.6.0",
"six==1.16.0",
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Topic :: Games",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Natural Language :: English",
]

[project.optional-dependencies]
dev = [
"bandit",
"black",
"fawltydeps",
"flake8",
"flake8-pyproject",
"flake8-bugbear",
"flake8-builtins",
"flake8-comprehensions",
"flake8-docstrings",
"flake8-eradicate",
"flake8-print",
"flake8-return",
"flake8-simplify",
"flake8-sorted-keys",
"flake8-todo",
"flake8-raise",
"isort",
"mypy",
"pytest",
"pytest-mock",
]

[tool.isort]
profile = "black"

[tool.flake8]
# Thanks https://www.reddit.com/r/learnpython/comments/rr6y69/comment/hqeqt68/?utm_source=share&utm_medium=web2x&context=3
ignore = [
"E203",
"E501",
"W503",
"W503",
]
max-line-length = 88
max-complexity = 39
extend-ignore = "E203"
inline-quotes = "double"
6 changes: 0 additions & 6 deletions requirements-test.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

17 changes: 0 additions & 17 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,3 @@ def test_post_webhook(client, publisher: ActivityPublisher):
publisher.publish_message.assert_called_with(
called_with, dest=DefinedTubes.activity_update
)


# def test_post_webhook_noop(client, publisher:ActivityPublisher):
#
# d = dict(
# subscription_id=111,
# owner_id=222,
# object_type='activity',
# object_id=999,
# aspect_type='update',
# updates={},
# event_time=1358919359,
# )
#
# client.simulate_post('/webhook', body=json.dumps(d), headers={'content-type': 'application/json'})
#
# publisher.publish_message.assert_not_called()
Loading