34
34
MYPY_CACHE_VERSION : 4
35
35
HA_SHORT_VERSION : 2023.6
36
36
DEFAULT_PYTHON : " 3.10"
37
- ALL_PYTHON_VERSIONS : " ['3.10', '3.11' ]"
37
+ ALL_PYTHON_VERSIONS : " ['3.10']"
38
38
# 10.3 is the oldest supported version
39
39
# - 10.3.32 is the version currently shipped with Synology (as of 17 Feb 2022)
40
40
# 10.6 is the current long-term-support
55
55
PYTHONASYNCIODEBUG : 1
56
56
HASS_CI : 1
57
57
58
- concurrency :
59
- group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
60
- cancel-in-progress : true
58
+ # concurrency:
59
+ # group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
60
+ # cancel-in-progress: true
61
61
62
62
jobs :
63
63
info :
@@ -666,6 +666,11 @@ jobs:
666
666
needs :
667
667
- info
668
668
- base
669
+ env :
670
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
671
+ CACHING : true
672
+ REMOTE : cdce8p
673
+ BRANCH : dev
669
674
steps :
670
675
- name : Check out code from GitHub
671
676
uses : actions/checkout@v3.5.2
@@ -675,10 +680,32 @@ jobs:
675
680
with :
676
681
python-version : ${{ env.DEFAULT_PYTHON }}
677
682
check-latest : true
683
+
684
+ - name : Fetch mypy version string (${{ env.BRANCH }})
685
+ id : fetch-version
686
+ run : |
687
+ echo "Checking mypy branch: ${{ env.BRANCH }}"
688
+ base=$(curl -sS \
689
+ https://raw.githubusercontent.com/${{ env.REMOTE }}/mypy/${{ env.BRANCH }}/mypy/version.py | \
690
+ grep -e ^__version__ | \
691
+ cut -d '=' -f2 | tr -d ' "')
692
+ sha=$(gh api \
693
+ -H "Accept: application/vnd.github+json" \
694
+ /repos/${{ env.REMOTE }}/mypy/git/ref/heads/${{ env.BRANCH }} | \
695
+ jq -r '.object.sha')
696
+ if [[ $base == *"+dev" ]]; then
697
+ version="v$base.$sha"
698
+ else
699
+ version="v$base"
700
+ fi
701
+ echo "version=$version" >> $GITHUB_OUTPUT
702
+ echo "name=(${{ env.BRANCH }} -- $version)" >> $GITHUB_OUTPUT
703
+ echo "Found: $version"
704
+
678
705
- name : Generate partial mypy restore key
679
706
id : generate-mypy-key
680
707
run : |
681
- mypy_version=$(cat requirements_test.txt | grep mypy | cut -d '=' -f 3)
708
+ mypy_version=${{ steps.fetch-version.outputs.version }}
682
709
echo "version=$mypy_version" >> $GITHUB_OUTPUT
683
710
echo "key=mypy-${{ env.MYPY_CACHE_VERSION }}-$mypy_version-${{
684
711
env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT
@@ -691,8 +718,105 @@ jobs:
691
718
key : >-
692
719
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
693
720
needs.info.outputs.python_cache_key }}
721
+
722
+ - name : Remove old mypy version
723
+ run : |
724
+ . venv/bin/activate
725
+ pip uninstall -y mypy
726
+ - name : Restore custom mypy version in venv ${{ steps.fetch-version.outputs.name }}
727
+ id : cache-venv-mypy
728
+ uses : actions/cache/restore@v3.3.1
729
+ with :
730
+ path : |
731
+ venv/lib/python3.10/site-packages/*__mypyc.cpython-310*.so
732
+ venv/lib/python3.10/site-packages/mypy*
733
+ venv/bin/mypy
734
+ key : >-
735
+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv_mypy-${{
736
+ env.CACHE_VERSION }}-${{ steps.fetch-version.outputs.version }}-compiled
737
+ restore-keys : |
738
+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv_mypy-${{
739
+ env.CACHE_VERSION }}-${{ steps.fetch-version.outputs.version }}-compiled-custom
740
+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv_mypy-${{
741
+ env.CACHE_VERSION }}-${{ steps.fetch-version.outputs.version }}
742
+ - name : Install compiled version if available
743
+ if : steps.cache-venv-mypy.outputs.cache-hit != 'true'
744
+ id : install-compiled
745
+ continue-on-error : true
746
+ run : |
747
+ . venv/bin/activate
748
+ tag=${{ steps.fetch-version.outputs.version }}
749
+ echo "$tag"
750
+ res=$(gh api \
751
+ -H "Accept: application/vnd.github+json" \
752
+ /repos/mypyc/mypy_mypyc-wheels/releases/tags/$tag)
753
+ py=$(echo ${{ env.DEFAULT_PYTHON }} | tr -d '.')
754
+ url=$(echo $res | jq -r \
755
+ --arg search_name "$py-manylinux" \
756
+ '.assets[] | select(.name | test($search_name)) .browser_download_url')
757
+ if [[ -n url ]]; then
758
+ echo "Found compiled version"
759
+ pip install -U $url
760
+ echo "status=done" >> $GITHUB_OUTPUT
761
+ echo "key-suffix=-compiled" >> $GITHUB_OUTPUT
762
+ exit 0
763
+ fi
764
+ - name : Install compiled version if available (custom)
765
+ if : |
766
+ steps.cache-venv-mypy.outputs.cache-hit != 'true'
767
+ && steps.install-compiled.outputs.status != 'done'
768
+ && endsWith( steps.cache-venv-mypy.outputs.cache-matched-key, '-compiled-custom' ) != true
769
+ id : install-compiled-custom
770
+ continue-on-error : true
771
+ run : |
772
+ . venv/bin/activate
773
+ tag=${{ steps.fetch-version.outputs.version }}
774
+ echo "$tag"
775
+ res=$(gh api \
776
+ -H "Accept: application/vnd.github+json" \
777
+ /repos/${{ env.REMOTE }}/mypy-wheels/releases/tags/$tag)
778
+ py=$(echo ${{ env.DEFAULT_PYTHON }} | tr -d '.')
779
+ url=$(echo $res | jq -r \
780
+ --arg search_name "$py-manylinux" \
781
+ '.assets[] | select(.name | test($search_name)) .browser_download_url')
782
+ if [[ -n url ]]; then
783
+ echo "Found compiled version"
784
+ pip install -U $url
785
+ echo "status=done" >> $GITHUB_OUTPUT
786
+ echo "key-suffix=-compiled-custom" >> $GITHUB_OUTPUT
787
+ exit 0
788
+ fi
789
+ - name : Install custom dependencies
790
+ if : |
791
+ steps.cache-venv-mypy.outputs.cache-matched-key == ''
792
+ && steps.install-compiled.outputs.status != 'done'
793
+ && steps.install-compiled-custom.outputs.status != 'done'
794
+ run : |
795
+ . venv/bin/activate
796
+ python --version
797
+ pip install -U git+https://github.com/${{ env.REMOTE }}/mypy.git@${{ env.BRANCH }}
798
+ - name : Save mypy version in venv
799
+ if : |
800
+ steps.cache-venv-mypy.outputs.cache-hit != 'true'
801
+ && (
802
+ steps.cache-venv-mypy.outputs.cache-matched-key == ''
803
+ || steps.install-compiled.outputs.status == 'done'
804
+ || steps.install-compiled-custom.outputs.status == 'done'
805
+ )
806
+ uses : actions/cache/save@v3.3.1
807
+ with :
808
+ path : |
809
+ venv/lib/python3.10/site-packages/*__mypyc.cpython-310*.so
810
+ venv/lib/python3.10/site-packages/mypy*
811
+ venv/bin/mypy
812
+ key : >-
813
+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv_mypy-${{
814
+ env.CACHE_VERSION }}-${{ steps.fetch-version.outputs.version }}${{
815
+ steps.install-compiled.outputs.key-suffix || steps.install-compiled-custom.outputs.key-suffix }}
816
+
694
817
- name : Restore mypy cache
695
- uses : actions/cache@v3.3.1
818
+ if : env.CACHING != 'false'
819
+ uses : actions/cache/restore@v3.3.1
696
820
with :
697
821
path : .mypy_cache
698
822
key : >-
@@ -710,6 +834,9 @@ jobs:
710
834
run : |
711
835
. venv/bin/activate
712
836
python --version
837
+ git branch --show-current
838
+ # For issues with serialize, add --cache-dir=/dev/null
839
+ # To install types: --install-types --non-interactive
713
840
mypy homeassistant pylint
714
841
- name : Run mypy (partially)
715
842
if : needs.info.outputs.test_full_suite == 'false'
@@ -718,10 +845,19 @@ jobs:
718
845
. venv/bin/activate
719
846
python --version
720
847
mypy homeassistant/components/${{ needs.info.outputs.integrations_glob }}
848
+ - name : Save mypy cache
849
+ if : success() || failure()
850
+ uses : actions/cache/save@v3.3.1
851
+ with :
852
+ path : .mypy_cache
853
+ key : >-
854
+ ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
855
+ steps.generate-mypy-key.outputs.key }}
721
856
722
857
pytest :
723
858
runs-on : ubuntu-22.04
724
859
if : |
860
+ false &&
725
861
(github.event_name != 'push' || github.event.repository.full_name == 'home-assistant/core')
726
862
&& github.event.inputs.lint-only != 'true'
727
863
&& github.event.inputs.pylint-only != 'true'
@@ -847,6 +983,7 @@ jobs:
847
983
MYSQL_ROOT_PASSWORD : password
848
984
options : --health-cmd="mysqladmin ping -uroot -ppassword" --health-interval=5s --health-timeout=2s --health-retries=3
849
985
if : |
986
+ false &&
850
987
(github.event_name != 'push' || github.event.repository.full_name == 'home-assistant/core')
851
988
&& github.event.inputs.lint-only != 'true'
852
989
&& github.event.inputs.pylint-only != 'true'
@@ -955,6 +1092,7 @@ jobs:
955
1092
POSTGRES_PASSWORD : password
956
1093
options : --health-cmd="pg_isready -hlocalhost -Upostgres" --health-interval=5s --health-timeout=2s --health-retries=3
957
1094
if : |
1095
+ false &&
958
1096
(github.event_name != 'push' || github.event.repository.full_name == 'home-assistant/core')
959
1097
&& github.event.inputs.lint-only != 'true'
960
1098
&& github.event.inputs.pylint-only != 'true'
0 commit comments