Skip to content

Commit 51ab9b2

Browse files
committed
Use pyproject.toml as Python version source
Python and Python-based tools are used in the development and maintenance of the project. A standardized version of Python is used for these operations. Poetry is used for Python package dependencies management. Poetry installs dependencies into a virtual environment. For this reason, the Poetry configuration includes a Python version number, which must match the correct version of Python for the project. This configuration is stored in the `pyproject.toml` file. Python is installed in the GitHub Actions runner environments using the "actions/setup-python" action, which also must be configured to install the correct version of Python. Previously the version number for use by the actions/setup-python action was defined in each workflow. This meant that we had multiple copies of the Python version information, all of which had to be kept in sync. Fortunately, support for using `pyproject.toml` as the source of version information for the "actions/setup-python" action was recently added. This means it is now possible for all components of the project infrastructure to get the Python version from a single source.
1 parent 07dc9c5 commit 51ab9b2

5 files changed

+6
-20
lines changed

.github/workflows/check-mkdocs-task.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ name: Check Website
44
env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.17"
7-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
8-
PYTHON_VERSION: "3.9"
97

108
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
119
on:
@@ -88,7 +86,7 @@ jobs:
8886
- name: Install Python
8987
uses: actions/setup-python@v5
9088
with:
91-
python-version: ${{ env.PYTHON_VERSION }}
89+
python-version-file: pyproject.toml
9290

9391
- name: Install Poetry
9492
run: pip install poetry

.github/workflows/check-python-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-python-task.md
22
name: Check Python
33

4-
env:
5-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6-
PYTHON_VERSION: "3.9"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -73,7 +69,7 @@ jobs:
7369
- name: Install Python
7470
uses: actions/setup-python@v5
7571
with:
76-
python-version: ${{ env.PYTHON_VERSION }}
72+
python-version-file: pyproject.toml
7773

7874
- name: Install Poetry
7975
run: pip install poetry
@@ -104,7 +100,7 @@ jobs:
104100
- name: Install Python
105101
uses: actions/setup-python@v5
106102
with:
107-
python-version: ${{ env.PYTHON_VERSION }}
103+
python-version-file: pyproject.toml
108104

109105
- name: Install Poetry
110106
run: pip install poetry

.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ name: Deploy Website
44
env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.17"
7-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
8-
PYTHON_VERSION: "3.9"
97

108
on:
119
push:
@@ -76,7 +74,7 @@ jobs:
7674
- name: Install Python
7775
uses: actions/setup-python@v5
7876
with:
79-
python-version: ${{ env.PYTHON_VERSION }}
77+
python-version-file: pyproject.toml
8078

8179
- name: Install Poetry
8280
run: |

.github/workflows/spell-check-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
22
name: Spell Check
33

4-
env:
5-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6-
PYTHON_VERSION: "3.9"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -55,7 +51,7 @@ jobs:
5551
- name: Install Python
5652
uses: actions/setup-python@v5
5753
with:
58-
python-version: ${{ env.PYTHON_VERSION }}
54+
python-version-file: pyproject.toml
5955

6056
- name: Install Poetry
6157
run: pip install poetry

.github/workflows/test-go-integration-task.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ name: Test Integration
44
env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.17"
7-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
8-
PYTHON_VERSION: "3.9"
97

108
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
119
on:
@@ -88,7 +86,7 @@ jobs:
8886
- name: Install Python
8987
uses: actions/setup-python@v5
9088
with:
91-
python-version: ${{ env.PYTHON_VERSION }}
89+
python-version-file: pyproject.toml
9290

9391
- name: Install Poetry
9492
run: pip install poetry

0 commit comments

Comments
 (0)