From b976f9469cbce850a1ec457776e349fc06df87e1 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 13 Jun 2024 15:16:49 -0700 Subject: [PATCH] Use pyproject.toml as Python version source All execution, development and validation for the project is performed using a specific version of Python. 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 a the version number for use by the actions/setup-python action was defined in the `.python-version` file. This allowed the Python version for use by the arduino/compile-sketches action's execution and all the workflows that make up its infrastructure to be configured from a single source. However, Poetry does not support the `.python-version` file so we were stuck with two copies of the Python version information, which must be kept in sync. Fortunately, support for using `pyproject.toml` as the version file 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. --- .github/workflows/check-python-task.yml | 6 ++---- .github/workflows/check-yaml-task.yml | 4 +--- .github/workflows/spell-check-task.yml | 2 +- .github/workflows/test-integration.yml | 2 -- .github/workflows/test-python-poetry-task.yml | 4 +--- .python-version | 1 - action.yml | 2 +- 7 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 .python-version diff --git a/.github/workflows/check-python-task.yml b/.github/workflows/check-python-task.yml index 8eaaaef7..27e7ed26 100644 --- a/.github/workflows/check-python-task.yml +++ b/.github/workflows/check-python-task.yml @@ -11,7 +11,6 @@ on: - "**/poetry.lock" - "**/pyproject.toml" - "**/setup.cfg" - - ".python-version" - "Taskfile.ya?ml" - "**/tox.ini" - "**.py" @@ -22,7 +21,6 @@ on: - "**/poetry.lock" - "**/pyproject.toml" - "**/setup.cfg" - - ".python-version" - "Taskfile.ya?ml" - "**/tox.ini" - "**.py" @@ -71,7 +69,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: .python-version + python-version-file: pyproject.toml - name: Install Poetry run: | @@ -105,7 +103,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: .python-version + python-version-file: pyproject.toml - name: Install Poetry run: | diff --git a/.github/workflows/check-yaml-task.yml b/.github/workflows/check-yaml-task.yml index 6cad3416..7c7ecd18 100644 --- a/.github/workflows/check-yaml-task.yml +++ b/.github/workflows/check-yaml-task.yml @@ -6,7 +6,6 @@ on: create: push: paths: - - ".python-version" - ".yamllint*" - "poetry.lock" - "pyproject.toml" @@ -23,7 +22,6 @@ on: - "**.syntax" pull_request: paths: - - ".python-version" - ".yamllint*" - "poetry.lock" - "pyproject.toml" @@ -99,7 +97,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: .python-version + python-version-file: pyproject.toml - name: Install Poetry run: | diff --git a/.github/workflows/spell-check-task.yml b/.github/workflows/spell-check-task.yml index 09c0c60b..e5c24ce0 100644 --- a/.github/workflows/spell-check-task.yml +++ b/.github/workflows/spell-check-task.yml @@ -51,7 +51,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: .python-version + python-version-file: pyproject.toml - name: Install Poetry run: | diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 897ff41d..4ba6d931 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -7,7 +7,6 @@ on: paths: - ".github/workflows/test-integration.yml" - ".github/workflows/testdata/**" - - ".python-version" - "poetry.lock" - "pyproject.toml" - "action.yml" @@ -17,7 +16,6 @@ on: paths: - ".github/workflows/test-integration.yml" - ".github/workflows/testdata/**" - - ".python-version" - "poetry.lock" - "pyproject.toml" - "action.yml" diff --git a/.github/workflows/test-python-poetry-task.yml b/.github/workflows/test-python-poetry-task.yml index 754a0815..028e4952 100644 --- a/.github/workflows/test-python-poetry-task.yml +++ b/.github/workflows/test-python-poetry-task.yml @@ -11,7 +11,6 @@ on: - "dev/.?codecov.ya?ml" - ".?codecov.ya?ml" - "Taskfile.ya?ml" - - ".python-version" - "poetry.lock" - "pyproject.toml" - "compilesketches/tests/**" @@ -24,7 +23,6 @@ on: - "dev/.?codecov.ya?ml" - ".?codecov.ya?ml" - "Taskfile.ya?ml" - - ".python-version" - "poetry.lock" - "pyproject.toml" - "compilesketches/tests/**" @@ -75,7 +73,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: .python-version + python-version-file: pyproject.toml - name: Install Poetry run: | diff --git a/.python-version b/.python-version deleted file mode 100644 index 1e334568..00000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.11.2 diff --git a/action.yml b/action.yml index 9e75969a..26fba2e9 100644 --- a/action.yml +++ b/action.yml @@ -76,7 +76,7 @@ runs: - name: Install Python uses: actions/setup-python@v5 with: - python-version-file: ${{ github.action_path }}/.python-version + python-version-file: ${{ github.action_path }}/pyproject.toml - name: Action setup shell: bash