Skip to content

Commit 498123c

Browse files
committed
fix(action): speed up by directly using setup-python
1 parent ae5fa3e commit 498123c

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

action.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,44 @@ inputs:
1414
extra_requirements:
1515
description: "Install extra dependencies"
1616
required: false
17+
cache:
18+
description: "Cache commitizen installation"
19+
required: false
20+
default: "true"
1721

1822
runs:
1923
using: "composite"
2024
steps:
21-
- uses: actions/setup-python@v6
2225
- id: set-vars
2326
shell: python
2427
env:
2528
COMMITIZEN_VERSION: ${{ inputs.version }}
29+
CACHE: ${{ inputs.cache }}
2630
run: |
2731
import os
32+
33+
# Set commitizen version
2834
commitizen_version = os.environ.get("COMMITIZEN_VERSION", "").strip()
2935
if commitizen_version == "latest":
3036
set_commitizen_version = ""
3137
else:
3238
set_commitizen_version = f"=={commitizen_version}"
39+
40+
# Set python cache
41+
cache = os.environ.get("CACHE", "")
42+
if cache == True or cache == "true":
43+
set_cache = "pip"
44+
else:
45+
set_cache = ""
46+
47+
# Write outputs
3348
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
3449
fh.write(f"COMMITIZEN_VERSION={set_commitizen_version}\n")
35-
- name: Install commitizen
36-
shell: bash
37-
env:
38-
COMMITIZEN_VERSION: ${{ steps.set-vars.outputs.COMMITIZEN_VERSION }}
39-
EXTRA_REQUIREMENTS: ${{ inputs.extra_requirements }}
50+
fh.write(f"PYTHON_CACHE={set_cache}\n")
51+
- uses: actions/setup-python@v6
52+
with:
53+
cache: ${{ steps.set-vars.outputs.PYTHON_CACHE }}
54+
pip-install: commitizen${steps.set-vars.outputs.COMMITIZEN_VERSION} ${inputs.extra_requirements}
55+
- shell: bash
4056
run: |
41-
pip install -U commitizen${COMMITIZEN_VERSION} ${EXTRA_REQUIREMENTS}
57+
python -m cz version

0 commit comments

Comments
 (0)