Skip to content

Commit a970e01

Browse files
committed
chore(ci): use variable for poetry version
Signed-off-by: Fatih Acar <[email protected]>
1 parent 4ba55e7 commit a970e01

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ env:
2929
METRICS_ENDPOINT: ${{ secrets.METRICS_ENDPOINT }}
3030

3131
jobs:
32-
# ------------------------------------------ Check Files Changes ------------------------------------------
32+
prepare-environment:
33+
uses: ./.github/workflows/define-versions.yml
34+
# ------------------------------------------ Check Files Changes ------------------------------------------
3335
files-changed:
3436
name: Detect which file has changed
3537
runs-on: ubuntu-latest
@@ -152,7 +154,7 @@ jobs:
152154
!contains(needs.*.result, 'failure') &&
153155
!contains(needs.*.result, 'cancelled') &&
154156
(needs.files-changed.outputs.python == 'true') || (needs.files-changed.outputs.documentation_generated == 'true')
155-
needs: ["files-changed", "yaml-lint", "python-lint"]
157+
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
156158
runs-on: "ubuntu-22.04"
157159
timeout-minutes: 5
158160
steps:
@@ -166,7 +168,7 @@ jobs:
166168
python-version: "3.12"
167169
- name: "Setup Python environment"
168170
run: |
169-
pipx install poetry==2.1
171+
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
170172
poetry config virtualenvs.create true --local
171173
poetry env use 3.12
172174
- name: "Install dependencies"
@@ -218,7 +220,7 @@ jobs:
218220
!contains(needs.*.result, 'failure') &&
219221
!contains(needs.*.result, 'cancelled') &&
220222
needs.files-changed.outputs.python == 'true'
221-
needs: ["files-changed", "yaml-lint", "python-lint"]
223+
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
222224
runs-on: ubuntu-latest
223225
timeout-minutes: 30
224226
steps:
@@ -230,7 +232,7 @@ jobs:
230232
python-version: ${{ matrix.python-version }}
231233
- name: "Setup environment"
232234
run: |
233-
pipx install poetry==2.1 --python python${{ matrix.python-version }}
235+
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }} --python python${{ matrix.python-version }}
234236
poetry config virtualenvs.create true --local
235237
pip install invoke toml codecov
236238
- name: "Install Package"
@@ -266,7 +268,7 @@ jobs:
266268
!contains(needs.*.result, 'failure') &&
267269
!contains(needs.*.result, 'cancelled') &&
268270
needs.files-changed.outputs.python == 'true'
269-
needs: ["files-changed", "yaml-lint", "python-lint"]
271+
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
270272
runs-on:
271273
group: "huge-runners"
272274
timeout-minutes: 30
@@ -283,7 +285,7 @@ jobs:
283285
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
284286
- name: "Setup environment"
285287
run: |
286-
pipx install poetry==2.1
288+
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
287289
poetry config virtualenvs.create true --local
288290
pip install invoke toml codecov
289291
- name: "Install Package"
@@ -306,7 +308,7 @@ jobs:
306308
# !contains(needs.*.result, 'cancelled') &&
307309
# needs.files-changed.outputs.python == 'true' &&
308310
# (github.base_ref == 'stable' || github.base_ref == 'develop')
309-
# needs: ["files-changed", "yaml-lint", "python-lint"]
311+
# needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
310312
# runs-on:
311313
# group: "huge-runners"
312314
# timeout-minutes: 30
@@ -356,7 +358,7 @@ jobs:
356358

357359
# - name: "Setup environment"
358360
# run: |
359-
# pipx install poetry==2.1
361+
# pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
360362
# poetry config virtualenvs.create true --local
361363
# pip install invoke toml codecov
362364

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
# yamllint disable rule:truthy rule:truthy rule:line-length
3+
name: "Define versions"
4+
on:
5+
workflow_call:
6+
outputs:
7+
POETRY_VERSION:
8+
value: "2.1.3"
9+
10+
jobs:
11+
prepare:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- run: "true"

.github/workflows/publish-pypi.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ on:
2929
default: false
3030

3131
jobs:
32+
prepare-environment:
33+
uses: ./.github/workflows/define-versions.yml
3234
publish_to_pypi:
3335
name: "Publish Infrahub SDK to PyPI"
3436
runs-on: "ubuntu-22.04"
37+
needs: prepare-environment
3538
steps:
3639
- name: "Set up Python"
3740
uses: "actions/setup-python@v5"
@@ -41,7 +44,7 @@ jobs:
4144
- name: "Install Poetry"
4245
uses: "snok/install-poetry@v1"
4346
with:
44-
version: 1.8.5
47+
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
4548
virtualenvs-create: true
4649
virtualenvs-in-project: true
4750
installer-parallel: true

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ on:
88
- published
99

1010
jobs:
11+
prepare-environment:
12+
uses: ./.github/workflows/define-versions.yml
1113
check_release:
1214
runs-on: ubuntu-22.04
15+
needs: prepare-environment
1316
outputs:
1417
is_prerelease: ${{ steps.release.outputs.is_prerelease }}
1518
is_devrelease: ${{ steps.release.outputs.is_devrelease }}
@@ -30,7 +33,7 @@ jobs:
3033
- name: "Install Poetry"
3134
uses: "snok/install-poetry@v1"
3235
with:
33-
version: 1.8.5
36+
version: ${{ needs.prepare-environment.outputs.POETRY_VERSION }}
3437
virtualenvs-create: true
3538
virtualenvs-in-project: true
3639
installer-parallel: true

0 commit comments

Comments
 (0)