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
|
|
|
|
|
2020-07-14 20:00:12 +02:00
|
|
|
jobs:
|
2021-06-30 17:03:55 +02:00
|
|
|
ci:
|
|
|
|
name: ${{ matrix.name }}
|
2020-07-14 20:00:12 +02:00
|
|
|
runs-on: ubuntu-latest
|
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:
|
|
|
|
include:
|
|
|
|
- id: flake8
|
|
|
|
name: Lint with flake8
|
|
|
|
- id: pylint
|
|
|
|
name: Lint with pylint
|
|
|
|
- id: black
|
|
|
|
name: Check formatting with black
|
|
|
|
- id: isort
|
|
|
|
name: Check import order with isort
|
|
|
|
- id: mypy
|
|
|
|
name: Check typing with mypy
|
2021-07-12 20:09:17 +02:00
|
|
|
- id: pytest
|
|
|
|
name: Run tests with pytest
|
2021-10-21 16:53:32 +02:00
|
|
|
- id: protoc
|
|
|
|
name: Check protobuf files match
|
2020-07-14 20:00:12 +02:00
|
|
|
steps:
|
2022-03-09 13:26:30 +01:00
|
|
|
- uses: actions/checkout@v3
|
2020-07-14 20:00:12 +02:00
|
|
|
- name: Set up Python
|
2022-06-13 15:00:22 +02:00
|
|
|
uses: actions/setup-python@v4
|
2021-06-30 17:03:55 +02:00
|
|
|
id: python
|
2020-07-14 20:00:12 +02:00
|
|
|
with:
|
|
|
|
python-version: '3.7'
|
2021-07-26 01:31:04 +02:00
|
|
|
|
2021-06-30 17:03:55 +02:00
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
2021-06-18 17:57:02 +02:00
|
|
|
run: |
|
2021-06-30 17:03:55 +02:00
|
|
|
echo "::set-output name=dir::$(pip cache dir)"
|
|
|
|
- name: Restore PIP cache
|
2022-09-06 04:04:01 +02:00
|
|
|
uses: actions/cache@v3.0.8
|
2021-06-18 17:57:02 +02:00
|
|
|
with:
|
2021-06-30 17:03:55 +02:00
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
|
|
|
key: pip-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements_test.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
pip-${{ steps.python.outputs.python-version }}-
|
2021-06-18 17:57:02 +02:00
|
|
|
- name: Set up Python environment
|
|
|
|
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
|
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/isort.json"
|
|
|
|
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
|
|
|
|
if: ${{ matrix.id == 'flake8' }}
|
|
|
|
- run: pylint aioesphomeapi
|
|
|
|
if: ${{ matrix.id == 'pylint' }}
|
2021-07-29 16:09:16 +02:00
|
|
|
- run: black --check --diff --color aioesphomeapi tests
|
2021-06-30 17:03:55 +02:00
|
|
|
if: ${{ matrix.id == 'black' }}
|
2021-07-29 16:09:16 +02:00
|
|
|
- run: isort --check --diff aioesphomeapi tests
|
2021-06-30 17:03:55 +02:00
|
|
|
if: ${{ matrix.id == 'isort' }}
|
|
|
|
- run: mypy aioesphomeapi
|
|
|
|
if: ${{ matrix.id == 'mypy' }}
|
2021-07-12 20:09:17 +02:00
|
|
|
- run: pytest -vv --tb=native tests
|
|
|
|
if: ${{ matrix.id == 'pytest' }}
|
2021-10-21 16:53:32 +02:00
|
|
|
- run: |
|
|
|
|
docker run \
|
|
|
|
-v "$PWD":/aioesphomeapi \
|
|
|
|
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
|
|
|
|
if: ${{ matrix.id == 'protoc' }}
|