Skip to content

[TEST] Bartek's Lab #629

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

Draft
wants to merge 70 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
f2c297a
Try converting project to pyproject.toml and uv
Ickerday Jul 28, 2025
81a4e95
Update project URLs
Ickerday Jul 28, 2025
1ebcdc6
Remove unused packages and add flake8 found in tox.ini
Ickerday Jul 28, 2025
4502606
Update name, remove setup.py
Ickerday Jul 28, 2025
dae08b0
Extract deps into dev deps
Ickerday Jul 28, 2025
69bb731
Move versioning to pyproject.toml, adjust version extracting to use i…
Ickerday Jul 28, 2025
0c2b2a5
Try fix CI/CD
Ickerday Jul 29, 2025
7b320c4
Try fix build #2
Ickerday Jul 29, 2025
343713e
Reformat README
Ickerday Jul 31, 2025
b59c407
Remove Commands.conf.spec.xlsx
Ickerday Jul 31, 2025
338170e
Remove .env
Ickerday Jul 31, 2025
01774fa
Add missing deps
Ickerday Jul 31, 2025
7bd53fc
Fiddle around with CI/CD
Ickerday Jul 31, 2025
db6b3ee
Add miscellaneous changes
Ickerday Jul 31, 2025
2c386a9
Fiddle around with CI/CD #2
Ickerday Jul 31, 2025
f154e90
Fiddle around with CI/CD #3
Ickerday Jul 31, 2025
9fed603
Fiddle around with CI/CD #4
Ickerday Jul 31, 2025
0cfbaae
Fiddle around with CI/CD #5
Ickerday Jul 31, 2025
e51e42f
Fiddle around with CI/CD #6
Ickerday Jul 31, 2025
a865779
Fiddle around with CI/CD #7
Ickerday Jul 31, 2025
c8ee057
Change default Splunk version in .env.template to v10
Ickerday Jul 31, 2025
a0498aa
Fiddle around with CI/CD #8
Ickerday Aug 4, 2025
79d2dd5
Move tox config to pyproject.toml, return to old version accessing st…
Ickerday Aug 5, 2025
fa7fb74
Assorted small changes
Ickerday Aug 5, 2025
4cef846
Try caching virtualenvs in GitHub Actions
Ickerday Aug 5, 2025
1bf86e6
Fix not using venv after restoring cache
Ickerday Aug 5, 2025
9ce725d
Add caching .tox as well
Ickerday Aug 5, 2025
18b97df
Test cache
Ickerday Aug 5, 2025
c114d78
Fix build breaking if the cache is invalid
Ickerday Aug 5, 2025
5770ac3
Back out of caching for now
Ickerday Aug 5, 2025
bbff0d6
Add `build` package as release won't work without it
Ickerday Aug 5, 2025
5297914
Pin GH Action versions to specific commits
Ickerday Aug 5, 2025
caeba73
Format GH templates
Ickerday Aug 5, 2025
bb5f45c
Try another approach to splitting dependencies in pyproject.toml
Ickerday Aug 5, 2025
0e0f2a5
Finally figure out how dependency groups are managed in pip?
Ickerday Aug 5, 2025
8855231
Add matrix to release.yml for easier configuration in the future, add…
Ickerday Aug 5, 2025
4a8bb2d
Try using an older Splunk version to determine cause of CI failures
Ickerday Aug 5, 2025
89ca01b
Change `where` calls to `type -a`
Ickerday Aug 5, 2025
5114df6
Fix wrong Splunk version in .env.template
Ickerday Aug 5, 2025
728c67a
Reformat .env.template, add new Splunk 10 env variable to docker-compose
Ickerday Aug 6, 2025
3af9355
Change .env template name, add Docker health check ot test.yml
Ickerday Aug 6, 2025
5f74aab
Add quotes to port mappings
Ickerday Aug 6, 2025
ec11167
Enable only Python 3.7, 3.9 and splunk 8.2 and 9.4
Ickerday Aug 6, 2025
c09e8de
Set release.yml to use Python 3.9
Ickerday Aug 6, 2025
13fbd86
Readd Python 3.7 to tox
Ickerday Aug 6, 2025
00f57b6
Disable some versions in the test.yml matrix
Ickerday Aug 7, 2025
e04a6f5
Pin Python to the minor version instead of patch
Ickerday Aug 7, 2025
09f8739
Remove VSCode workspace
Ickerday Aug 8, 2025
225bfef
Add code-workspace to gitignore
Ickerday Aug 8, 2025
d3fc3e1
Merge remote-tracking branch 'origin/develop' into dev/BJ/pyproject-toml
Ickerday Aug 8, 2025
1bac2cb
Fix a comment
Ickerday Aug 8, 2025
27af6d8
Reorganize .env.test
Ickerday Aug 8, 2025
c14f4f3
Only check for is_preview in job result if ran on Splunk pre-v10
Ickerday Aug 8, 2025
9ff33ee
Remove duplicated ruff link
Ickerday Aug 11, 2025
f496605
Add logging to exceptions in desperation, remove duplicated test (wil…
Ickerday Aug 11, 2025
f34f3a8
Add *.log to .gitignore
Ickerday Aug 11, 2025
1514f28
Reenable more CI targets
Ickerday Aug 11, 2025
ad83f98
Fix Python 3.13 failing on Iterable/Iterator reserved names
Ickerday Aug 11, 2025
46ac32d
Reenable fast-false
Ickerday Aug 11, 2025
176f92b
Import collections.abc correctly
Ickerday Aug 11, 2025
444e949
Annotate flaky test in test_collection.py
Ickerday Aug 11, 2025
e3a5278
Redisable fail-fast
Ickerday Aug 11, 2025
8968533
Force SDK logs, set output to file
Ickerday Aug 11, 2025
0f7d648
Annotate flaky test
Ickerday Aug 11, 2025
aa9508e
Annotate another flaky test
Ickerday Aug 12, 2025
cf0e076
Merge commit '1aa5b208645a8e683c87da2d5c6ec426509c309a' into dev/BJ/p…
Ickerday Aug 12, 2025
ade4a8f
Change CI targets again
Ickerday Aug 12, 2025
d7e2efb
Remove a CI target because we don't ship Python 3.7 with Splunk 10
Ickerday Aug 12, 2025
a728f84
Add back 9.4 as it was an on-prem only release (previously thought no…
Ickerday Aug 12, 2025
4d304c0
Use skipTest instead of returns, add some TODOs for myself etc.
Ickerday Aug 12, 2025
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
14 changes: 6 additions & 8 deletions .env → .env.test
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Your version of Splunk (default: latest)
version=latest

# Access scheme (default: https)
scheme=https
# Splunk host (default: localhost)
host=localhost
# Splunk admin port (default: 8089)
port=8089

# Splunk username
username=admin
# Splunk password
password=changed!
# Access scheme (default: https)
scheme=https
# Your version of Splunk (default: 6.2)
version=9.0
# Bearer token for authentication
#splunkToken="<Bearer-token>"
# Session key for authentication
#token="<Session-Key>"
16 changes: 9 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,14 +24,16 @@ A clear and concise description of what you expected to happen.
If applicable, add logs or screenshots to help explain your problem.

**Splunk (please complete the following information):**

- Version: [e.g. 8.0.5]
- OS: [e.g. Ubuntu 20.04.1]
- Deployment: [e.g. single-instance]

**SDK (please complete the following information):**
- Version: [e.g. 1.6.14]
- Language Runtime Version: [e.g. Python 3.7]
- OS: [e.g. MacOS 10.15.7]

- Version: [e.g. 1.6.14]
- Language Runtime Version: [e.g. Python 3.7]
- OS: [e.g. MacOS 10.15.7]

**Additional context**
Add any other context about the problem here.
9 changes: 3 additions & 6 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---


7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
9 changes: 4 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE/pr_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
---
name: Pull Request Template
about: Create a Pull Request to contribute to the SDK
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

## Description of PR

Provide the **context and motivation** for this PR.
Provide the **context and motivation** for this PR.
Briefly explain the **type of changes** (bug fix, feature request, doc update, etc.) made in this PR. Provide reference to issue # fixed, if applicable.

Describe the approach to the solution, the changes made, and any resulting change in behavior or impact to the user.
Expand Down
112 changes: 112 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Splunk SDK Python - AI Assistant Guide

This guide helps AI coding assistants understand the key patterns and practices of the Splunk SDK for Python codebase.

## Architecture Overview

The SDK is organized into several key modules:

- `splunklib.client`: Main interface for interacting with Splunk's REST API
- `splunklib.binding`: Low-level HTTP and authentication handling
- `splunklib.data`: XML/Atom feed parsing utilities
- `splunklib.modularinput`: Framework for creating Splunk modular inputs
- `splunklib.searchcommands`: Framework for custom search commands

### Core Patterns

1. Service Connection:

```python
import splunklib.client as client
service = client.connect(
host='localhost',
port=8089,
username='admin',
password='changeme'
# OR splunkToken=<bearer_token>
# OR token=<session_key>
)
```

2. Resource Collections Pattern:

- All Splunk resources (apps, jobs, searches etc.) are accessed via collections
- Collections return Entity objects with attribute access
- Example:

```python
apps = service.apps
my_app = apps.create('my_app')
print(my_app['author']) # Or: my_app.author
```

3. XML Data Handling:

- Use `splunklib.data.load()` for parsing Splunk's XML responses
- Include proper XML namespace handling as shown in `data.py`

## Development Workflows

1. Testing:

```bash
# Run all tests with Docker
make up SPLUNK_VERSION=9.2
make wait_up
make test
make down

# Run specific test
make test_specific TEST=tests/test_binding.py
```

2. Environment Setup:

- Required: Python 3.7, 3.9, or 3.13
- Create `.env` file for test credentials (see README template)
- Set `PYTHONPATH` to include SDK root

## Project-Specific Conventions

1. Search Command Development:

- Use `self.add_field(record, fieldname, value)` to modify records
- Never modify record dictionaries directly
- Example:

```python
class CustomStreamingCommand(StreamingCommand):
def stream(self, records):
for record in records:
self.add_field(record, "new_field", "value")
yield record
```

2. Modular Input Development:

- Access metadata via InputDefinition in stream_events()
- Use `gen_record()` for generating events in custom commands

## Key Integration Points

1. Authentication Methods:

- Username/password
- Bearer token
- Session key
- See connection examples in README

2. Test Dependencies:

- Requires [SDK App Collection](https://github.com/splunk/sdk-app-collection)
- Clean Splunk instance recommended (disable \*NIX/Windows apps)
- Never test against production instances

## Reference Files

- `splunklib/client.py`: Core service and entity implementations
- `splunklib/data.py`: XML parsing patterns
- `tests/README.md`: Testing configuration and practices
- `.env.template`: Environment variable template

For more details, consult the [Developer Portal Reference](https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/).
54 changes: 28 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
name: Release
name: Publish release to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry-run:
type: boolean
required: true
default: true

jobs:
publish:
name: Deploy Release to PyPI
runs-on: ubuntu-latest
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: 3.7
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install twine
run: pip install . --group build
- name: Build package
run: python setup.py sdist
run: python -m build
- name: Publish package to PyPI
uses: pypa/[email protected]
if: ${{ inputs.dry-run == 'false' }}
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Install tox
run: pip install tox
- name: Generate API docs
password: ${{ secrets.PYPI_PASSWORD }}
- name: Generate API reference docs
run: |
rm -rf ./docs/_build
tox -e docs
- name : Docs Upload
uses: actions/upload-artifact@v3
python -m tox -e docs
- name: Upload API reference docs
if: ${{ inputs.dry-run == 'false' }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: python_sdk_docs
path: docs/_build/html
# Test upload
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: ${{ secrets.test_pypi_password }}
# repository_url: https://test.pypi.org/legacy/
73 changes: 36 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
name: Python CI

on:
[ push, workflow_dispatch ]
on: [push, workflow_dispatch]

jobs:
build:

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python: [ 3.9, 3.13 ]
splunk-version:
- "8.1"
- "8.2"
- "latest"
os: [ubuntu-latest]
python-version: [3.9, 3.13]
splunk-version: [9.3, 9.4, latest]
include:
# Ubuntu 22.04 is the last version we can get pre-built Python 3.7 binaries for
- os: ubuntu-22.04
python: 3.7
splunk-version: "8.1"
- os: ubuntu-22.04
python: 3.7
splunk-version: "8.2"
python-version: 3.7
splunk-version: 9.3
- os: ubuntu-22.04
python: 3.7
splunk-version: "latest"

fail-fast: false

python-version: 3.7
splunk-version: 9.4
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run docker compose
run: SPLUNK_VERSION=${{matrix.splunk-version}} docker compose up -d

- name: Setup Python
uses: actions/setup-python@v4
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up environment variables
run: cp ./.env.test ./.env
- name: Launch Splunk ${{ matrix.splunk-version }}
run: SPLUNK_VERSION=${{ matrix.splunk-version }} docker compose up -d
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.python }}

- name: Install tox
run: pip install tox

- name: Test Execution
run: tox -e py
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python --version && python -m pip --version && python -m pip install tox
- name: Run Docker health check
# Probably solves nothing, worth trying regardless
run: |
timeout 30s make wait_up
if [ $? -eq 124 ]; then
echo "Splunk failed to start within 30 seconds."
docker compose logs
exit 1
fi
- name: Run test suite
run: python -m tox -e py
- name: Print docker logs for optional inspection
run: docker compose logs
fossa-scan:
uses: splunk/oss-scanning-public/.github/workflows/oss-scan.yml@main
secrets: inherit
secrets: inherit
Loading
Loading