esphome/.github/workflows/ci.yml

148 lines
4.6 KiB
YAML
Raw Normal View History

2020-07-14 14:34:44 +02:00
# THESE JOBS ARE COPIED IN release.yml and release-dev.yml
# PLEASE ALSO UPDATE THOSE FILES WHEN CHANGING LINES HERE
name: CI
on:
push:
branches: [dev, beta, release]
2020-07-14 14:34:44 +02:00
pull_request:
jobs:
ci-with-container:
name: ${{ matrix.name }}
2020-07-14 14:34:44 +02:00
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- id: clang-format
name: Run script/clang-format
- id: clang-tidy
name: Run script/clang-tidy 1/4
split: 1
- id: clang-tidy
name: Run script/clang-tidy 2/4
split: 2
- id: clang-tidy
name: Run script/clang-tidy 3/4
split: 3
- id: clang-tidy
name: Run script/clang-tidy 4/4
split: 4
2020-07-14 14:34:44 +02:00
# cpp lint job runs with esphome-lint docker image so that clang-format-*
# doesn't have to be installed
2021-07-15 21:51:52 +02:00
container: ghcr.io/esphome/esphome-lint:1.1
2020-07-14 14:34:44 +02:00
steps:
- uses: actions/checkout@v2
# Set up the pio project so that the cpp checks know how files are compiled
# (build flags, libraries etc)
- name: Set up platformio environment
run: pio init --ide atom
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/clang-tidy.json"
echo "::add-matcher::.github/workflows/matchers/gcc.json"
# Also run git-diff-index so that the step is marked as failed on formatting errors,
# since clang-format doesn't do anything but change files if -i is passed.
- name: Run clang-format
run: |
script/clang-format -i
git diff-index --quiet HEAD --
if: ${{ matrix.id == 'clang-format' }}
2020-07-14 14:34:44 +02:00
- name: Run clang-tidy
run: script/clang-tidy --all-headers --fix --split-num 4 --split-at ${{ matrix.split }}
if: ${{ matrix.id == 'clang-tidy' }}
- name: Suggested changes
2020-07-14 14:34:44 +02:00
run: script/ci-suggest-changes
if: always()
2020-07-14 14:34:44 +02:00
ci:
2020-07-14 14:34:44 +02:00
# Don't use the esphome-lint docker image because it may contain outdated requirements.
# This way, all dependencies are cached via the cache action.
name: ${{ matrix.name }}
2020-07-14 14:34:44 +02:00
runs-on: ubuntu-latest
strategy:
fail-fast: false
2020-07-14 14:34:44 +02:00
matrix:
include:
- id: ci-custom
name: Run script/ci-custom
- id: lint-python
name: Run script/lint-python
- id: test
file: tests/test1.yaml
name: Test tests/test1.yaml
- id: test
file: tests/test2.yaml
name: Test tests/test2.yaml
- id: test
file: tests/test3.yaml
name: Test tests/test3.yaml
- id: test
file: tests/test4.yaml
name: Test tests/test4.yaml
2021-07-22 03:24:01 +02:00
- id: test
file: tests/test5.yaml
name: Test tests/test5.yaml
- id: pytest
name: Run pytest
2020-07-14 14:34:44 +02:00
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
2020-07-14 14:34:44 +02:00
- name: Cache pip modules
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: esphome-pip-3.7-${{ hashFiles('setup.py') }}
restore-keys: |
esphome-pip-3.7-
2020-07-14 14:34:44 +02:00
# Use per test platformio cache because tests have different platform versions
- name: Cache ~/.platformio
uses: actions/cache@v1
with:
path: ~/.platformio
key: test-home-platformio-${{ matrix.file }}-${{ hashFiles('esphome/core/config.py') }}
2020-07-14 14:34:44 +02:00
restore-keys: |
test-home-platformio-${{ matrix.file }}-
if: ${{ matrix.id == 'test' }}
2020-07-14 14:34:44 +02:00
- name: Set up python environment
run: script/setup
2020-07-15 01:37:30 +02:00
2020-07-14 14:34:44 +02:00
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/ci-custom.json"
echo "::add-matcher::.github/workflows/matchers/lint-python.json"
2020-07-14 14:34:44 +02:00
echo "::add-matcher::.github/workflows/matchers/python.json"
echo "::add-matcher::.github/workflows/matchers/pytest.json"
echo "::add-matcher::.github/workflows/matchers/gcc.json"
2020-07-15 14:00:02 +02:00
- name: Lint Custom
2020-07-15 14:00:02 +02:00
run: |
script/ci-custom.py
script/build_codeowners.py --check
if: ${{ matrix.id == 'ci-custom' }}
- name: Lint Python
run: script/lint-python
if: ${{ matrix.id == 'lint-python' }}
- run: esphome compile ${{ matrix.file }}
if: ${{ matrix.id == 'test' }}
2020-07-15 14:00:02 +02:00
- name: Run pytest
run: |
pytest -vv --tb=native tests
if: ${{ matrix.id == 'pytest' }}