From f9c55d7ca45241de75394748c319c5ddb6ac77ae Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:13:39 +0000 Subject: [PATCH 01/12] (mock) Mark mariadb as success to skip on partial builds --- .github/workflows/ci.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dc0fa13a7303a3..2693a7a30dacf2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -920,7 +920,6 @@ jobs: && github.event.inputs.lint-only != 'true' && github.event.inputs.pylint-only != 'true' && github.event.inputs.mypy-only != 'true' - && needs.info.outputs.test_full_suite == 'true' needs: - info - base @@ -939,6 +938,7 @@ jobs: Run tests Python ${{ matrix.python-version }} (mariadb) steps: - name: Install additional OS dependencies + if: needs.info.outputs.test_full_suite == 'false' run: | sudo apt-get update sudo apt-get -y install \ @@ -946,14 +946,17 @@ jobs: ffmpeg \ libmariadb-dev-compat - name: Check out code from GitHub + if: needs.info.outputs.test_full_suite == 'false' uses: actions/checkout@v3.3.0 - name: Set up Python ${{ matrix.python-version }} + if: needs.info.outputs.test_full_suite == 'false' id: python uses: actions/setup-python@v4.5.0 with: python-version: ${{ matrix.python-version }} check-latest: true - name: Restore full Python ${{ matrix.python-version }} virtual environment + if: needs.info.outputs.test_full_suite == 'false' id: cache-venv uses: actions/cache/restore@v3.2.4 with: @@ -962,9 +965,11 @@ jobs: key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ needs.info.outputs.python_cache_key }} - name: Register Python problem matcher + if: needs.info.outputs.test_full_suite == 'false' run: | echo "::add-matcher::.github/workflows/matchers/python.json" - name: Install Pytest Annotation plugin + if: needs.info.outputs.test_full_suite == 'false' run: | . venv/bin/activate # Ideally this should be part of our dependencies @@ -972,13 +977,16 @@ jobs: # on a non-GitHub environment. pip install pytest-github-actions-annotate-failures==0.1.3 - name: Register pytest slow test problem matcher + if: needs.info.outputs.test_full_suite == 'false' run: | echo "::add-matcher::.github/workflows/matchers/pytest-slow.json" - name: Install SQL Python libraries + if: needs.info.outputs.test_full_suite == 'false' run: | . venv/bin/activate pip install mysqlclient sqlalchemy_utils - name: Run pytest (partially) + if: needs.info.outputs.test_full_suite == 'false' timeout-minutes: 15 shell: bash run: | @@ -998,11 +1006,13 @@ jobs: --dburl=mysql://root:password@127.0.0.1/homeassistant-test \ tests/components/recorder - name: Upload coverage artifact + if: needs.info.outputs.test_full_suite == 'false' uses: actions/upload-artifact@v3.1.2 with: name: coverage-${{ matrix.python-version }}-mariadb path: coverage.xml - name: Check dirty + if: needs.info.outputs.test_full_suite == 'false' run: | ./script/check_dirty From ae540bb7cd8ca583081c4d88876af146522178ef Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:45:22 +0000 Subject: [PATCH 02/12] mariadb_groups --- .github/workflows/ci.yaml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2693a7a30dacf2..35f123e8b8e68a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,10 +53,11 @@ jobs: core: ${{ steps.core.outputs.changes }} integrations_glob: ${{ steps.info.outputs.integrations_glob }} integrations: ${{ steps.integrations.outputs.changes }} + mariadb_groups: ${{ steps.info.outputs.mariadb_groups }} pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }} python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }} - requirements: ${{ steps.core.outputs.requirements }} python_versions: ${{ steps.info.outputs.python_versions }} + requirements: ${{ steps.core.outputs.requirements }} test_full_suite: ${{ steps.info.outputs.test_full_suite }} test_group_count: ${{ steps.info.outputs.test_group_count }} test_groups: ${{ steps.info.outputs.test_groups }} @@ -103,6 +104,7 @@ jobs: run: | # Defaults integrations_glob="" + mariadb_groups="[]" test_full_suite="true" test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 @@ -154,6 +156,8 @@ jobs: fi # Output & sent to GitHub Actions + echo "mariadb_groups: ${mariadb_groups}" + echo "mariadb_groups=${mariadb_groups}" >> $GITHUB_OUTPUT echo "python_versions: ${ALL_PYTHON_VERSIONS}" echo "python_versions=${ALL_PYTHON_VERSIONS}" >> $GITHUB_OUTPUT echo "test_full_suite: ${test_full_suite}" @@ -920,7 +924,6 @@ jobs: && github.event.inputs.lint-only != 'true' && github.event.inputs.pylint-only != 'true' && github.event.inputs.mypy-only != 'true' - needs: - info - base - gen-requirements-all @@ -934,11 +937,11 @@ jobs: fail-fast: false matrix: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} + mariadb-group: ${{ fromJson(needs.info.outputs.mariadb_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (mariadb) + Run tests Python ${{ matrix.python-version }} (${{ matrix.mariadb-group }}) steps: - name: Install additional OS dependencies - if: needs.info.outputs.test_full_suite == 'false' run: | sudo apt-get update sudo apt-get -y install \ @@ -946,17 +949,14 @@ jobs: ffmpeg \ libmariadb-dev-compat - name: Check out code from GitHub - if: needs.info.outputs.test_full_suite == 'false' uses: actions/checkout@v3.3.0 - name: Set up Python ${{ matrix.python-version }} - if: needs.info.outputs.test_full_suite == 'false' id: python uses: actions/setup-python@v4.5.0 with: python-version: ${{ matrix.python-version }} check-latest: true - name: Restore full Python ${{ matrix.python-version }} virtual environment - if: needs.info.outputs.test_full_suite == 'false' id: cache-venv uses: actions/cache/restore@v3.2.4 with: @@ -965,11 +965,9 @@ jobs: key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ needs.info.outputs.python_cache_key }} - name: Register Python problem matcher - if: needs.info.outputs.test_full_suite == 'false' run: | echo "::add-matcher::.github/workflows/matchers/python.json" - name: Install Pytest Annotation plugin - if: needs.info.outputs.test_full_suite == 'false' run: | . venv/bin/activate # Ideally this should be part of our dependencies @@ -977,16 +975,13 @@ jobs: # on a non-GitHub environment. pip install pytest-github-actions-annotate-failures==0.1.3 - name: Register pytest slow test problem matcher - if: needs.info.outputs.test_full_suite == 'false' run: | echo "::add-matcher::.github/workflows/matchers/pytest-slow.json" - name: Install SQL Python libraries - if: needs.info.outputs.test_full_suite == 'false' run: | . venv/bin/activate pip install mysqlclient sqlalchemy_utils - name: Run pytest (partially) - if: needs.info.outputs.test_full_suite == 'false' timeout-minutes: 15 shell: bash run: | @@ -1006,13 +1001,11 @@ jobs: --dburl=mysql://root:password@127.0.0.1/homeassistant-test \ tests/components/recorder - name: Upload coverage artifact - if: needs.info.outputs.test_full_suite == 'false' uses: actions/upload-artifact@v3.1.2 with: name: coverage-${{ matrix.python-version }}-mariadb path: coverage.xml - name: Check dirty - if: needs.info.outputs.test_full_suite == 'false' run: | ./script/check_dirty From a5e9422258432d0d04d5ec5d4b4f53f69e074778 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:02:28 +0000 Subject: [PATCH 03/12] Adjust --- .github/workflows/ci.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35f123e8b8e68a..1db5c031db60b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,11 +53,11 @@ jobs: core: ${{ steps.core.outputs.changes }} integrations_glob: ${{ steps.info.outputs.integrations_glob }} integrations: ${{ steps.integrations.outputs.changes }} - mariadb_groups: ${{ steps.info.outputs.mariadb_groups }} pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }} python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }} - python_versions: ${{ steps.info.outputs.python_versions }} requirements: ${{ steps.core.outputs.requirements }} + mariadb_groups: ${{ steps.info.outputs.mariadb_groups }} + python_versions: ${{ steps.info.outputs.python_versions }} test_full_suite: ${{ steps.info.outputs.test_full_suite }} test_group_count: ${{ steps.info.outputs.test_group_count }} test_groups: ${{ steps.info.outputs.test_groups }} @@ -937,9 +937,8 @@ jobs: fail-fast: false matrix: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} - mariadb-group: ${{ fromJson(needs.info.outputs.mariadb_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (${{ matrix.mariadb-group }}) + Run tests Python ${{ matrix.python-version }} (mariadb) steps: - name: Install additional OS dependencies run: | From 31247da9e23adde98c8393aeb2bb54bbca380e92 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:03:15 +0000 Subject: [PATCH 04/12] Fix yaml --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1db5c031db60b8..0211d6a75720ef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -924,6 +924,7 @@ jobs: && github.event.inputs.lint-only != 'true' && github.event.inputs.pylint-only != 'true' && github.event.inputs.mypy-only != 'true' + needs: - info - base - gen-requirements-all From 57694655b72e4e38509279b4066a68753a48d181 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:04:04 +0000 Subject: [PATCH 05/12] mariadb-group --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0211d6a75720ef..b76852448fafea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -938,8 +938,9 @@ jobs: fail-fast: false matrix: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} + mariadb-group: ${{ fromJson(needs.info.outputs.mariadb_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (mariadb) + Run tests Python ${{ matrix.python-version }} (${{ matrix.mariadb-group }}) steps: - name: Install additional OS dependencies run: | From 3affc1f38bf1b6229a36d977da3f8aa7952dfd18 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:16:48 +0000 Subject: [PATCH 06/12] Add postgresql-group --- .github/workflows/ci.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b76852448fafea..8763780dad83c3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,6 +57,7 @@ jobs: python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }} requirements: ${{ steps.core.outputs.requirements }} mariadb_groups: ${{ steps.info.outputs.mariadb_groups }} + postgresql_groups: ${{ steps.info.outputs.postgresql_groups }} python_versions: ${{ steps.info.outputs.python_versions }} test_full_suite: ${{ steps.info.outputs.test_full_suite }} test_group_count: ${{ steps.info.outputs.test_group_count }} @@ -105,6 +106,7 @@ jobs: # Defaults integrations_glob="" mariadb_groups="[]" + postgresql_groups="[]" test_full_suite="true" test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 @@ -158,6 +160,8 @@ jobs: # Output & sent to GitHub Actions echo "mariadb_groups: ${mariadb_groups}" 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 "test_full_suite: ${test_full_suite}" @@ -1023,7 +1027,6 @@ jobs: if: | (github.event_name != 'push' || github.event.repository.full_name == 'home-assistant/core') && github.event.inputs.lint-only != 'true' - && needs.info.outputs.test_full_suite == 'true' needs: - info - base @@ -1037,8 +1040,9 @@ jobs: fail-fast: false matrix: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} + postgresql-group: ${{ fromJson(needs.info.outputs.postgresql_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (postgresql) + Run tests Python ${{ matrix.python-version }} (${{ matrix.postgresql-group }}) steps: - name: Install additional OS dependencies run: | From 2009ecd245b4593b189443bd3ea41342e7d3a0f1 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:19:16 +0000 Subject: [PATCH 07/12] Align --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8763780dad83c3..f3b0b84596f172 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1027,6 +1027,8 @@ jobs: if: | (github.event_name != 'push' || github.event.repository.full_name == 'home-assistant/core') && github.event.inputs.lint-only != 'true' + && github.event.inputs.pylint-only != 'true' + && github.event.inputs.mypy-only != 'true' needs: - info - base @@ -1123,6 +1125,7 @@ jobs: needs: - info - pytest + - pytest-mariadb - pytest-postgres steps: - name: Check out code from GitHub From 605012f64e55a7f4e6b0c2f209937e88e5c9dadd Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:26:37 +0000 Subject: [PATCH 08/12] Include mariadb-postgresql --- .github/workflows/ci.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f3b0b84596f172..497e31f996efb4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -105,8 +105,8 @@ jobs: run: | # Defaults integrations_glob="" - mariadb_groups="[]" - postgresql_groups="[]" + mariadb_groups="['mariadb']" + postgresql_groups="['postgresql']" test_full_suite="true" test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 @@ -140,6 +140,8 @@ jobs: tests_glob=$(echo "${tests}" | jq -cSr '. | join(",")') [[ "${tests_glob}" == *","* ]] && tests_glob="{${tests_glob}}" + mariadb_groups="[]" + postgresql_groups="[]" test_full_suite="false" fi @@ -152,6 +154,8 @@ jobs: || [[ "${{ github.event.inputs.full }}" == "true" ]] \ || [[ "${{ contains(github.event.pull_request.labels.*.name, 'ci-full-run') }}" == "true" ]]; then + mariadb_groups="['mariadb']" + postgresql_groups="['postgresql']" test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 test_full_suite="true" From e07d723187568af432c80fed8f43b4781ebbe48a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:36:00 +0100 Subject: [PATCH 09/12] Update ci.yaml --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 497e31f996efb4..ca50ad5ab4752d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,6 +34,8 @@ env: HA_SHORT_VERSION: 2023.3 DEFAULT_PYTHON: "3.10" ALL_PYTHON_VERSIONS: "['3.10']" + MARIADB_VERSIONS: "['mariadb:10.9.3']" + POSTGRESQL_VERSIONS: "['postgres:15.0']" PRE_COMMIT_CACHE: ~/.cache/pre-commit PIP_CACHE: /tmp/pip-cache SQLALCHEMY_WARN_20: 1 @@ -105,8 +107,8 @@ jobs: run: | # Defaults integrations_glob="" - mariadb_groups="['mariadb']" - postgresql_groups="['postgresql']" + mariadb_groups=${MARIADB_VERSIONS} + postgresql_groups=${POSTGRESQL_VERSIONS} test_full_suite="true" test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 @@ -154,8 +156,8 @@ jobs: || [[ "${{ github.event.inputs.full }}" == "true" ]] \ || [[ "${{ contains(github.event.pull_request.labels.*.name, 'ci-full-run') }}" == "true" ]]; then - mariadb_groups="['mariadb']" - postgresql_groups="['postgresql']" + mariadb_groups=${MARIADB_VERSIONS} + postgresql_groups=${POSTGRESQL_VERSIONS} test_groups="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" test_group_count=10 test_full_suite="true" From fed53cc4ba079f2cf685385569c7474a001e2888 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:50:21 +0100 Subject: [PATCH 10/12] Update ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ca50ad5ab4752d..6cffb4d979af45 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -923,7 +923,7 @@ jobs: runs-on: ubuntu-20.04 services: mariadb: - image: mariadb:10.9.3 + image: ${{ matrix.mariadb-group }} ports: - 3306:3306 env: @@ -1024,7 +1024,7 @@ jobs: runs-on: ubuntu-20.04 services: postgres: - image: postgres:15.0 + image: ${{ matrix.postgresql-group }} ports: - 5432:5432 env: From 78c5dae03ec3b8152112e0dedd9d4b8e7d38c2ea Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 7 Feb 2023 20:51:02 +0100 Subject: [PATCH 11/12] Rename jobs --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6cffb4d979af45..c66d85427722b4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -950,7 +950,7 @@ jobs: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} mariadb-group: ${{ fromJson(needs.info.outputs.mariadb_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (${{ matrix.mariadb-group }}) + Run recorder tests Python ${{ matrix.python-version }} (${{ matrix.mariadb-group }}) steps: - name: Install additional OS dependencies run: | @@ -1050,7 +1050,7 @@ jobs: python-version: ${{ fromJson(needs.info.outputs.python_versions) }} postgresql-group: ${{ fromJson(needs.info.outputs.postgresql_groups) }} name: >- - Run tests Python ${{ matrix.python-version }} (${{ matrix.postgresql-group }}) + Run recorder tests Python ${{ matrix.python-version }} (${{ matrix.postgresql-group }}) steps: - name: Install additional OS dependencies run: | From 86b3eae26282fb7c67ac40d5eb60029346bb4b7c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:38:55 +0000 Subject: [PATCH 12/12] Remove recorder tests from coverage needs --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c66d85427722b4..c25b7c8953295a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1131,8 +1131,6 @@ jobs: needs: - info - pytest - - pytest-mariadb - - pytest-postgres steps: - name: Check out code from GitHub uses: actions/checkout@v3.3.0