Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d5a3e8

Browse files
authored
Enable caching in Python tests workflow (#33355)
* 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
1 parent 43b2bf7 commit 1d5a3e8

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,41 @@ inputs:
3434
required: false
3535
description: 'Whether to disable the gradle cache'
3636
default: false
37+
python-cache:
38+
required: false
39+
description: 'Whether to enable Python pip caching'
40+
default: true
41+
tox-cache:
42+
required: false
43+
description: 'Whether to enable tox environment caching'
44+
default: true
3745

3846
runs:
3947
using: "composite"
4048
steps:
4149
- name: Install Python
4250
if: ${{ inputs.python-version != '' }}
43-
uses: actions/setup-python@v4
51+
uses: actions/setup-python@v5
4452
with:
4553
python-version: ${{ inputs.python-version == 'default' && '3.9' || inputs.python-version }}
54+
cache: ${{ inputs.python-cache && 'pip' || 'none' }}
55+
cache-dependency-path: |
56+
sdks/python/setup.py
57+
sdks/python/tox.ini
58+
59+
- name: Cache tox environments
60+
if: ${{ inputs.python-version != '' && inputs.tox-cache == 'true' }}
61+
uses: actions/cache@v3
62+
with:
63+
path: |
64+
sdks/python/target/.tox
65+
!sdks/python/target/.tox/**/log
66+
!sdks/python/target/.tox/.package_cache
67+
key: tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-${{ hashFiles('sdks/python/setup.py') }}
68+
restore-keys: |
69+
tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-${{ hashFiles('sdks/python/tox.ini') }}-
70+
tox-${{ runner.os }}-py${{ inputs.python-version == 'default' && '39' || inputs.python-version }}-
71+
4672
- name: Install Java
4773
if: ${{ inputs.java-version != '' }}
4874
uses: actions/setup-java@v3

.github/workflows/python_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ jobs:
9393
matrix:
9494
os: [macos-latest, windows-latest]
9595
params: [
96-
{"py_ver": "3.9", "tox_env": "py39"},
97-
{"py_ver": "3.10", "tox_env": "py310" },
96+
{ "py_ver": "3.9", "tox_env": "py39" },
97+
{ "py_ver": "3.10", "tox_env": "py310" },
9898
{ "py_ver": "3.11", "tox_env": "py311" },
9999
{ "py_ver": "3.12", "tox_env": "py312" },
100100
]

0 commit comments

Comments
 (0)