2020-07-14 20:00:12 +02:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-06-30 18:08:56 +02:00
|
|
|
branches: [main]
|
2020-07-14 20:00:12 +02:00
|
|
|
pull_request:
|
|
|
|
|
2021-10-23 21:57:46 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2023-04-16 22:45:43 +02:00
|
|
|
concurrency:
|
|
|
|
# yamllint disable-line rule:line-length
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-07-14 20:00:12 +02:00
|
|
|
jobs:
|
2021-06-30 17:03:55 +02:00
|
|
|
ci:
|
2023-10-12 20:12:39 +02:00
|
|
|
name: ${{ matrix.name }} py ${{ matrix.python-version }} on ${{ matrix.os }} (${{ matrix.extension }})
|
2023-10-12 00:52:19 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
2021-06-30 17:03:55 +02:00
|
|
|
strategy:
|
2021-07-26 01:31:04 +02:00
|
|
|
fail-fast: false
|
2021-06-30 17:03:55 +02:00
|
|
|
matrix:
|
2023-10-12 00:52:19 +02:00
|
|
|
python-version:
|
|
|
|
- "3.9"
|
|
|
|
- "3.10"
|
|
|
|
- "3.11"
|
2023-10-20 02:00:36 +02:00
|
|
|
- "3.12"
|
2023-10-12 00:52:19 +02:00
|
|
|
os:
|
2023-10-20 02:00:36 +02:00
|
|
|
- ubuntu-latest
|
2024-08-29 21:58:03 +02:00
|
|
|
- windows-latest
|
|
|
|
- macos-latest
|
2023-10-12 20:12:39 +02:00
|
|
|
extension:
|
|
|
|
- "skip_cython"
|
2023-10-20 02:00:36 +02:00
|
|
|
- "use_cython"
|
2024-08-29 21:58:03 +02:00
|
|
|
exclude:
|
|
|
|
- python-version: "3.9"
|
|
|
|
os: windows-latest
|
|
|
|
- python-version: "3.10"
|
|
|
|
os: windows-latest
|
|
|
|
- python-version: "3.11"
|
|
|
|
os: windows-latest
|
|
|
|
- python-version: "3.9"
|
|
|
|
os: macos-latest
|
|
|
|
- python-version: "3.10"
|
|
|
|
os: macos-latest
|
|
|
|
- python-version: "3.11"
|
|
|
|
os: macos-latest
|
2024-08-29 22:04:54 +02:00
|
|
|
- extension: "use_cython"
|
|
|
|
os: windows-latest
|
|
|
|
- extension: "use_cython"
|
|
|
|
os: macos-latest
|
2020-07-14 20:00:12 +02:00
|
|
|
steps:
|
2023-09-25 00:04:02 +02:00
|
|
|
- uses: actions/checkout@v4
|
2020-07-14 20:00:12 +02:00
|
|
|
- name: Set up Python
|
2023-12-10 03:55:55 +01:00
|
|
|
uses: actions/setup-python@v5
|
2021-06-30 17:03:55 +02:00
|
|
|
id: python
|
2020-07-14 20:00:12 +02:00
|
|
|
with:
|
2023-10-12 00:52:19 +02:00
|
|
|
python-version: ${{ matrix.python-version }}
|
2021-07-26 01:31:04 +02:00
|
|
|
|
2021-06-30 17:03:55 +02:00
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
2024-08-29 22:01:45 +02:00
|
|
|
shell: bash
|
2021-06-18 17:57:02 +02:00
|
|
|
run: |
|
2022-11-22 19:30:14 +01:00
|
|
|
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
2021-06-30 17:03:55 +02:00
|
|
|
- name: Restore PIP cache
|
2024-02-02 12:23:39 +01:00
|
|
|
uses: actions/cache@v4
|
2021-06-18 17:57:02 +02:00
|
|
|
with:
|
2021-06-30 17:03:55 +02:00
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
2023-10-12 20:12:39 +02:00
|
|
|
key: pip-${{ steps.python.outputs.python-version }}-${{ matrix.extension }}-${{ hashFiles('requirements.txt', 'requirements_test.txt') }}
|
2021-06-30 17:03:55 +02:00
|
|
|
restore-keys: |
|
2023-10-12 20:12:39 +02:00
|
|
|
pip-${{ steps.python.outputs.python-version }}-${{ matrix.extension }}-
|
|
|
|
- name: Set up Python environment (no cython)
|
|
|
|
if: ${{ matrix.extension == 'skip_cython' }}
|
|
|
|
env:
|
|
|
|
SKIP_CYTHON: 1
|
2024-08-29 22:01:45 +02:00
|
|
|
shell: bash
|
2023-10-12 20:12:39 +02:00
|
|
|
run: |
|
|
|
|
pip3 install -r requirements.txt -r requirements_test.txt
|
|
|
|
pip3 install -e .
|
|
|
|
- name: Set up Python environment (cython)
|
|
|
|
if: ${{ matrix.extension == 'use_cython' }}
|
|
|
|
env:
|
|
|
|
REQUIRE_CYTHON: 1
|
2024-08-29 22:01:45 +02:00
|
|
|
shell: bash
|
2021-06-18 17:57:02 +02:00
|
|
|
run: |
|
2021-06-30 17:03:55 +02:00
|
|
|
pip3 install -r requirements.txt -r requirements_test.txt
|
2021-06-18 17:57:02 +02:00
|
|
|
pip3 install -e .
|
2021-06-30 17:03:55 +02:00
|
|
|
- name: Register problem matchers
|
2024-08-29 22:01:45 +02:00
|
|
|
shell: bash
|
2021-06-18 17:57:02 +02:00
|
|
|
run: |
|
|
|
|
echo "::add-matcher::.github/workflows/matchers/flake8.json"
|
2021-06-30 17:03:55 +02:00
|
|
|
echo "::add-matcher::.github/workflows/matchers/pylint.json"
|
2021-06-18 17:57:02 +02:00
|
|
|
echo "::add-matcher::.github/workflows/matchers/mypy.json"
|
2021-07-12 20:09:17 +02:00
|
|
|
echo "::add-matcher::.github/workflows/matchers/pytest.json"
|
2021-07-26 01:31:04 +02:00
|
|
|
|
2021-06-30 17:03:55 +02:00
|
|
|
- run: flake8 aioesphomeapi
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Lint with flake8
|
2024-08-29 22:01:45 +02:00
|
|
|
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
|
2021-06-30 17:03:55 +02:00
|
|
|
- run: pylint aioesphomeapi
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Lint with pylint
|
2024-08-29 22:01:45 +02:00
|
|
|
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
|
2021-07-29 16:09:16 +02:00
|
|
|
- run: black --check --diff --color aioesphomeapi tests
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Check formatting with black
|
2024-08-29 22:01:45 +02:00
|
|
|
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
|
2021-06-30 17:03:55 +02:00
|
|
|
- run: mypy aioesphomeapi
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Check typing with mypy
|
2024-08-29 22:01:45 +02:00
|
|
|
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
|
2023-10-16 00:24:27 +02:00
|
|
|
- run: pytest -vv --cov=aioesphomeapi --cov-report=xml --tb=native tests
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Run tests with pytest
|
2023-10-16 00:17:15 +02:00
|
|
|
- name: Upload coverage to Codecov
|
|
|
|
uses: codecov/codecov-action@v3
|
2023-10-20 02:00:36 +02:00
|
|
|
- run: |
|
2021-10-21 16:53:32 +02:00
|
|
|
docker run \
|
|
|
|
-v "$PWD":/aioesphomeapi \
|
2024-03-06 19:53:35 +01:00
|
|
|
-u "$(id -u):$(id -g)" \
|
2021-10-21 16:53:32 +02:00
|
|
|
ghcr.io/esphome/aioesphomeapi-proto-builder:latest
|
|
|
|
if ! git diff --quiet; then
|
|
|
|
echo "You have altered the generated proto files but they do not match what is expected."
|
|
|
|
echo "Please run the following to update the generated files:"
|
|
|
|
echo 'docker run -v "$PWD":/aioesphomeapi ghcr.io/esphome/aioesphomeapi-proto-builder:latest'
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-10-12 00:52:19 +02:00
|
|
|
name: Check protobuf files match
|
2024-08-29 22:01:45 +02:00
|
|
|
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' && matrix.os == 'ubuntu-latest' }}
|