-
Notifications
You must be signed in to change notification settings - Fork 68
92 lines (85 loc) · 3.01 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: CI
on:
push:
branches: [main]
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
jobs:
ci:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
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
- id: pytest
name: Run tests with pytest
- id: protoc
name: Check protobuf files match
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
id: python
with:
python-version: '3.9'
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Restore PIP cache
uses: actions/cache@v3.3.1
with:
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: |
pip3 install -r requirements.txt -r requirements_test.txt
pip3 install -e .
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/flake8.json"
echo "::add-matcher::.github/workflows/matchers/pylint.json"
echo "::add-matcher::.github/workflows/matchers/isort.json"
echo "::add-matcher::.github/workflows/matchers/mypy.json"
echo "::add-matcher::.github/workflows/matchers/pytest.json"
- run: flake8 aioesphomeapi
if: ${{ matrix.id == 'flake8' }}
- run: pylint aioesphomeapi
if: ${{ matrix.id == 'pylint' }}
- run: black --check --diff --color aioesphomeapi tests
if: ${{ matrix.id == 'black' }}
- run: isort --check --diff aioesphomeapi tests
if: ${{ matrix.id == 'isort' }}
- run: mypy aioesphomeapi
if: ${{ matrix.id == 'mypy' }}
- run: pytest -vv --tb=native tests
if: ${{ matrix.id == '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
if: ${{ matrix.id == 'protoc' }}