Skip to content

Commit

Permalink
Enable caching in Python tests workflow (#33355)
Browse files Browse the repository at this point in the history
* Enable caching in Python tests workflow

As can be seen in [BuildBudget's demo](https://buildbudget.dev/demo/workflow/2083803/), this
workflow costs ~$2k/month.

This change should reduce the time it takes and eventually its cost by using standard
caching techniques.

* fixup! Enable caching in Python tests workflow

* removed unnecessary input

* fixup! removed unnecessary input
  • Loading branch information
eduramirezh authored Jan 7, 2025
1 parent 43b2bf7 commit 1d5a3e8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
28 changes: 27 additions & 1 deletion .github/actions/setup-environment-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,41 @@ inputs:
required: false
description: 'Whether to disable the gradle cache'
default: false
python-cache:
required: false
description: 'Whether to enable Python pip caching'
default: true
tox-cache:
required: false
description: 'Whether to enable tox environment caching'
default: true

runs:
using: "composite"
steps:
- name: Install Python
if: ${{ inputs.python-version != '' }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version == 'default' && '3.9' || inputs.python-version }}
cache: ${{ inputs.python-cache && 'pip' || 'none' }}
cache-dependency-path: |
sdks/python/setup.py
sdks/python/tox.ini
- name: Cache tox environments
if: ${{ inputs.python-version != '' && inputs.tox-cache == 'true' }}
uses: actions/cache@v3
with:
path: |
sdks/python/target/.tox
!sdks/python/target/.tox/**/log
!sdks/python/target/.tox/.package_cache
key: tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-${{ hashFiles('sdks/python/setup.py') }}
restore-keys: |
tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-
tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-
- name: Install Java
if: ${{ inputs.java-version != '' }}
uses: actions/setup-java@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ jobs:
matrix:
os: [macos-latest, windows-latest]
params: [
{"py_ver": "3.9", "tox_env": "py39"},
{"py_ver": "3.10", "tox_env": "py310" },
{ "py_ver": "3.9", "tox_env": "py39" },
{ "py_ver": "3.10", "tox_env": "py310" },
{ "py_ver": "3.11", "tox_env": "py311" },
{ "py_ver": "3.12", "tox_env": "py312" },
]
Expand Down

0 comments on commit 1d5a3e8

Please sign in to comment.