Skip to content

Commit 79a4e09

Browse files
authored
Audit GH Workflows with zizmor (#780)
1 parent 09f1883 commit 79a4e09

11 files changed

Lines changed: 100 additions & 45 deletions

File tree

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
name: Run Splunk AppInspect
22
description: Package a mock app containing the SDK and its dependencies, then validate it with AppInspect.
33

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-
104
runs:
115
using: composite
126
steps:
137
- name: Install AppInspect dependencies
148
shell: bash
159
run: sudo apt-get install -y libmagic1
16-
- name: Install the SDK and its dependencies into the mock app
10+
- name: Install the SDK and its dependencies into a mock app
1711
shell: bash
1812
run: |
19-
mkdir -p ${{ inputs.mock-app-path }}/bin/lib
20-
uv pip install ".[openai, anthropic, google]" --target ${{ inputs.mock-app-path }}/bin/lib
13+
mkdir -p ./tests/system/test_apps/generating_app/bin/lib
14+
uv pip install ".[openai, anthropic, google]" --target ./tests/system/test_apps/generating_app/bin/lib
2115
- name: Package the mock app
2216
shell: bash
2317
run: |
24-
cd ${{ inputs.mock-app-path }}
18+
cd ./tests/system/test_apps/generating_app
2519
tar -czf mock_app.tgz --exclude="__pycache__" bin default metadata
2620
- name: Validate the mock app with AppInspect
2721
shell: bash
28-
run: uvx splunk-appinspect inspect ${{ inputs.mock-app-path }}/mock_app.tgz --included-tags cloud
22+
run: uvx splunk-appinspect inspect ./tests/system/test_apps/generating_app/mock_app.tgz --included-tags cloud

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: Set up SDK environment
22
description: Perform all the shared setup steps
33

44
inputs:
5-
python-version:
6-
description: Python version used for this run
7-
required: true
8-
default: "3.13"
95
deps-group:
106
description: Dependency groups passed to `uv sync --group`
117
required: true
@@ -17,12 +13,12 @@ runs:
1713
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
1814
with:
1915
version: 0.11.6
20-
python-version: ${{ inputs.python-version }}
16+
python-version: 3.13
2117
activate-environment: true
2218
enable-cache: true
2319
cache-python: true
2420
- name: Install dependencies from the ${{ inputs.deps-group }} group
2521
env:
2622
SDK_DEPS_GROUP: ${{ inputs.deps-group }}
2723
shell: bash
28-
run: SDK_DEPS_GROUP="${{ inputs.deps-group }}" make ci-install
24+
run: make ci-install

.github/dependabot.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ updates:
44
directory: "/"
55
target-branch: "develop"
66
schedule:
7-
interval: "weekly"
7+
interval: "monthly"
88
groups:
99
github-actions:
10-
patterns: ["*"]
10+
update-types: ["major", "minor", "patch"]
11+
cooldown:
12+
default-days: 7
1113
- package-ecosystem: "uv"
1214
directory: "/"
1315
schedule:
14-
interval: "weekly"
16+
interval: "monthly"
1517
groups:
1618
python-uv-lock:
17-
patterns: ["*"]
19+
update-types: ["minor", "patch"]
20+
cooldown:
21+
default-days: 7

.github/workflows/appinspect.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8-
env:
9-
PYTHON_VERSION: 3.13
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions: {}
1013

1114
jobs:
1215
appinspect:
16+
name: Run AppInspect
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
1620
with:
1721
persist-credentials: false
1822
- uses: ./.github/actions/setup-sdk-environment
1923
with:
20-
python-version: ${{ env.PYTHON_VERSION }}
24+
python-version: 3.13
2125
deps-group: lint
2226
- name: Run AppInspect
2327
uses: ./.github/actions/run-appinspect

.github/workflows/cd.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
name: Python CD
1+
name: Python SDK CD
22
on:
33
push:
44
branches: [develop]
55
release:
66
types: [published]
77
workflow_dispatch:
88

9-
env:
10-
DIST_DIR: dist/
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: false
12+
13+
permissions: {}
1114

1215
jobs:
1316
build-distributables:
17+
name: Build release distributables
1418
# Why building is separate from publishing:
1519
# https://github.com/pypa/gh-action-pypi-publish/issues/217#issuecomment-1965727093
1620
runs-on: ubuntu-latest
@@ -26,15 +30,17 @@ jobs:
2630
deps-group: release
2731
- name: Set pre-release version
2832
if: startsWith(github.ref, 'refs/tags/') != true
33+
env:
34+
RUN_NUMBER: ${{ github.run_number }}
2935
run: |
3036
VERSION_BASE="$(uv version --short)"
31-
RUN_NUMBER="${{ github.run_number }}"
3237
uv version "${VERSION_BASE}.dev${RUN_NUMBER}"
3338
- name: Set release version
3439
if: startsWith(github.ref, 'refs/tags/') == true
40+
env:
41+
VERSION_TAG: ${{ github.event.release.tag_name }}
3542
run: |
36-
VERSION_TAG="${{ github.event.release.tag_name }}"
37-
[[ $VERSION_TAG != $(uv version --short) ]] && {
43+
[[ ${VERSION_TAG} != $(uv version --short) ]] && {
3844
printf "Git tag should be identical to version field in pyproject.toml"
3945
exit 1
4046
}
@@ -50,7 +56,7 @@ jobs:
5056
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
5157
with:
5258
name: splunk-sdk-${{ steps.get-version.outputs.version }}
53-
path: ${{ env.DIST_DIR }}
59+
path: dist/
5460
- name: Generate API reference
5561
run: make -C ./docs zip
5662
- name: Upload docs artifact
@@ -60,11 +66,12 @@ jobs:
6066
path: docs/_build/splunk-sdk-python-docs.zip
6167

6268
publish-pre-release:
69+
name: Publish pre-release to Test PyPI
6370
if: startsWith(github.ref, 'refs/tags/') == false
6471
needs: build-distributables
6572
runs-on: ubuntu-latest
6673
permissions:
67-
id-token: write
74+
id-token: write # Required for OIDC-based trusted publishing to PyPI
6875
environment:
6976
name: splunk-test-pypi
7077
url: https://test.pypi.org/project/splunk-sdk/
@@ -73,18 +80,19 @@ jobs:
7380
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
7481
with:
7582
name: splunk-sdk-${{ needs.build-distributables.outputs.version }}
76-
path: ${{ env.DIST_DIR }}
83+
path: dist/
7784
- name: Publish packages to Test PyPI
7885
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
7986
with:
8087
repository-url: https://test.pypi.org/legacy/
8188

8289
publish-release:
90+
name: Publish release to PyPI
8391
if: startsWith(github.ref, 'refs/tags/') == true
8492
needs: build-distributables
8593
runs-on: ubuntu-latest
8694
permissions:
87-
id-token: write
95+
id-token: write # Required for OIDC-based trusted publishing to PyPI
8896
environment:
8997
name: splunk-pypi
9098
url: https://pypi.org/project/splunk-sdk/
@@ -93,7 +101,7 @@ jobs:
93101
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
94102
with:
95103
name: splunk-sdk-${{ needs.build-distributables.outputs.version }}
96-
path: ${{ env.DIST_DIR }}
104+
path: dist/
97105
- name: Publish packages to PyPI
98106
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
99107
with:

.github/workflows/lint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions: {}
13+
814
jobs:
915
lint:
16+
name: Run linters
1017
runs-on: ubuntu-latest
1118
steps:
1219
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

.github/workflows/test.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1010
cancel-in-progress: true
1111

12+
permissions: {}
13+
1214
jobs:
1315
test:
16+
name: Run test suite
1417
runs-on: ubuntu-latest
1518
strategy:
1619
matrix:
@@ -30,7 +33,9 @@ jobs:
3033
SPLUNKBASE_PASSWORD: ${{ secrets.SPLUNKBASE_PASSWORD }}
3134
run: uv run ./scripts/download_splunk_mcp_server_app.py
3235
- name: Launch Splunk Docker instance
33-
run: SPLUNK_VERSION=${{ matrix.splunk-version }} docker compose up -d
36+
env:
37+
SPLUNK_VERSION: ${{ matrix.splunk-version }}
38+
run: docker compose up -d
3439
- name: Set up .env
3540
run: cp .env.template .env
3641
- name: Write internal AI secrets to .env
@@ -51,10 +56,8 @@ jobs:
5156
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae
5257
with:
5358
path: .pytest_cache
54-
key: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-${{
55-
github.sha }}
56-
restore-keys: |
57-
pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-
59+
key: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-${{ github.sha }}
60+
restore-keys: pytest-cache-${{ runner.os }}-py${{ matrix.python-version }}-${{ github.ref_name }}-
5861
- name: Run unit tests
5962
run: make test-unit
6063
- name: Run integration/system tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ $RECYCLE.BIN/
279279

280280
.vscode/
281281
docs/_build/
282+
.claude/
282283

283284
!*.conf.spec
284285
**/metadata/local.meta

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## VIRTUALENV MANAGEMENT
44

5-
# https://docs.astral.sh/uv/reference/cli/#uv-run--upgrade
5+
# https://docs.astral.sh/uv/reference/cli/#uv-sync
66
# --no-config skips Splunk's internal PyPI mirror
77
UV_SYNC_CMD := uv sync --no-config
8+
# https://docs.astral.sh/uv/reference/cli/#uv-run
9+
UV_RUN_CMD := uv run
10+
# https://docs.zizmor.sh/usage
11+
ZIZMOR_CMD := $(UV_RUN_CMD) zizmor --pedantic --strict-collection
812

913
.PHONY: install
1014
install:
@@ -20,9 +24,12 @@ upgrade:
2024
ci-install:
2125
$(UV_SYNC_CMD) --frozen --group $(SDK_DEPS_GROUP)
2226

23-
UV_RUN_CMD := uv run
2427
.PHONY: lint
25-
lint: lint-python # TODO: Add mbake
28+
lint: lint-python lint-gh-actions # TODO: Add mbake
29+
30+
.PHONY: lint-gh-actions
31+
lint-gh-actions:
32+
$(ZIZMOR_CMD) ./.github
2633

2734
.PHONY: lint-python
2835
lint-python:
@@ -31,7 +38,11 @@ lint-python:
3138
$(UV_RUN_CMD) basedpyright
3239

3340
.PHONY: ci-lint
34-
ci-lint: ci-lint-python # TODO: Add mbake
41+
ci-lint: ci-lint-python ci-lint-gh-actions # TODO: Add mbake
42+
43+
.PHONY: ci-lint-gh-actions
44+
ci-lint-gh-actions:
45+
$(ZIZMOR_CMD) ./.github
3546

3647
.PHONY: ci-lint-python
3748
ci-lint-python:

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ test = [
5353
"vcrpy>=8.1.1",
5454
]
5555
release = ["build>=1.5.0", "jinja2>=3.1.6", "sphinx>=9.1.0", "twine>=6.2.0"]
56-
lint = ["basedpyright>=1.39.4", "ruff>=0.15.12", "mbake>=1.4.6"]
56+
lint = [
57+
"basedpyright>=1.39.4",
58+
"ruff>=0.15.12",
59+
"mbake>=1.4.6",
60+
"zizmor==1.25.2",
61+
]
5762
dev = [
5863
"rich>=15.0.0",
5964
{ include-group = "test" },

0 commit comments

Comments
 (0)