Skip to content

Commit 794da02

Browse files
authored
1 parent b764d82 commit 794da02

21 files changed

Lines changed: 990 additions & 750 deletions

File tree

.basedpyright/baseline.json

Lines changed: 225 additions & 161 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run Splunk AppInspect
2+
description: Package a mock app containing the SDK and its dependencies, then validate it with AppInspect.
3+
4+
inputs:
5+
mock-app-path:
6+
description: Path to app packaged for scanning with AppInspect
7+
required: true
8+
default: ./tests/system/test_apps/generating_app
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Install AppInspect dependencies
14+
shell: bash
15+
run: sudo apt-get install -y libmagic1
16+
- name: Install the SDK and its dependencies into the mock app
17+
shell: bash
18+
run: |
19+
mkdir -p ${{ inputs.mock-app-path }}/bin/lib
20+
uv pip install ".[openai, anthropic]" --target ${{ inputs.mock-app-path }}/bin/lib
21+
- name: Package the mock app
22+
shell: bash
23+
run: |
24+
cd ${{ inputs.mock-app-path }}
25+
tar -czf mock_app.tgz --exclude="__pycache__" bin default metadata
26+
- name: Validate the mock app with AppInspect
27+
shell: bash
28+
run: uvx splunk-appinspect inspect ${{ inputs.mock-app-path }}/mock_app.tgz --included-tags cloud

.github/actions/setup-sdk-environment/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ inputs:
55
python-version:
66
description: Python version used for this run
77
required: true
8+
default: "3.13"
89
deps-group:
910
description: Dependency groups passed to `uv sync --group`
1011
required: true
12+
default: dev
1113

1214
runs:
1315
using: composite
1416
steps:
1517
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
1618
with:
1719
version: 0.11.6
18-
activate-environment: true
1920
python-version: ${{ inputs.python-version }}
20-
- name: Install dependencies from the ${{ inputs.deps-group }} group(s)
21-
run: SDK_DEPS_GROUP="${{ inputs.deps-group }}" make uv-sync-ci
21+
activate-environment: true
22+
enable-cache: true
23+
cache-python: true
24+
- name: Install dependencies from the ${{ inputs.deps-group }} group
25+
env:
26+
SDK_DEPS_GROUP: ${{ inputs.deps-group }}
2227
shell: bash
28+
run: SDK_DEPS_GROUP="${{ inputs.deps-group }}" make ci-install

.github/workflows/appinspect.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: Validate SDK with Splunk AppInspect
2-
on: [ push, workflow_dispatch ]
2+
on: [push, workflow_dispatch]
33

44
env:
55
PYTHON_VERSION: 3.13
6-
MOCK_APP_PATH: ./tests/system/test_apps/generating_app
76

87
jobs:
98
appinspect:
@@ -14,16 +13,5 @@ jobs:
1413
with:
1514
python-version: ${{ env.PYTHON_VERSION }}
1615
deps-group: lint
17-
- name: Install splunk-appinspect dependencies
18-
run: sudo apt-get install -y libmagic1
19-
- name: Install packages for the mock app
20-
run: |
21-
mkdir -p ${{ env.MOCK_APP_PATH }}/bin/lib
22-
uv pip install ".[openai, anthropic]" --target ${{ env.MOCK_APP_PATH }}/bin/lib
23-
- name: Copy splunklib to a test app and package it as a mock app
24-
run: |
25-
cd ${{ env.MOCK_APP_PATH }}
26-
tar -czf mock_app.tgz --exclude="__pycache__" bin default metadata
27-
- name: Validate mock app with splunk-appinspect
28-
run: uvx splunk-appinspect inspect ${{ env.MOCK_APP_PATH }}/mock_app.tgz
29-
--included-tags cloud
16+
- name: Run AppInspect
17+
uses: ./.github/actions/run-appinspect

.github/workflows/lint.yml

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

44
jobs:
5-
lint-stage:
5+
lint:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
@@ -12,5 +12,5 @@ jobs:
1212
deps-group: lint
1313
- name: Verify uv.lock is up-to-date
1414
run: uv lock --check
15-
- name: Verify against basedpyright baseline
16-
run: uv run --frozen basedpyright
15+
- name: Verify files are linted and formatted
16+
run: make ci-lint

.github/workflows/pre-release.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
name: Publish SDK to Test PyPI
2-
on: [workflow_dispatch]
1+
name: Publish pre-release to Test PyPI
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- release/2.x
7+
workflow_dispatch:
38

49
env:
510
PYTHON_VERSION: 3.13
611

712
jobs:
8-
publish-to-test-pypi:
13+
publish-pre-release:
914
runs-on: ubuntu-latest
1015
permissions:
11-
id-token: write
16+
id-token: write # Required for publishing
1217
environment:
1318
name: splunk-test-pypi
1419
steps:
@@ -17,8 +22,16 @@ jobs:
1722
with:
1823
python-version: ${{ env.PYTHON_VERSION }}
1924
deps-group: release
25+
- name: Set temporary pre-release version
26+
run: |
27+
VERSION_BASE="$(uv version --short)"
28+
RUN_NUMBER="${{ github.run_number }}"
29+
COMMIT_SHA="$(git rev-parse --short HEAD)"
30+
uv version --frozen "${VERSION_BASE}.dev${RUN_NUMBER}+g${COMMIT_SHA}"
2031
- name: Build packages for distribution
2132
run: uv build
33+
- name: Run AppInspect
34+
uses: ./.github/actions/run-appinspect
2235
- name: Publish packages to Test PyPI
2336
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
2437
with:

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
publish-to-pypi:
1111
runs-on: ubuntu-latest
1212
permissions:
13-
id-token: write
13+
id-token: write # Required for publishing
1414
environment:
1515
name: splunk-pypi
1616
steps:
@@ -21,6 +21,8 @@ jobs:
2121
deps-group: release
2222
- name: Build packages for distribution
2323
run: uv build
24+
- name: Run AppInspect
25+
uses: ./.github/actions/run-appinspect
2426
- name: Publish packages to PyPI
2527
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
2628
with:

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,41 @@ concurrency:
66
cancel-in-progress: true
77

88
jobs:
9-
test-stage:
10-
runs-on: ${{ matrix.os }}
9+
test:
1110
strategy:
1211
matrix:
1312
os: [ubuntu-latest]
1413
python-version: [3.13]
1514
splunk-version: [latest]
15+
runs-on: ${{ matrix.os }}
1616
steps:
1717
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
1818
- uses: ./.github/actions/setup-sdk-environment
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
deps-group: test
2222
- name: Download Splunk MCP Server App
23-
run: uv run ./scripts/download_splunk_mcp_server_app.py
2423
env:
2524
SPLUNKBASE_USERNAME: ${{ secrets.SPLUNKBASE_USERNAME }}
2625
SPLUNKBASE_PASSWORD: ${{ secrets.SPLUNKBASE_PASSWORD }}
26+
run: uv run ./scripts/download_splunk_mcp_server_app.py
2727
- name: Launch Splunk Docker instance
2828
run: SPLUNK_VERSION=${{ matrix.splunk-version }} docker compose up -d
2929
- name: Set up .env
3030
run: cp .env.template .env
3131
- name: Write internal AI secrets to .env
32-
run: |
33-
echo "internal_ai_app_key=$INTERNAL_AI_APP_KEY" >> .env
34-
echo "internal_ai_client_id=$INTERNAL_AI_CLIENT_ID" >> .env
35-
echo "internal_ai_client_secret=$INTERNAL_AI_CLIENT_SECRET" >> .env
36-
echo "internal_ai_token_url=$INTERNAL_AI_TOKEN_URL" >> .env
37-
echo "internal_ai_base_url=$INTERNAL_AI_BASE_URL" >> .env
3832
env:
3933
INTERNAL_AI_APP_KEY: ${{ secrets.INTERNAL_AI_APP_KEY }}
4034
INTERNAL_AI_CLIENT_ID: ${{ secrets.INTERNAL_AI_CLIENT_ID }}
4135
INTERNAL_AI_CLIENT_SECRET: ${{ secrets.INTERNAL_AI_CLIENT_SECRET }}
4236
INTERNAL_AI_TOKEN_URL: ${{ secrets.INTERNAL_AI_TOKEN_URL }}
4337
INTERNAL_AI_BASE_URL: ${{ secrets.INTERNAL_AI_BASE_URL }}
38+
run: |
39+
echo "internal_ai_app_key=$INTERNAL_AI_APP_KEY" >> .env
40+
echo "internal_ai_client_id=$INTERNAL_AI_CLIENT_ID" >> .env
41+
echo "internal_ai_client_secret=$INTERNAL_AI_CLIENT_SECRET" >> .env
42+
echo "internal_ai_token_url=$INTERNAL_AI_TOKEN_URL" >> .env
43+
echo "internal_ai_base_url=$INTERNAL_AI_BASE_URL" >> .env
4444
- name: Restore pytest cache
4545
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop' }}
4646
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
@@ -51,5 +51,5 @@ jobs:
5151
pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-
5252
- name: Run unit tests
5353
run: make test-unit
54-
- name: Run entire test suite
54+
- name: Run integration/system tests
5555
run: make test-integration

Makefile

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,39 @@
66
# --no-config skips Splunk's internal PyPI mirror
77
UV_SYNC_CMD := uv sync --no-config
88

9-
.PHONY: uv-sync
10-
uv-sync:
9+
.PHONY: install
10+
install:
1111
$(UV_SYNC_CMD) --dev
1212

13-
.PHONY: uv-upgrade
14-
uv-upgrade:
13+
.PHONY: upgrade
14+
upgrade:
1515
$(UV_SYNC_CMD) --dev --upgrade
1616

17-
1817
# Workaround for make being unable to pass arguments to underlying cmd
1918
# $ SDK_DEPS_GROUP="build" make uv-sync-ci
20-
.PHONY: uv-sync-ci
21-
uv-sync-ci:
22-
uv sync --locked --group $(SDK_DEPS_GROUP)
19+
.PHONY: ci-install
20+
ci-install:
21+
$(UV_SYNC_CMD) --group $(SDK_DEPS_GROUP)
22+
23+
UV_RUN_CMD := uv run --frozen --no-config
24+
.PHONY: lint
25+
lint: lint-python # TODO: Add mbake
26+
27+
.PHONY: lint-python
28+
lint-python:
29+
$(UV_RUN_CMD) basedpyright
30+
$(UV_RUN_CMD) ruff check --fix-only
31+
$(UV_RUN_CMD) ruff format
32+
33+
UV_RUN_CMD := uv run --frozen --no-config
34+
.PHONY: ci-lint
35+
ci-lint: ci-lint-python # TODO: Add mbake
36+
37+
.PHONY: ci-lint-python
38+
ci-lint-python:
39+
$(UV_RUN_CMD) basedpyright
40+
# $(UV_RUN_CMD) ruff check
41+
# $(UV_RUN_CMD) ruff format --check
2342

2443
.PHONY: clean
2544
clean:
@@ -97,4 +116,4 @@ docker-splunk-restart:
97116

98117
.PHONY: docker-tail-python-log
99118
docker-tail-python-log:
100-
docker exec -it $(CONTAINER_NAME) sudo tail $(SPLUNK_HOME)/var/log/splunk/python.log
119+
docker exec -it $(CONTAINER_NAME) sudo tail $(SPLUNK_HOME)/var/log/splunk/python.log

docs/conf.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
# All configuration values have a default; values that are commented out
1010
# serve to show the default.
1111

12+
import importlib.metadata
1213
from datetime import datetime
1314

14-
import splunklib
15-
1615
# If extensions (or modules to document with autodoc) are in another directory,
1716
# add these directories to sys.path here. If the directory is relative to the
1817
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -41,16 +40,15 @@
4140

4241
# General information about the project.
4342
project = "Splunk SDK for Python"
44-
copyright = f"{datetime.now().year}, Splunk Inc."
43+
copyright = f"2011-{datetime.now().year} Splunk, Inc."
4544

4645
# The version info for the project you're documenting, acts as replacement for
4746
# |version| and |release|, also used in various other places throughout the
4847
# built documents.
4948
#
5049
# The short X.Y version.
51-
version = splunklib.__version__
52-
# The full version, including alpha/beta/rc tags.
53-
release = splunklib.__version__
50+
release = importlib.metadata.version("splunk-sdk")
51+
version = ".".join(release.split(".")[:2])
5452

5553
# The language for content autogenerated by Sphinx. Refer to documentation
5654
# for a list of supported languages.

0 commit comments

Comments
 (0)