Skip to content

Commit 2667471

Browse files
committed
Merge branch 'master' of github.com:Koen1999/suricata-check-extension-example
2 parents 9ae40b0 + 78ee282 commit 2667471

8 files changed

Lines changed: 117 additions & 51 deletions

File tree

.github/workflows/python-pr.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313
jobs:
1414
test:
1515
name: Quick Test
16-
runs-on: ubuntu-latest
16+
runs-on: self-hosted
1717

1818
strategy:
1919
fail-fast: true
@@ -49,7 +49,7 @@ jobs:
4949
5050
build:
5151
name: Build
52-
runs-on: ubuntu-latest
52+
runs-on: self-hosted
5353
needs:
5454
- test
5555

@@ -77,7 +77,7 @@ jobs:
7777
7878
lint:
7979
name: Lint
80-
runs-on: ubuntu-latest
80+
runs-on: self-hosted
8181
needs:
8282
- build
8383

@@ -103,7 +103,6 @@ jobs:
103103
104104
- name: Lint with flake8
105105
run: |
106-
# stop the build if there are Python syntax errors or undefined names
107106
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
108107
109108
- name: Type checking with Pyright
@@ -117,3 +116,32 @@ jobs:
117116
- name: Lint with Ruff
118117
run: |
119118
ruff check --output-format=github .
119+
120+
docs:
121+
name: Docs
122+
runs-on: self-hosted
123+
needs:
124+
- lint
125+
126+
strategy:
127+
fail-fast: false
128+
129+
steps:
130+
- uses: actions/checkout@v4
131+
132+
- name: Set up Python 3.13
133+
uses: actions/setup-python@v5
134+
with:
135+
python-version: "3.13"
136+
cache: "pip"
137+
138+
- name: Install dependencies
139+
run: |
140+
python -m pip install --upgrade pip setuptools wheel build
141+
pip install -r requirements.txt
142+
143+
- name: Generate docs with sphinx
144+
run: |
145+
cd docs
146+
make clean
147+
make html

.github/workflows/python-release.yml

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
test:
99
name: Test Release
10-
runs-on: ubuntu-latest
10+
runs-on: self-hosted
1111

1212
strategy:
1313
fail-fast: true
@@ -33,7 +33,7 @@ jobs:
3333
3434
- name: Test with pytest (slow)
3535
run: |
36-
pytest -m "slow"
36+
pytest -m "slow" --cov-fail-under=0
3737
3838
release-build:
3939
name: Build Release
@@ -43,20 +43,61 @@ jobs:
4343

4444
strategy:
4545
fail-fast: true
46-
matrix:
47-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
4846

4947
steps:
50-
- uses: actions/checkout@v4
48+
- name: Checkout release code
49+
uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
5152

5253
- uses: actions/setup-python@v5
5354
with:
54-
python-version: ${{ matrix.python-version }}
55+
python-version: "3.x"
5556

5657
- name: Install most recent build dependencies
5758
run: |
58-
python -m pip install --upgrade build --upgrade-strategy eager
59+
python -m pip install --upgrade pip --upgrade-strategy eager
60+
python -m pip install --upgrade build pipdeptree --upgrade-strategy eager
5961
60-
- name: build release distributions
62+
- name: Output installed packages
63+
run: |
64+
pip freeze --all
65+
66+
- name: Output dependency tree
67+
run: |
68+
pipdeptree
69+
70+
- name: Build release distributions
6171
run: |
6272
python -m build
73+
74+
- name: Upload windows dists
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: release-dists
78+
path: dist/
79+
80+
pypi-publish:
81+
name: Publish to PyPI
82+
runs-on: ubuntu-latest
83+
needs:
84+
- release-build
85+
environment:
86+
name: pypi
87+
permissions:
88+
id-token: write
89+
90+
strategy:
91+
fail-fast: true
92+
93+
steps:
94+
- name: Retrieve release distributions
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: release-dists
98+
path: dist/
99+
100+
- name: Publish release distributions to PyPI
101+
uses: pypa/gh-action-pypi-publish@release/v1
102+
with:
103+
print-hash: true

docs/conf.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# -- Project information -----------------------------------------------------
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1515

16-
project = "suricata-check-application-example"
16+
project = "suricata-check-extension-example"
1717
copyright = "2024, Koen Teuwen"
1818
author = "Koen Teuwen"
1919

@@ -26,7 +26,6 @@
2626

2727
extensions = [
2828
"myst_parser",
29-
"sphinx.ext.autodoc",
3029
"autoapi.extension",
3130
"sphinx.ext.intersphinx",
3231
"sphinx.ext.viewcode",
@@ -39,51 +38,31 @@
3938
intersphinx_mapping = {
4039
"python": ("https://docs.python.org/3/", None),
4140
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
41+
"suricata-check": ("https://suricata-check.teuwen.net/", None),
4242
"idstools": ("https://idstools.readthedocs.io/en/latest/", None),
43-
"suricata-check": ("https://suricata-check.readthedocs.io/en/latest/", None),
4443
}
4544

4645
root_doc = "index"
4746
master_doc = "index"
4847

48+
suppress_warnings = []
49+
4950
# -- Options for HTML output -------------------------------------------------
5051
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
5152

5253
html_theme = "sphinx_rtd_theme"
53-
html_static_path = ["static"]
54+
html_theme_options = {
55+
"prev_next_buttons_location": "both",
56+
"style_external_links": True,
57+
}
58+
html_favicon = "https://docs.readthedocs.io/favicon.ico"
5459

5560
# -- Options for MyST -------------------------------------------------
5661
# https://myst-parser.readthedocs.io/en/latest/
5762

5863
myst_enable_extensions = ["linkify"]
5964
myst_heading_anchors = 5
6065

61-
# -- Options for Autodoc -------------------------------------------------
62-
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#configuration
63-
64-
autoclass_context = "both"
65-
autodoc_class_signature = "separated"
66-
autodoc_member_order = "groupwise"
67-
autodoc_default_flags = [
68-
"members",
69-
"special-members",
70-
"inherited-members",
71-
"show-inheritance",
72-
"ignore-module-all",
73-
"maxdepth",
74-
]
75-
autodoc_default_options = {
76-
"member-order": "bysource",
77-
"special-members": "__init__",
78-
"undoc-members": False,
79-
"maxdepth": 2,
80-
}
81-
autodoc_typehints = "both"
82-
autodoc_typehints_description_target = "all"
83-
84-
# -- Options for AutoAPI -------------------------------------------------
85-
# https://sphinx-autoapi.readthedocs.io/en/latest/
86-
8766
autoapi_dirs = ["../suricata_check_extension_example"]
8867
autoapi_options = [
8968
"members",
@@ -96,3 +75,8 @@
9675
autoapi_python_class_content = "both"
9776
autoapi_member_order = "groupwise"
9877
autoapi_own_page_level = "module"
78+
79+
# -- Options for viewcode -------------------------------------------------
80+
# https://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html
81+
82+
viewcode_line_numbers = True

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
contain the root `toctree` directive.
55
66
Welcome to suricata-check-extension-example's documentation!
7-
==========================================
7+
============================================================
88

99
.. toctree::
1010
:caption: Documentation

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ classifiers = [
5151
"Operating System :: Microsoft :: Windows",
5252
"Operating System :: MacOS",
5353
"Framework :: Pytest",
54-
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
54+
"License :: OSI Approved :: Apache Software License",
5555
]
5656
requires-python = ">=3.9"
5757
dependencies = ["suricata-check>=0.3.0beta0", "idstools>=0.6.5",]
@@ -68,7 +68,7 @@ dev = [
6868
"black>=24.4.2",
6969
"pyright>=1.1.367",
7070
"sphinx>=7.3.7",
71-
"sphinx-rtd-theme>=2.0.0",
71+
"sphinx-rtd-theme>=3.0.0",
7272
"myst-parser[linkify]>=3.0.1",
7373
"sphinx-click>=6.0.0",
7474
"sphinx-autoapi>=3.4.0",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ruff>=0.4.9
1010
black>=24.4.2
1111
pyright>=1.1.367
1212
sphinx>=7.3.7
13-
sphinx-rtd-theme>=2.0.0
13+
sphinx-rtd-theme>=3.0.0
1414
myst-parser[linkify]>=3.0.1
1515
sphinx-click>=6.0.0
1616
sphinx-autoapi>=3.4.0

suricata_check_extension_example/_version.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,23 @@ def get_version() -> str:
2121

2222
git_dir = os.path.join(SURICATA_CHECK_DIR, "..", ".git")
2323
if os.path.exists(git_dir):
24-
v = __get_git_revision_short_hash()
25-
_logger.debug(
26-
"Detected suricata-check-extension-example version using git: %s", v
27-
)
24+
try:
25+
import setuptools_git_versioning # noqa: RUF100, PLC0415
26+
27+
v = str(
28+
setuptools_git_versioning.get_version(
29+
root=os.path.join(SURICATA_CHECK_DIR, "..")
30+
)
31+
)
32+
_logger.debug(
33+
"Detected suricata-check-extension-example version using setuptools_git_versioning: %s",
34+
v,
35+
)
36+
except: # noqa: E722
37+
v = __get_git_revision_short_hash()
38+
_logger.debug(
39+
"Detected suricata-check-extension-example version using git: %s", v
40+
)
2841
else:
2942
try:
3043
v = version("suricata-check-extension-example")

tests/test_suricata_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_version():
9797
logging.basicConfig(level=logging.DEBUG)
9898
if not hasattr(suricata_check, "__version__"):
9999
pytest.fail("suricata_check has no attribute __version__")
100-
from suricata_check._version import __version__
100+
from suricata_check._version import __version__ # noqa: RUF100, PLC0415
101101

102102
if __version__ == "unknown":
103103
warnings.warn(RuntimeWarning("Version is unknown."))

0 commit comments

Comments
 (0)