aioesphomeapi/.github/workflows/ci.yml

90 lines
3.1 KiB
YAML
Raw Normal View History

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:
permissions:
contents: read
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:
name: ${{ matrix.name }} py ${{ matrix.python-version }} on ${{ matrix.os }}
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:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- ubuntu-latest
2020-07-14 20:00:12 +02:00
steps:
- uses: actions/checkout@v4
2020-07-14 20:00:12 +02:00
- name: Set up Python
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: ${{ 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
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
2021-06-30 17:03:55 +02:00
- name: Restore PIP cache
uses: actions/cache@v3
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 }}-
- name: Set up Python environment
run: |
2021-06-30 17:03:55 +02:00
pip3 install -r requirements.txt -r requirements_test.txt
pip3 install -e .
2021-06-30 17:03:55 +02:00
- name: Register problem matchers
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"
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
name: Lint with flake8
if: ${{ matrix.python-version == '3.11' }}
2021-06-30 17:03:55 +02:00
- run: pylint aioesphomeapi
name: Lint with pylint
if: ${{ matrix.python-version == '3.11' }}
2021-07-29 16:09:16 +02:00
- run: black --check --diff --color aioesphomeapi tests
name: Check formatting with black
if: ${{ matrix.python-version == '3.11' }}
2021-07-29 16:09:16 +02:00
- run: isort --check --diff aioesphomeapi tests
name: Check import order with isort
if: ${{ matrix.python-version == '3.11' }}
2021-06-30 17:03:55 +02:00
- run: mypy aioesphomeapi
name: Check typing with mypy
if: ${{ matrix.python-version == '3.11' }}
2021-07-12 20:09:17 +02:00
- run: pytest -vv --tb=native tests
name: Run tests with pytest
- 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
name: Check protobuf files match
if: ${{ matrix.python-version == '3.11' }}