Skip to content

Commit 23489a6

Browse files
Extract setup-poetry composite action to remove duplication
Create .github/actions/setup-poetry that bundles JFrog setup, setup-python, poetry install via pip, JFrog source config, cache, and dependency install into a single reusable action with inputs for python-version, install-args, cache-path, and cache-suffix. All workflows now call setup-poetry instead of repeating these steps, matching the pattern from databricks/databricks-sqlalchemy#59. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent 002b492 commit 23489a6

File tree

5 files changed

+96
-229
lines changed

5 files changed

+96
-229
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Setup Poetry with JFrog
2+
description: Install Poetry, configure JFrog as primary PyPI source, and install project dependencies
3+
4+
inputs:
5+
python-version:
6+
description: Python version to set up
7+
required: true
8+
install-args:
9+
description: Extra arguments for poetry install (e.g. --all-extras)
10+
required: false
11+
default: ""
12+
cache-path:
13+
description: Path to the virtualenv for caching (e.g. .venv or .venv-pyarrow)
14+
required: false
15+
default: ".venv"
16+
cache-suffix:
17+
description: Extra suffix for the cache key to avoid collisions across job variants
18+
required: false
19+
default: ""
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Setup JFrog
25+
uses: ./.github/actions/setup-jfrog
26+
27+
- name: Set up python ${{ inputs.python-version }}
28+
id: setup-python
29+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
30+
with:
31+
python-version: ${{ inputs.python-version }}
32+
33+
- name: Install Poetry
34+
shell: bash
35+
run: |
36+
pip install poetry==2.2.1
37+
poetry config virtualenvs.create true
38+
poetry config virtualenvs.in-project true
39+
poetry config installer.parallel true
40+
41+
- name: Configure Poetry JFrog source
42+
shell: bash
43+
run: |
44+
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
45+
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
46+
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
47+
poetry lock
48+
49+
- name: Load cached venv
50+
id: cached-poetry-dependencies
51+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
52+
with:
53+
path: ${{ inputs.cache-path }}
54+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ inputs.cache-suffix }}${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
55+
56+
- name: Install dependencies
57+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
58+
shell: bash
59+
run: poetry install --no-interaction --no-root
60+
61+
- name: Install library
62+
shell: bash
63+
run: poetry install --no-interaction ${{ inputs.install-args }}

.github/workflows/code-coverage.yml

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,15 @@ jobs:
2323
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2424
with:
2525
fetch-depth: 0
26-
- name: Setup JFrog
27-
uses: ./.github/actions/setup-jfrog
28-
- name: Set up python
29-
id: setup-python
30-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
31-
with:
32-
python-version: "3.10"
3326
- name: Install system dependencies
3427
run: |
3528
sudo apt-get update
3629
sudo apt-get install -y libkrb5-dev
37-
- name: Install Poetry
38-
run: |
39-
pip install poetry==2.2.1
40-
poetry config virtualenvs.create true
41-
poetry config virtualenvs.in-project true
42-
poetry config installer.parallel true
43-
- name: Configure Poetry for JFrog
44-
run: |
45-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
46-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
47-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
48-
poetry lock
49-
- name: Load cached venv
50-
id: cached-poetry-dependencies
51-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
30+
- name: Setup Poetry
31+
uses: ./.github/actions/setup-poetry
5232
with:
53-
path: .venv
54-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
55-
- name: Install dependencies
56-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
57-
run: poetry install --no-interaction --no-root
58-
- name: Install Kerberos system dependencies
59-
run: |
60-
sudo apt-get update
61-
sudo apt-get install -y libkrb5-dev
62-
- name: Install library
63-
run: poetry install --no-interaction --all-extras
33+
python-version: "3.10"
34+
install-args: "--all-extras"
6435
- name: Run parallel tests with coverage
6536
continue-on-error: false
6637
run: |

.github/workflows/code-quality-checks.yml

Lines changed: 16 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
matrix:
1616
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1717
dependency-version: ["default", "min"]
18-
# Optimize matrix - test min/max on subset of Python versions
1918
exclude:
2019
- python-version: "3.12"
2120
dependency-version: "min"
@@ -27,36 +26,11 @@ jobs:
2726
steps:
2827
- name: Check out repository
2928
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
30-
- name: Setup JFrog
31-
uses: ./.github/actions/setup-jfrog
32-
- name: Set up python ${{ matrix.python-version }}
33-
id: setup-python
34-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
29+
- name: Setup Poetry
30+
uses: ./.github/actions/setup-poetry
3531
with:
3632
python-version: ${{ matrix.python-version }}
37-
- name: Install Poetry
38-
run: |
39-
pip install poetry==2.2.1
40-
poetry config virtualenvs.create true
41-
poetry config virtualenvs.in-project true
42-
poetry config installer.parallel true
43-
- name: Configure Poetry for JFrog
44-
run: |
45-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
46-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
47-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
48-
poetry lock
49-
- name: Load cached venv
50-
id: cached-poetry-dependencies
51-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
52-
with:
53-
path: .venv
54-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ matrix.dependency-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
55-
- name: Install dependencies
56-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
57-
run: poetry install --no-interaction --no-root
58-
- name: Install library
59-
run: poetry install --no-interaction
33+
cache-suffix: "${{ matrix.dependency-version }}-"
6034
- name: Install Python tools for custom versions
6135
if: matrix.dependency-version != 'default'
6236
run: poetry run pip install toml packaging
@@ -94,41 +68,18 @@ jobs:
9468

9569
steps:
9670
- name: Check out repository
97-
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
98-
- name: Setup JFrog
99-
uses: ./.github/actions/setup-jfrog
100-
- name: Set up python ${{ matrix.python-version }}
101-
id: setup-python
102-
uses: actions/setup-python@e9aba2c848f5ebd159c070c61ea2c4e2b122355e # v2
103-
with:
104-
python-version: ${{ matrix.python-version }}
105-
- name: Install Poetry
106-
run: |
107-
pip install poetry==2.2.1
108-
poetry config virtualenvs.create true
109-
poetry config virtualenvs.in-project true
110-
poetry config installer.parallel true
111-
- name: Configure Poetry for JFrog
112-
run: |
113-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
114-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
115-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
116-
poetry lock
117-
- name: Load cached venv
118-
id: cached-poetry-dependencies
119-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
120-
with:
121-
path: .venv-pyarrow
122-
key: venv-pyarrow-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ matrix.dependency-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
123-
- name: Install dependencies
124-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
125-
run: poetry install --no-interaction --no-root
71+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
12672
- name: Install Kerberos system dependencies
12773
run: |
12874
sudo apt-get update
12975
sudo apt-get install -y libkrb5-dev
130-
- name: Install library
131-
run: poetry install --no-interaction --all-extras
76+
- name: Setup Poetry
77+
uses: ./.github/actions/setup-poetry
78+
with:
79+
python-version: ${{ matrix.python-version }}
80+
install-args: "--all-extras"
81+
cache-path: ".venv-pyarrow"
82+
cache-suffix: "pyarrow-${{ matrix.dependency-version }}-"
13283
- name: Install Python tools for custom versions
13384
if: matrix.dependency-version != 'default'
13485
run: poetry run pip install toml packaging
@@ -158,36 +109,10 @@ jobs:
158109
steps:
159110
- name: Check out repository
160111
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
161-
- name: Setup JFrog
162-
uses: ./.github/actions/setup-jfrog
163-
- name: Set up python ${{ matrix.python-version }}
164-
id: setup-python
165-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
112+
- name: Setup Poetry
113+
uses: ./.github/actions/setup-poetry
166114
with:
167115
python-version: ${{ matrix.python-version }}
168-
- name: Install Poetry
169-
run: |
170-
pip install poetry==2.2.1
171-
poetry config virtualenvs.create true
172-
poetry config virtualenvs.in-project true
173-
poetry config installer.parallel true
174-
- name: Configure Poetry for JFrog
175-
run: |
176-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
177-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
178-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
179-
poetry lock
180-
- name: Load cached venv
181-
id: cached-poetry-dependencies
182-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
183-
with:
184-
path: .venv
185-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
186-
- name: Install dependencies
187-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
188-
run: poetry install --no-interaction --no-root
189-
- name: Install library
190-
run: poetry install --no-interaction
191116
- name: Black
192117
run: poetry run black --check src
193118

@@ -201,37 +126,11 @@ jobs:
201126
steps:
202127
- name: Check out repository
203128
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
204-
- name: Setup JFrog
205-
uses: ./.github/actions/setup-jfrog
206-
- name: Set up python ${{ matrix.python-version }}
207-
id: setup-python
208-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
129+
- name: Setup Poetry
130+
uses: ./.github/actions/setup-poetry
209131
with:
210132
python-version: ${{ matrix.python-version }}
211-
- name: Install Poetry
212-
run: |
213-
pip install poetry==2.2.1
214-
poetry config virtualenvs.create true
215-
poetry config virtualenvs.in-project true
216-
poetry config installer.parallel true
217-
- name: Configure Poetry for JFrog
218-
run: |
219-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
220-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
221-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
222-
poetry lock
223-
- name: Load cached venv
224-
id: cached-poetry-dependencies
225-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
226-
with:
227-
path: .venv
228-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
229-
- name: Install dependencies
230-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
231-
run: poetry install --no-interaction --no-root
232-
- name: Install library
233-
run: poetry install --no-interaction
234133
- name: Mypy
235134
run: |
236-
mkdir .mypy_cache # Workaround for bad error message "error: --install-types failed (no mypy cache directory)"; see https://github.com/python/mypy/issues/10768#issuecomment-2178450153
135+
mkdir .mypy_cache
237136
poetry run mypy --install-types --non-interactive src

.github/workflows/daily-telemetry-e2e.yml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,15 @@ jobs:
3333
steps:
3434
- name: Check out repository
3535
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
36-
- name: Setup JFrog
37-
uses: ./.github/actions/setup-jfrog
38-
- name: Set up python
39-
id: setup-python
40-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
41-
with:
42-
python-version: "3.10"
4336
- name: Install Kerberos system dependencies
4437
run: |
4538
sudo apt-get update
4639
sudo apt-get install -y libkrb5-dev
47-
- name: Install Poetry
48-
run: |
49-
pip install poetry==2.2.1
50-
poetry config virtualenvs.create true
51-
poetry config virtualenvs.in-project true
52-
poetry config installer.parallel true
53-
- name: Configure Poetry for JFrog
54-
run: |
55-
poetry config repositories.jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
56-
poetry config http-basic.jfrog gha-service-account "${JFROG_ACCESS_TOKEN}"
57-
poetry source add --priority=primary jfrog https://databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple
58-
poetry lock
59-
- name: Load cached venv
60-
id: cached-poetry-dependencies
61-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
40+
- name: Setup Poetry
41+
uses: ./.github/actions/setup-poetry
6242
with:
63-
path: .venv
64-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
65-
- name: Install dependencies
66-
run: poetry install --no-interaction --all-extras
43+
python-version: "3.10"
44+
install-args: "--all-extras"
6745
- name: Run telemetry E2E tests
6846
run: |
6947
TEST_PATTERN="${{ github.event.inputs.test_pattern || 'tests/e2e/test_telemetry_e2e.py' }}"

0 commit comments

Comments
 (0)