From 780dc178a10fcfee2ee87adf842c88efa0da4794 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Wed, 4 Mar 2026 16:53:31 +0100 Subject: [PATCH] Use Python version file in CI for setting the default python version (#164751) --- .github/workflows/builder.yml | 13 ++++---- .github/workflows/ci.yaml | 52 ++++++++++++++++-------------- .github/workflows/translations.yml | 7 ++-- .github/workflows/wheels.yml | 7 ++-- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index 42f5842e8d1..4da14798852 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -10,7 +10,6 @@ on: env: BUILD_TYPE: core - DEFAULT_PYTHON: "3.14.2" PIP_TIMEOUT: 60 UV_HTTP_TIMEOUT: 60 UV_SYSTEM_PYTHON: "true" @@ -42,10 +41,10 @@ jobs: with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" - name: Get information id: info @@ -132,11 +131,11 @@ jobs: workflow_conclusion: success name: package - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python if: needs.init.outputs.channel == 'dev' uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" - name: Adjust nightly version if: needs.init.outputs.channel == 'dev' @@ -538,10 +537,10 @@ jobs: with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" - name: Download translations uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e42481e05be..d9705417a3d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,8 +41,7 @@ env: UV_CACHE_VERSION: 1 MYPY_CACHE_VERSION: 1 HA_SHORT_VERSION: "2026.4" - DEFAULT_PYTHON: "3.14.2" - ALL_PYTHON_VERSIONS: "['3.14.2']" + ADDITIONAL_PYTHON_VERSIONS: "[]" # 10.3 is the oldest supported version # - 10.3.32 is the version currently shipped with Synology (as of 17 Feb 2022) # 10.6 is the current long-term-support @@ -166,6 +165,11 @@ jobs: tests_glob="" lint_only="" skip_coverage="" + default_python=$(cat .python-version) + all_python_versions=$(jq -cn \ + --arg default_python "${default_python}" \ + --argjson additional_python_versions "${ADDITIONAL_PYTHON_VERSIONS}" \ + '[$default_python] + $additional_python_versions') if [[ "${INTEGRATION_CHANGES}" != "[]" ]]; then @@ -235,8 +239,8 @@ jobs: echo "mariadb_groups=${mariadb_groups}" >> $GITHUB_OUTPUT echo "postgresql_groups: ${postgresql_groups}" echo "postgresql_groups=${postgresql_groups}" >> $GITHUB_OUTPUT - echo "python_versions: ${ALL_PYTHON_VERSIONS}" - echo "python_versions=${ALL_PYTHON_VERSIONS}" >> $GITHUB_OUTPUT + echo "python_versions: ${all_python_versions}" + echo "python_versions=${all_python_versions}" >> $GITHUB_OUTPUT echo "test_full_suite: ${test_full_suite}" echo "test_full_suite=${test_full_suite}" >> $GITHUB_OUTPUT echo "integrations_glob: ${integrations_glob}" @@ -503,13 +507,13 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: @@ -540,13 +544,13 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: @@ -576,11 +580,11 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - name: Run gen_copilot_instructions.py run: | @@ -682,13 +686,13 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: @@ -735,13 +739,13 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: @@ -786,11 +790,11 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - name: Generate partial mypy restore key id: generate-mypy-key @@ -798,7 +802,7 @@ jobs: mypy_version=$(cat requirements_test.txt | grep 'mypy.*=' | cut -d '=' -f 3) echo "version=${mypy_version}" >> $GITHUB_OUTPUT echo "key=mypy-${MYPY_CACHE_VERSION}-${mypy_version}-${HA_SHORT_VERSION}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: @@ -879,13 +883,13 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + - name: Restore full Python virtual environment id: cache-venv uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index d400affd34d..f5e0119b234 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -15,9 +15,6 @@ concurrency: group: ${{ github.workflow }} cancel-in-progress: true -env: - DEFAULT_PYTHON: "3.14.2" - jobs: upload: name: Upload @@ -29,10 +26,10 @@ jobs: with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" - name: Upload Translations env: diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 21acda6745a..781654bc5d8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -16,9 +16,6 @@ on: - "requirements.txt" - "script/gen_requirements_all.py" -env: - DEFAULT_PYTHON: "3.14.2" - permissions: {} concurrency: @@ -36,11 +33,11 @@ jobs: with: persist-credentials: false - - name: Set up Python ${{ env.DEFAULT_PYTHON }} + - name: Set up Python id: python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: - python-version: ${{ env.DEFAULT_PYTHON }} + python-version-file: ".python-version" check-latest: true - name: Create Python virtual environment