From 546c978990d251b733ecd23952b193e8c69ec791 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 9 Sep 2023 08:00:01 +0200 Subject: [PATCH 1/2] Update black to 23.9.0 --- .pre-commit-config.yaml | 2 +- requirements_test_pre_commit.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77740d6279e72b..50829592f53c31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: args: - --fix - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.7.0 + rev: 23.9.0 hooks: - id: black args: diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 844d796e7af72a..9663d0a8fb7f4e 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -1,6 +1,6 @@ # Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit -black==23.7.0 +black==23.9.0 codespell==2.2.2 ruff==0.0.285 yamllint==1.32.0 From e06d72ed902e5a3979e1ac716cedaab7e03593a6 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 15 Aug 2023 09:10:49 +0200 Subject: [PATCH 2/2] Add black caching [ci] --- .github/workflows/ci.yaml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2e1df49549efa7..c20886f23425fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,6 +36,7 @@ env: CACHE_VERSION: 5 PIP_CACHE_VERSION: 4 MYPY_CACHE_VERSION: 4 + BLACK_CACHE_VERSION: 1 HA_SHORT_VERSION: "2023.10" DEFAULT_PYTHON: "3.11" ALL_PYTHON_VERSIONS: "['3.11']" @@ -55,6 +56,7 @@ env: POSTGRESQL_VERSIONS: "['postgres:12.14','postgres:15.2']" PRE_COMMIT_CACHE: ~/.cache/pre-commit PIP_CACHE: /tmp/pip-cache + BLACK_CACHE: /tmp/black-cache SQLALCHEMY_WARN_20: 1 PYTHONASYNCIODEBUG: 1 HASS_CI: 1 @@ -272,6 +274,13 @@ jobs: with: python-version: ${{ env.DEFAULT_PYTHON }} check-latest: true + - name: Generate partial black restore key + id: generate-black-key + run: | + black_version=$(cat requirements_test_pre_commit.txt | grep black | cut -d '=' -f 3) + echo "version=$black_version" >> $GITHUB_OUTPUT + echo "key=black-${{ env.BLACK_CACHE_VERSION }}-$black_version-${{ + env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT - name: Restore base Python virtual environment id: cache-venv uses: actions/cache/restore@v3.3.2 @@ -290,14 +299,28 @@ jobs: key: >- ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ needs.info.outputs.pre-commit_cache_key }} + - name: Restore black cache + uses: actions/cache@v3.3.2 + with: + path: ${{ env.BLACK_CACHE }} + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + steps.generate-black-key.outputs.key }} + restore-keys: | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-black-${{ + env.BLACK_CACHE_VERSION }}-${{ steps.generate-black-key.outputs.version }}-${{ + env.HA_SHORT_VERSION }}- - name: Run black (fully) - if: needs.info.outputs.test_full_suite == 'true' + env: + BLACK_CACHE_DIR: ${{ env.BLACK_CACHE }} run: | . venv/bin/activate pre-commit run --hook-stage manual black --all-files --show-diff-on-failure - name: Run black (partially) if: needs.info.outputs.test_full_suite == 'false' shell: bash + env: + BLACK_CACHE_DIR: ${{ env.BLACK_CACHE }} run: | . venv/bin/activate shopt -s globstar