DSPy: The framework for programming—not prompting—language models
Python
ci(workflows): fix zizmor and actionlint findings across all workflows (#9743)
Isaac Miller9ebd38f5f3ff
diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.ymlindex c72fba571..855f5719c 100644--- a/.github/workflows/build_and_release.yml+++ b/.github/workflows/build_and_release.yml@@ -4,13 +4,18 @@ on:push:tags:- "*"+permissions: {}jobs:extract-tag:runs-on: ubuntu-latest+ permissions:+ contents: readoutputs:version: ${{ steps.extract_tag.outputs.tag }}steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- id: extract_tagname: Extract tag namerun: echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"@@ -21,9 +26,12 @@ jobs:environment:name: testpypipermissions:+ contents: readid-token: write # IMPORTANT: mandatory for trusted publishingsteps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- name: Set up Python 3.11uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:@@ -36,15 +44,18 @@ jobs:deno-version: v2.7.7- name: Get correct version for TestPyPI releaseid: check_version+ env:+ VERSION: ${{ needs.extract-tag.outputs.version }}run: |- VERSION=${{ needs.extract-tag.outputs.version }}PACKAGE_NAME="dspy-ai-test-isaac"echo "Checking if $VERSION for $PACKAGE_NAME exists on TestPyPI"- NEW_VERSION=$(python3 .github/workflows/build_utils/test_version.py $PACKAGE_NAME $VERSION)+ NEW_VERSION=$(python3 .github/workflows/build_utils/test_version.py "$PACKAGE_NAME" "$VERSION")echo "Version to be used for TestPyPI release: $NEW_VERSION"echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"- name: Update version in pyproject.toml- run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' pyproject.toml+ env:+ VERSION: ${{ steps.check_version.outputs.version }}+ run: sed -i "/#replace_package_version_marker/{n;s/version=\"[^\"]*\"/version=\"$VERSION\"/;}" pyproject.toml- name: Update package name in pyproject.tomlrun: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test-isaac"/;}' pyproject.toml- name: Build a binary wheel@@ -80,7 +91,7 @@ jobs:id-token: write # IMPORTANT: mandatory for trusted publishingcontents: writesteps:- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 # zizmor: ignore[artipacked] -- git-auto-commit-action needs persisted credentials- name: Set up Python 3.11uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:@@ -92,9 +103,13 @@ jobs:with:deno-version: v2.7.7- name: Update version in pyproject.toml- run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' pyproject.toml+ env:+ VERSION: ${{ needs.extract-tag.outputs.version }}+ run: sed -i "/#replace_package_version_marker/{n;s/version *= *\"[^\"]*\"/version=\"$VERSION\"/;}" pyproject.toml- name: Update version in __metadata__.py- run: sed -i '/#replace_package_version_marker/{n;s/__version__ *= *"[^"]*"/__version__="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/__metadata__.py+ env:+ VERSION: ${{ needs.extract-tag.outputs.version }}+ run: sed -i "/#replace_package_version_marker/{n;s/__version__ *= *\"[^\"]*\"/__version__=\"$VERSION\"/;}" ./dspy/__metadata__.py# Publish to dspy- name: Update package name in pyproject.tomlrun: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy"/;}' pyproject.toml@@ -123,10 +138,13 @@ jobs:- name: Update package name in pyproject.tomlrun: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy-ai"/;}' .github/.internal_dspyai/pyproject.toml- name: Update version for dspy-ai release- run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' .github/.internal_dspyai/pyproject.toml+ env:+ VERSION: ${{ needs.extract-tag.outputs.version }}+ run: sed -i "/#replace_package_version_marker/{n;s/version *= *\"[^\"]*\"/version=\"$VERSION\"/;}" .github/.internal_dspyai/pyproject.toml- name: Update dspy dependency for dspy-ai release- run: |- sed -i '/#replace_dspy_version_marker/{n;s/dspy>=[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' .github/.internal_dspyai/pyproject.toml+ env:+ VERSION: ${{ needs.extract-tag.outputs.version }}+ run: sed -i "/#replace_dspy_version_marker/{n;s/dspy>=[^\"]*/dspy>=$VERSION/;}" .github/.internal_dspyai/pyproject.toml- name: Build a binary wheel (dspy-ai)run: python3 -m build .github/.internal_dspyai/- name: Validate built distributions (dspy-ai)@@ -152,6 +170,7 @@ jobs:steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:+ persist-credentials: falseref: main- name: Apply version bump for mainenv:diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.ymlindex 8199246d1..691c4b784 100644--- a/.github/workflows/docs-push.yml+++ b/.github/workflows/docs-push.yml@@ -10,13 +10,19 @@ on:paths:- "docs/**"+permissions: {}+jobs:build-test:if: github.event_name == 'pull_request'runs-on: ubuntu-latest+ permissions:+ contents: readsteps:- name: Checkout codeuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- name: Install dependencies and buildrun: |cd docs@@ -26,14 +32,17 @@ jobs:update-docs-subtree:if: github.event_name == 'push' && github.repository == 'stanfordnlp/dspy'runs-on: ubuntu-latest+ permissions:+ contents: readsteps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:+ persist-credentials: falsefetch-depth: 0- name: Push docs to separate repouses: cpina/github-action-push-to-another-repository@55306faa4ed53b815ae49e564af8cfb359d32ae2 # mainenv:- API_TOKEN_GITHUB: ${{ secrets.GH_PAT }}+ API_TOKEN_GITHUB: ${{ secrets.GH_PAT }} # zizmor: ignore[secrets-outside-env]with:source-directory: "docs"destination-github-username: "krypticmouse"diff --git a/.github/workflows/precommits_check.yml b/.github/workflows/precommits_check.ymlindex c103121b4..c10c60c45 100644--- a/.github/workflows/precommits_check.yml+++ b/.github/workflows/precommits_check.yml@@ -2,11 +2,17 @@ name: Pre-commit checkson:workflow_dispatch:+permissions: {}+jobs:pre-commit-checks:runs-on: ubuntu-latest+ permissions:+ contents: readsteps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- name: Set up Pythonuses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:@@ -20,17 +26,22 @@ jobs:id: filesuses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 # v1- name: Checking changed files+ env:+ CHANGED_FILES: ${{ steps.files.outputs.all }}shell: bashrun: |echo "Changed files"- echo ${{ steps.files.outputs.all }}+ echo "$CHANGED_FILES"echo "GitHub Client version"- echo $(gh --version)+ gh --version- name: Pre-Commit Checks+ env:+ CHANGED_FILES: ${{ steps.files.outputs.all }}run: |python -m pip install --upgrade pippip install pre-commitecho "Running pre-commit scans:"# adding log display in case of pre-commit errors- pre-commit run -v --files ${{ steps.files.outputs.all }}+ # shellcheck disable=SC2086+ pre-commit run -v --files $CHANGED_FILESshell: bashdiff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.ymlindex 7b9f5edd5..5c44f4703 100644--- a/.github/workflows/run_tests.yml+++ b/.github/workflows/run_tests.yml@@ -7,6 +7,8 @@ on:pull_request:types: [opened, synchronize, reopened]+permissions: {}+jobs:fix:name: Check Ruff Fix@@ -15,6 +17,8 @@ jobs:contents: readsteps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:python-version: "3.11"@@ -28,7 +32,7 @@ jobs:- name: Create and activate virtual environmentrun: |uv venv .venv- echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH+ echo "${{ github.workspace }}/.venv/bin" >> "$GITHUB_PATH"- name: Install dependenciesrun: uv sync --dev -p .venv --extra dev- name: Ruff Check@@ -47,11 +51,15 @@ jobs:test:name: Run Testsruns-on: ubuntu-latest+ permissions:+ contents: readstrategy:matrix:python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:python-version: ${{ matrix.python-version }}@@ -71,7 +79,7 @@ jobs:- name: Create and activate virtual environmentrun: |uv venv .venv- echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH+ echo "${{ github.workspace }}/.venv/bin" >> "$GITHUB_PATH"- name: Install dependenciesrun: |uv sync --dev -p .venv --extra dev@@ -90,8 +98,12 @@ jobs:llm_call_test:name: Run Tests with Real LMruns-on: ubuntu-latest+ permissions:+ contents: readsteps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:python-version: 3.11@@ -105,7 +117,7 @@ jobs:- name: Create and activate virtual environmentrun: |uv venv .venv- echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH+ echo "${{ github.workspace }}/.venv/bin" >> "$GITHUB_PATH"- name: Install dependenciesrun: |uv sync --dev -p .venv --extra dev@@ -128,12 +140,12 @@ jobs:if: steps.cache-ollama.outputs.cache-hit != 'true'run: docker exec ollama ollama pull llama3.2:3b- name: Set LM environment variable- run: echo "LM_FOR_TEST=ollama/llama3.2:3b" >> $GITHUB_ENV+ run: echo "LM_FOR_TEST=ollama/llama3.2:3b" >> "$GITHUB_ENV"- name: Run testsrun: uv run -p .venv pytest -m llm_call --llm_call -vv --durations=5 tests/- name: Fix permissions for cacheif: always()- run: sudo chown -R $USER:$USER ollama-data || true+ run: sudo chown -R "$USER":"$USER" ollama-data || true- name: Stop Ollama serviceif: always()run: docker stop ollama && docker rm ollama@@ -141,11 +153,15 @@ jobs:build_package:name: Build Packageruns-on: ubuntu-latest+ permissions:+ contents: readstrategy:matrix:python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0with:python-version: ${{ matrix.python-version }}@@ -159,7 +175,7 @@ jobs:- name: Create and activate virtual environmentrun: |uv venv .venv- echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH+ echo "${{ github.workspace }}/.venv/bin" >> "$GITHUB_PATH"- name: Install dependenciesrun: uv sync --dev -p .venv --extra dev- name: Build