Skip to content

Commit c36f7a6

Browse files
authored
[CI] Reuse Python provisioning code (#5457)
1 parent 0ea697c commit c36f7a6

File tree

6 files changed

+49
-34
lines changed

6 files changed

+49
-34
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: setup-python
2+
description: Sets up python
3+
inputs:
4+
python_version:
5+
description: Python version
6+
default: "3.10"
7+
use_pyenv:
8+
description: Use pyenv to install Python
9+
default: "false"
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
14+
if: ${{ !inputs.use_pyenv }}
15+
uses: actions/setup-python@v6
16+
with:
17+
python-version: ${{ inputs.python_version }}
18+
19+
- name: Install Python (from pyenv) ${{ inputs.python_version }}
20+
if: ${{ inputs.use_pyenv }}
21+
uses: ./.github/actions/setup-pyenv-python
22+
with:
23+
python-version: ${{ inputs.python_version }}

.github/workflows/build-test-reusable.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,11 @@ jobs:
9999
path: $HOME/.cache/pip
100100
key: pip-${{ inputs.python_version }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.PIP_CACHE_NUMBER }}
101101

102-
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
103-
if: ${{ !inputs.use_pyenv_python }}
104-
uses: actions/setup-python@v6
102+
- name: Install Python
103+
uses: ./.github/actions/setup-python
105104
with:
106-
python-version: ${{ inputs.python_version }}
107-
108-
- name: Install Python (from pyenv) ${{ inputs.python_version }}
109-
if: ${{ inputs.use_pyenv_python }}
110-
uses: ./.github/actions/setup-pyenv-python
111-
with:
112-
python-version: ${{ inputs.python_version }}
105+
python_version: ${{ inputs.python_version }}
106+
use_pyenv: ${{ inputs.use_pyenv_python }}
113107

114108
# Build PyTorch here once, integration tests jobs should load it from cache.
115109
- name: Setup PyTorch
@@ -229,17 +223,11 @@ jobs:
229223
path: $HOME/.cache/pip
230224
key: pip-${{ inputs.python_version }}-${{ matrix.suite }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.PIP_CACHE_NUMBER }}
231225

232-
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
233-
if: ${{ !inputs.use_pyenv_python }}
234-
uses: actions/setup-python@v6
235-
with:
236-
python-version: ${{ inputs.python_version }}
237-
238-
- name: Install Python (from pyenv) ${{ inputs.python_version }}
239-
if: ${{ inputs.use_pyenv_python }}
240-
uses: ./.github/actions/setup-pyenv-python
226+
- name: Install Python
227+
uses: ./.github/actions/setup-python
241228
with:
242-
python-version: ${{ inputs.python_version }}
229+
python_version: ${{ inputs.python_version }}
230+
use_pyenv: ${{ inputs.use_pyenv_python }}
243231

244232
- name: Setup PyTorch
245233
uses: ./.github/actions/setup-pytorch
@@ -423,10 +411,11 @@ jobs:
423411
path: reports
424412
merge-multiple: true
425413

426-
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
427-
uses: actions/setup-python@v6
414+
- name: Install Python
415+
uses: ./.github/actions/setup-python
428416
with:
429-
python-version: ${{ inputs.python_version }}
417+
python_version: ${{ inputs.python_version }}
418+
use_pyenv: ${{ inputs.use_pyenv_python }}
430419

431420
- name: Install pass_rate dependencies
432421
run: |

.github/workflows/build-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ jobs:
7878
path: $HOME/.cache/pip
7979
key: pip-3.10-${{ hashFiles('.pre-commit-config.yaml') }}-${{ env.CACHE_NUMBER }}
8080

81-
- name: Install Python (from pyenv)
82-
uses: ./.github/actions/setup-pyenv-python
81+
- name: Install Python
82+
uses: ./.github/actions/setup-python
8383
with:
84-
python-version: '3.10'
84+
python_version: "3.10"
85+
use_pyenv: true
8586

8687
- name: Run pre-commit checks
8788
run: |

.github/workflows/coverity.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ jobs:
2424
run: |
2525
sudo apt install -y file
2626
27-
- name: Install Python (from pyenv)
28-
uses: ./.github/actions/setup-pyenv-python
27+
- name: Install Python
28+
uses: ./.github/actions/setup-python
2929
with:
30-
python-version: '3.10'
30+
python_version: "3.10"
31+
use_pyenv: true
3132

3233
- name: Load coverity from cache
3334
id: coverity-cache

.github/workflows/e2e-accuracy.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ jobs:
148148
- name: Checkout repository
149149
uses: actions/checkout@v5
150150

151-
- name: Install Python (from pyenv)
152-
uses: ./.github/actions/setup-pyenv-python
151+
- name: Install Python
152+
uses: ./.github/actions/setup-python
153153
with:
154-
python-version: "3.10"
154+
python_version: "3.10"
155+
use_pyenv: true
155156

156157
- name: Download all artifacts
157158
uses: actions/download-artifact@v6

.github/workflows/e2e-reusable.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ jobs:
8484
key: pip-$PYTHON_VERSION-$GITHUB_SHA
8585

8686
- name: Install Python
87-
uses: actions/setup-python@v6
87+
uses: ./.github/actions/setup-python
8888
with:
89-
python-version: ${{ env.PYTHON_VERSION }}
89+
python_version: ${{ env.PYTHON_VERSION }}
9090

9191
- name: Install Python build dependencies
9292
run: |

0 commit comments

Comments
 (0)