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

Add required ReadTheDocs configuration, update CI config #183

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/python-ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']

name: Python ${{ matrix.python-version }} Build
steps:
Expand All @@ -27,14 +27,12 @@ jobs:
pip install -U pip setuptools
pip install tox-gh-actions
pip install codecov
- name: Create test user
run: |
mongo admin --eval 'db.createUser({user:"travis",pwd:"test",roles:[{role:"root",db:"admin"}]});'
- name: Test with Tox
run: |
tox
- name: Upload coverage information to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4.2.0
with:
fail_ci_if_error: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- repo: https://github.com/PyCQA/flake8
rev: 3.8.4
rev: 7.0.0
hooks:
- id: flake8
name: Check project styling
args:
- --max-line-length=160
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
rev: 5.13.2
hooks:
- id: isort
name: Sort python imports (shows diff)
Expand Down
27 changes: 27 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build all formats (incl. pdf, epub)
formats: all

# Declare the Python requirements required to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- docs
9 changes: 6 additions & 3 deletions medallion/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from six import iteritems

APPLICATION_INSTANCE = Flask("medallion")
APPLICATION_INSTANCE.taxii_config = {}
APPLICATION_INSTANCE.usersconfig = {}
APPLICATION_INSTANCE.backend_config = {}


def create_resource(resource_name, items, more=False, next_id=None):
Expand Down Expand Up @@ -276,16 +279,16 @@ def start(self):
def get_application_instance_config_values(flask_application_instance, config_group, config_key=None):
if config_group == "taxii":
if flask_application_instance.taxii_config and config_key in flask_application_instance.taxii_config:
return flask_application_instance.taxii_config[config_key]
return flask_application_instance.taxii_config.get(config_key)
else:
return flask_application_instance.taxii_config
if config_group == "users":
if flask_application_instance.users_config and config_key in flask_application_instance.users_config:
return flask_application_instance.users_config[config_key]
return flask_application_instance.users_config.get(config_key)
else:
return flask_application_instance.users_config
if config_group == "backend":
if flask_application_instance.backend_config and config_key in flask_application_instance.backend_config:
return flask_application_instance.backend_config[config_key]
return flask_application_instance.backend_config.get(config_key)
else:
return flask_application_instance.backend_config
2 changes: 1 addition & 1 deletion medallion/views/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_version_parameter_in_content_type_header():


def validate_limit_parameter():
max_page = current_app.taxii_config["max_page_size"]
max_page = current_app.taxii_config.get("max_page_size")
limit = request.args.get("limit", max_page)
try:
limit = int(limit)
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def get_long_description():
"Topic :: Security",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="taxii taxii2 server json cti cyber threat intelligence",
packages=find_packages(exclude=["*.test", "*.test.data"]),
Expand Down
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[tox]
envlist = py36,py37,py38,py39,packaging,pre-commit-check
envlist = py{38,39,310,311,312},packaging,pre-commit-check

[testenv]
deps =
-U
tox
pytest
pytest-cov
Expand All @@ -12,14 +11,17 @@ deps =
responses
pymongo
pyjwt
setuptools
commands =
pytest --cov=medallion medallion/test/ --cov-report term-missing

passenv = GITHUB_*

[testenv:packaging]
deps =
setuptools
twine
wheel
commands =
python setup.py sdist bdist_wheel --universal
twine check dist/*
Expand All @@ -32,7 +34,8 @@ commands =

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39, packaging, pre-commit-check
3.9: py39
3.10: py310
3.11: py311
3.12: py312, packaging, pre-commit-check
Loading