mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Run python tests on windows and macos (#6010)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										13
									
								
								.github/actions/restore-python/action.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/actions/restore-python/action.yml
									
									
									
									
										vendored
									
									
								
							| @@ -28,11 +28,20 @@ runs: | |||||||
|         # yamllint disable-line rule:line-length |         # yamllint disable-line rule:line-length | ||||||
|         key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ inputs.cache-key }} |         key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ inputs.cache-key }} | ||||||
|     - name: Create Python virtual environment |     - name: Create Python virtual environment | ||||||
|       if: steps.cache-venv.outputs.cache-hit != 'true' |       if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os != 'Windows' | ||||||
|       shell: bash |       shell: bash | ||||||
|       run: | |       run: | | ||||||
|         python -m venv venv |         python -m venv venv | ||||||
|         . venv/bin/activate |         source venv/bin/activate | ||||||
|  |         python --version | ||||||
|  |         pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt | ||||||
|  |         pip install -e . | ||||||
|  |     - name: Create Python virtual environment | ||||||
|  |       if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os == 'Windows' | ||||||
|  |       shell: bash | ||||||
|  |       run: | | ||||||
|  |         python -m venv venv | ||||||
|  |         ./venv/Scripts/activate | ||||||
|         python --version |         python --version | ||||||
|         pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt |         pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt | ||||||
|         pip install -e . |         pip install -e . | ||||||
|   | |||||||
							
								
								
									
										44
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -166,7 +166,35 @@ jobs: | |||||||
|  |  | ||||||
|   pytest: |   pytest: | ||||||
|     name: Run pytest |     name: Run pytest | ||||||
|     runs-on: ubuntu-latest |     strategy: | ||||||
|  |       fail-fast: false | ||||||
|  |       matrix: | ||||||
|  |         python-version: | ||||||
|  |           - "3.9" | ||||||
|  |           - "3.10" | ||||||
|  |           - "3.11" | ||||||
|  |           - "3.12" | ||||||
|  |         os: | ||||||
|  |           - ubuntu-latest | ||||||
|  |           - macOS-latest | ||||||
|  |           - windows-latest | ||||||
|  |         exclude: | ||||||
|  |           # Minimize CI resource usage | ||||||
|  |           # by only running the Python version | ||||||
|  |           # version used for docker images on Windows and macOS | ||||||
|  |           - python-version: "3.12" | ||||||
|  |             os: windows-latest | ||||||
|  |           - python-version: "3.10" | ||||||
|  |             os: windows-latest | ||||||
|  |           - python-version: "3.9" | ||||||
|  |             os: windows-latest | ||||||
|  |           - python-version: "3.12" | ||||||
|  |             os: macOS-latest | ||||||
|  |           - python-version: "3.10" | ||||||
|  |             os: macOS-latest | ||||||
|  |           - python-version: "3.9" | ||||||
|  |             os: macOS-latest | ||||||
|  |     runs-on: ${{ matrix.os }} | ||||||
|     needs: |     needs: | ||||||
|       - common |       - common | ||||||
|     steps: |     steps: | ||||||
| @@ -175,14 +203,24 @@ jobs: | |||||||
|       - name: Restore Python |       - name: Restore Python | ||||||
|         uses: ./.github/actions/restore-python |         uses: ./.github/actions/restore-python | ||||||
|         with: |         with: | ||||||
|           python-version: ${{ env.DEFAULT_PYTHON }} |           python-version: ${{ matrix.python-version }} | ||||||
|           cache-key: ${{ needs.common.outputs.cache-key }} |           cache-key: ${{ needs.common.outputs.cache-key }} | ||||||
|       - name: Register matcher |       - name: Register matcher | ||||||
|         run: echo "::add-matcher::.github/workflows/matchers/pytest.json" |         run: echo "::add-matcher::.github/workflows/matchers/pytest.json" | ||||||
|       - name: Run pytest |       - name: Run pytest | ||||||
|  |         if: matrix.os == 'windows-latest' | ||||||
|  |         run: | | ||||||
|  |           ./venv/Scripts/activate | ||||||
|  |           pytest -vv --cov-report=xml --tb=native tests | ||||||
|  |       - name: Run pytest | ||||||
|  |         if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest' | ||||||
|         run: | |         run: | | ||||||
|           . venv/bin/activate |           . venv/bin/activate | ||||||
|           pytest -vv --tb=native tests |           pytest -vv --cov-report=xml --tb=native tests | ||||||
|  |       - name: Upload coverage to Codecov | ||||||
|  |         uses: codecov/codecov-action@v3 | ||||||
|  |         with: | ||||||
|  |           token: ${{ secrets.CODECOV_TOKEN }} | ||||||
|  |  | ||||||
|   clang-format: |   clang-format: | ||||||
|     name: Check clang-format |     name: Check clang-format | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user