Skip to content

Commit 150b1f3

Browse files
authored
Replace tox with pytest and Makefile, cleanup in docs/Makefile (#669)
* Remove unused code from docs Makefile * Fix missing backtick in docstring * Remove tox * Add programmatic year setting in docs * Move python version string to env, use dependency groups in pre-release.yml * Sync pre-release.yml to release.yml * Add "Python 3 Only" classifier * Update missed deps installation statement in test.yml * Run linter on CHANGELOG.md, fix typos * Capitalize some terms in CHANGELOG * Add unfortunate workaround for deps installation in Python 3.7 in CI * Unify naming in GH Action workflows * Fix missing dependencies in test suite 🤦 * Use latest release of splunk-app-collection * Separate .PHONY-ies as they look better; Update README.md * uv.lock * More cleanup in `Makefile`s * Fix "Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`." * Refactor README * Refactor README #2 * Finish cleanup in Makefile * Spruce up example app names etc. * Separate app dependency install for Python 3.7 and the rest * Rewrite installation section in README * Drop `deprecation` from dependencies in test.yml * PR review changes * Another README refactor * Run `mbake` on `Makefile`s * Pin dependencies in `pyproject.toml` wherever possible * Adjust details in README * Retires -> retries * Last adjustments to README * Adjust docstring in client.py * PR review adjustments
1 parent 306d3f8 commit 150b1f3

File tree

24 files changed

+1924
-1078
lines changed

24 files changed

+1924
-1078
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[run]
22
omit =
3-
.tox/*
43
tests/*

.github/workflows/pre-release.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
name: CD
1+
name: Publish SDK to Test PyPI
22
on: [workflow_dispatch]
33

4+
env:
5+
PYTHON_VERSION: 3.9
6+
47
jobs:
5-
test-pypi-deploy:
6-
name: Deploy to Test PyPI
8+
publish-sdk-test-pypi:
79
runs-on: ubuntu-latest
810
permissions:
911
id-token: write
@@ -12,15 +14,15 @@ jobs:
1214
steps:
1315
- name: Checkout source
1416
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493
15-
- name: Set up Python
17+
- name: Set up Python ${{ env.PYTHON_VERSION }}
1618
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
1719
with:
18-
python-version: 3.9
20+
python-version: ${{ env.PYTHON_VERSION }}
1921
- name: Install dependencies
20-
run: pip install build
21-
- name: Build package
22+
run: python -m pip install . --group build
23+
- name: Build packages for distribution
2224
run: python -m build
23-
- name: Publish package to Test PyPI
25+
- name: Publish packages to Test PyPI
2426
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
2527
with:
2628
repository-url: https://test.pypi.org/legacy/

.github/workflows/release.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Release
1+
name: Publish SDK to PyPI
22
on:
33
release:
44
types: [published]
55

6+
env:
7+
PYTHON_VERSION: 3.9
8+
69
jobs:
7-
publish:
8-
name: Deploy release to PyPI
10+
publish-sdk-pypi:
911
runs-on: ubuntu-latest
1012
permissions:
1113
id-token: write
@@ -14,24 +16,20 @@ jobs:
1416
steps:
1517
- name: Checkout source
1618
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493
17-
- name: Set up Python
19+
- name: Set up Python ${{ env.PYTHON_VERSION }}
1820
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
1921
with:
20-
python-version: 3.9
22+
python-version: ${{ env.PYTHON_VERSION }}
2123
- name: Install dependencies
22-
run: pip install build
23-
- name: Build package
24+
run: python -m pip install . --group release
25+
- name: Build packages for distribution
2426
run: python -m build
25-
- name: Publish package to PyPI
27+
- name: Publish packages to PyPI
2628
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
27-
- name: Install tox
28-
run: pip install tox
29-
- name: Generate API docs
30-
run: |
31-
rm -rf ./docs/_build
32-
tox -e docs
33-
- name: Docs Upload
29+
- name: Generate API reference
30+
run: make -C ./docs html
31+
- name: Upload docs artifact
3432
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
3533
with:
36-
name: python_sdk_docs
34+
name: python-sdk-docs
3735
path: docs/_build/html

.github/workflows/test.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Python CI
22
on: [push, workflow_dispatch]
33

44
jobs:
5-
build:
5+
run-test-suite:
66
runs-on: ${{ matrix.os }}
77
strategy:
88
fail-fast: false
@@ -23,13 +23,17 @@ jobs:
2323
steps:
2424
- name: Checkout code
2525
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493
26-
- name: Run docker compose
26+
- name: Launch Splunk Docker instance
2727
run: SPLUNK_VERSION=${{ matrix.splunk-version }} docker compose up -d
28-
- name: Setup Python
28+
- name: Setup Python ${{ matrix.python-version }}
2929
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
3030
with:
3131
python-version: ${{ matrix.python-version }}
32-
- name: Install tox
33-
run: pip install tox
34-
- name: Test Execution
35-
run: tox -e py -- ./tests
32+
- name: (Python 3.7) Install dependencies
33+
if: ${{ matrix.python-version == '3.7' }}
34+
run: python -m pip install python-dotenv pytest
35+
- name: (Python >= 3.9) Install dependencies
36+
if: ${{ matrix.python-version != '3.7' }}
37+
run: python -m pip install . --group test
38+
- name: Run entire test suite
39+
run: python -m pytest ./tests

CHANGELOG.md

Lines changed: 316 additions & 288 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,48 @@
1-
RESET_COLOR=\033[0m
2-
GREEN_COLOR=\033[32;01m
3-
4-
CONTAINER_NAME := 'splunk'
1+
CONTAINER_NAME := "splunk"
52

63
.PHONY: docs
74
docs:
8-
@echo "$(GREEN_COLOR)==> docs $(RESET_COLOR)"
9-
@rm -rf ./docs/_build
10-
@tox -e docs
11-
@cd ./docs/_build/html && zip -r ../docs_html.zip . -x ".*" -x "__MACOSX"
12-
@echo "$(ATTN_COLOR)==> Docs pages can be found at ./docs/_build/html, docs bundle available at ./docs/_build/docs_html.zip"
5+
@make -C ./docs html
136

147
.PHONY: test
158
test:
16-
@echo "$(GREEN_COLOR)==> test $(RESET_COLOR)"
17-
@tox -e py -- ./tests
9+
@python -m pytest ./tests
1810

1911
.PHONY: test-unit
20-
test:
21-
@echo "$(GREEN_COLOR)==> test $(RESET_COLOR)"
22-
@tox -e py -- ./tests/unit
12+
test-unit:
13+
@python -m pytest ./tests/unit
2314

2415
.PHONY: test-integration
25-
test:
26-
@echo "$(GREEN_COLOR)==> test $(RESET_COLOR)"
27-
@tox -e py -- ./tests/integration ./tests/system
16+
test-integration:
17+
@python -m pytest ./tests/integration ./tests/system
2818

29-
.PHONY: up
30-
up:
31-
@echo "$(GREEN_COLOR)==> up $(RESET_COLOR)"
19+
.PHONY: docker-up
20+
docker-up:
3221
@docker-compose up -d
3322

34-
.PHONY: remove
35-
remove:
36-
@echo "$(GREEN_COLOR)==> rm $(RESET_COLOR)"
37-
@docker-compose rm -f -s
38-
39-
.PHONY: wait_up
40-
wait_up:
41-
@echo "$(GREEN_COLOR)==> wait_up $(RESET_COLOR)"
42-
@for i in `seq 0 180`; do if docker exec -it $(CONTAINER_NAME) /sbin/checkstate.sh &> /dev/null; then break; fi; printf "\rWaiting for Splunk for %s seconds..." $$i; sleep 1; done
43-
44-
.PHONY: down
45-
down:
46-
@echo "$(GREEN_COLOR)==> down $(RESET_COLOR)"
23+
.PHONY: docker-ensure-up
24+
docker-ensure-up:
25+
@for i in `seq 0 180`; do \
26+
if docker exec -it $(CONTAINER_NAME) /bin/bash -c "/sbin/checkstate.sh &> /dev/null"; then \
27+
break; \
28+
fi; \
29+
printf "\rWaiting for Splunk for %s seconds..." $$i; \
30+
sleep 1; \
31+
done
32+
33+
.PHONY: docker-start
34+
docker-start: docker-up docker-ensure-up
35+
36+
.PHONY: docker-down
37+
docker-down:
4738
@docker-compose stop
4839

49-
.PHONY: start
50-
start: up wait_up
40+
.PHONY: docker-restart
41+
docker-restart: docker-down docker-start
5142

52-
.PHONY: restart
53-
restart: down start
43+
.PHONY: docker-remove
44+
docker-remove:
45+
@docker-compose rm -f -s
5446

55-
.PHONY: refresh
56-
refresh: remove start
47+
.PHONY: docker-refresh
48+
docker-refresh: docker-remove docker-start

0 commit comments

Comments
 (0)