5656 sdks/python/setup.py
5757 sdks/python/tox.ini
5858
59+ # Multiline python-version (e.g. 3.10\n3.11\n...) must not be embedded raw
60+ # in cache keys: actions/cache treats each newline-separated line as a
61+ # separate key and fails when there are more than 10 ("Keys are limited to
62+ # a maximum of 10"). Collapse whitespace into a single key fragment.
63+ - name : Sanitize Python version for tox cache key
64+ if : ${{ inputs.python-version != '' && inputs.tox-cache == 'true' }}
65+ id : py-cache-key
66+ shell : bash
67+ env :
68+ PYTHON_VERSION_INPUT : ${{ inputs.python-version }}
69+ run : |
70+ if [[ "$PYTHON_VERSION_INPUT" == "default" ]]; then
71+ sanitized="310"
72+ else
73+ sanitized=$(printf '%s' "$PYTHON_VERSION_INPUT" | tr -s '[:space:]' '-' | sed 's/^-//;s/-$//')
74+ fi
75+ echo "sanitized=$sanitized" >> "$GITHUB_OUTPUT"
76+
5977 - name : Cache tox environments
6078 if : ${{ inputs.python-version != '' && inputs.tox-cache == 'true' }}
6179 uses : actions/cache@v6
@@ -64,10 +82,10 @@ runs:
6482 sdks/python/target/.tox
6583 !sdks/python/target/.tox/**/log
6684 !sdks/python/target/.tox/.package_cache
67- key : tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '310' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-${{ hashFiles('sdks/python/setup.py') }}
85+ key : tox-${{ runner.os }}-py${{ steps.py-cache-key.outputs.sanitized }}-${{ hashFiles('sdks/python/tox.ini') }}-${{ hashFiles('sdks/python/setup.py') }}
6886 restore-keys : |
69- tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '310' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-
70- tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '310' || inputs.python-version }}-
87+ tox-${{ runner.os }}-py${{ steps.py-cache-key.outputs.sanitized }}-${{ hashFiles('sdks/python/tox.ini') }}-
88+ tox-${{ runner.os }}-py${{ steps.py-cache-key.outputs.sanitized }}-
7189
7290 - name : Install Java
7391 if : ${{ inputs.java-version != '' }}
0 commit comments