mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add GitHub Actions for CI (#37419)
* Add GitHub Actions for CI * Add base/full to step descriptions
This commit is contained in:
parent
5ecb3f9be2
commit
573134fcb4
751
.github/workflows/ci.yaml
vendored
Normal file
751
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,751 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
# yamllint disable-line rule:truthy
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- rc
|
||||||
|
- master
|
||||||
|
pull_request: ~
|
||||||
|
|
||||||
|
env:
|
||||||
|
DEFAULT_PYTHON: 3.7
|
||||||
|
PRE_COMMIT_HOME: ~/.cache/pre-commit
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Separate job to pre-populate the base dependency cache
|
||||||
|
# This prevent upcoming jobs to do the same individually
|
||||||
|
prepare-base:
|
||||||
|
name: Prepare base dependencies
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
id: python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements_test.txt') }}-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
|
||||||
|
${{ runner.os }}-base-venv-
|
||||||
|
- name: Create Python virtual environment
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
python -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install -U pip setuptools
|
||||||
|
pip install -r requirements.txt -r requirements_test.txt -c homeassistant/package_constraints.txt
|
||||||
|
# Uninstalling typing as a workaround. Eventually we should make sure
|
||||||
|
# all our dependencies drop typing.
|
||||||
|
# Find offending deps with `pipdeptree -r -p typing`
|
||||||
|
pip uninstall -y typing
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pre-commit-
|
||||||
|
- name: Install pre-commit dependencies
|
||||||
|
if: steps.cache-precommit.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit install-hooks
|
||||||
|
|
||||||
|
lint-bandit:
|
||||||
|
name: Check bandit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run bandit
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual bandit --all-files
|
||||||
|
|
||||||
|
lint-black:
|
||||||
|
name: Check black
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run black
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual black --all-files
|
||||||
|
|
||||||
|
lint-codespell:
|
||||||
|
name: Check codespell
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run codespell
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --show-diff-on-failure --color=always --hook-stage manual codespell --all-files
|
||||||
|
|
||||||
|
lint-dockerfile:
|
||||||
|
name: Check Dockerfile
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Check Dockerfile
|
||||||
|
uses: docker://hadolint/hadolint:v1.18.0
|
||||||
|
with:
|
||||||
|
args: hadolint Dockerfile
|
||||||
|
- name: Check Dockerfile.dev
|
||||||
|
uses: docker://hadolint/hadolint:v1.18.0
|
||||||
|
with:
|
||||||
|
args: hadolint Dockerfile.dev
|
||||||
|
|
||||||
|
lint-executable-shebangs:
|
||||||
|
name: Check executables
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run executables check
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual check-executables-have-shebangs --all-files
|
||||||
|
|
||||||
|
lint-flake8:
|
||||||
|
name: Check flake8
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run flake8
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual flake8 --all-files
|
||||||
|
|
||||||
|
lint-isort:
|
||||||
|
name: Check isort
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run isort
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual isort --all-files
|
||||||
|
|
||||||
|
lint-json:
|
||||||
|
name: Check JSON
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run check-json
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual check-json --all-files
|
||||||
|
|
||||||
|
lint-pyupgrade:
|
||||||
|
name: Check pyupgrade
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run pyupgrade
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual pyupgrade --all-files
|
||||||
|
|
||||||
|
# Disabled until we have the existing issues fixed
|
||||||
|
# lint-shellcheck:
|
||||||
|
# name: Check ShellCheck
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# needs: prepare-base
|
||||||
|
# steps:
|
||||||
|
# - name: Check out code from GitHub
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
# - name: Run ShellCheck
|
||||||
|
# uses: ludeeus/action-shellcheck@0.3.0
|
||||||
|
|
||||||
|
lint-yaml:
|
||||||
|
name: Check YAML
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Restore pre-commit environment from cache
|
||||||
|
id: cache-precommit
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.PRE_COMMIT_HOME }}
|
||||||
|
key: |
|
||||||
|
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Fail job if cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run yamllint
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pre-commit run --hook-stage manual yamllint --all-files
|
||||||
|
|
||||||
|
hassfest:
|
||||||
|
name: Check hassfest
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run hassfest
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
python -m script.hassfest --action validate
|
||||||
|
|
||||||
|
gen-requirements-all:
|
||||||
|
name: Check all requirements
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-base
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
id: python
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
|
- name: Restore base Python virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version
|
||||||
|
}}-${{ hashFiles('requirements.txt') }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run gen_requirements_all.py
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
python -m script.gen_requirements_all validate
|
||||||
|
|
||||||
|
prepare-tests:
|
||||||
|
name: Prepare tests for Python ${{ matrix.python-version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7, 3.8]
|
||||||
|
container: homeassistant/ci-azure:${{ matrix.python-version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name:
|
||||||
|
Restore full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('requirements_all.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('requirements_all.txt') }}
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-
|
||||||
|
- name:
|
||||||
|
Create full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
python -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install -U pip setuptools wheel
|
||||||
|
pip install -r requirements_all.txt -c homeassistant/package_constraints.txt
|
||||||
|
pip install -r requirements_test.txt -c homeassistant/package_constraints.txt
|
||||||
|
# Uninstalling typing as a workaround. Eventually we should make sure
|
||||||
|
# all our dependencies drop typing.
|
||||||
|
# Find offending deps with `pipdeptree -r -p typing`
|
||||||
|
pip uninstall -y typing
|
||||||
|
pip install -e .
|
||||||
|
|
||||||
|
pylint:
|
||||||
|
name: Check pylint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-tests
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
container: homeassistant/ci-azure:${{ matrix.python-version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name:
|
||||||
|
Restore full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('requirements_all.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run pylint
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pylint homeassistant
|
||||||
|
|
||||||
|
mypy:
|
||||||
|
name: Check mypy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-tests
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
container: homeassistant/ci-azure:${{ matrix.python-version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name:
|
||||||
|
Restore full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('requirements_all.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run mypy
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
mypy homeassistant
|
||||||
|
|
||||||
|
pytest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: prepare-tests
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
group: [1, 2, 3, 4]
|
||||||
|
python-version: [3.7, 3.8]
|
||||||
|
name: >-
|
||||||
|
Run tests Python ${{ matrix.python-version }} (group ${{ matrix.group }})
|
||||||
|
container: homeassistant/ci-azure:${{ matrix.python-version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name:
|
||||||
|
Restore full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('requirements_all.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Run pytest
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
pytest \
|
||||||
|
-qq \
|
||||||
|
--timeout=9 \
|
||||||
|
--durations=10 \
|
||||||
|
-n auto \
|
||||||
|
--dist=loadfile \
|
||||||
|
--test-group-count 4 \
|
||||||
|
--test-group=${{ matrix.group }} \
|
||||||
|
--cov homeassistant \
|
||||||
|
-o console_output_style=count \
|
||||||
|
-p no:sugar \
|
||||||
|
tests
|
||||||
|
- name: Upload coverage artifact
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: coverage-${{ matrix.python-version }}-group${{ matrix.group }}
|
||||||
|
path: .coverage
|
||||||
|
- name: Check dirty
|
||||||
|
run: |
|
||||||
|
./script/check_dirty
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
name: Process test coverage
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: pytest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.7]
|
||||||
|
container: homeassistant/ci-azure:${{ matrix.python-version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out code from GitHub
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name:
|
||||||
|
Restore full Python ${{ matrix.python-version }} virtual environment
|
||||||
|
id: cache-venv
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: venv
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-venv-${{ matrix.python-version }}-${{
|
||||||
|
hashFiles('requirements_test.txt') }}-${{
|
||||||
|
hashFiles('requirements_all.txt') }}-${{
|
||||||
|
hashFiles('homeassistant/package_constraints.txt') }}
|
||||||
|
- name: Fail job if Python cache restore failed
|
||||||
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Failed to restore Python virtual environment from cache"
|
||||||
|
exit 1
|
||||||
|
- name: Download all coverage artifacts
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
- name: Combine coverage results
|
||||||
|
run: |
|
||||||
|
. venv/bin/activate
|
||||||
|
coverage combine coverage*/.coverage*
|
||||||
|
coverage report --fail-under=94
|
||||||
|
coverage xml
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
20
requirements.txt
Normal file
20
requirements.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Home Assistant Core
|
||||||
|
aiohttp==3.6.1
|
||||||
|
astral==1.10.1
|
||||||
|
async_timeout==3.0.1
|
||||||
|
attrs==19.3.0
|
||||||
|
bcrypt==3.1.7
|
||||||
|
certifi>=2020.4.5.1
|
||||||
|
ciso8601==2.1.3
|
||||||
|
importlib-metadata==1.6.0;python_version<'3.8'
|
||||||
|
jinja2>=2.11.1
|
||||||
|
PyJWT==1.7.1
|
||||||
|
cryptography==2.9.2
|
||||||
|
pip>=8.0.3
|
||||||
|
python-slugify==4.0.0
|
||||||
|
pytz>=2020.1
|
||||||
|
pyyaml==5.3.1
|
||||||
|
requests==2.24.0
|
||||||
|
ruamel.yaml==0.15.100
|
||||||
|
voluptuous==0.11.7
|
||||||
|
voluptuous-serialize==2.3.0
|
@ -1,23 +1,5 @@
|
|||||||
# Home Assistant core
|
# Home Assistant Core, full dependency set
|
||||||
aiohttp==3.6.1
|
-r requirements.txt
|
||||||
astral==1.10.1
|
|
||||||
async_timeout==3.0.1
|
|
||||||
attrs==19.3.0
|
|
||||||
bcrypt==3.1.7
|
|
||||||
certifi>=2020.4.5.1
|
|
||||||
ciso8601==2.1.3
|
|
||||||
importlib-metadata==1.6.0;python_version<'3.8'
|
|
||||||
jinja2>=2.11.1
|
|
||||||
PyJWT==1.7.1
|
|
||||||
cryptography==2.9.2
|
|
||||||
pip>=8.0.3
|
|
||||||
python-slugify==4.0.0
|
|
||||||
pytz>=2020.1
|
|
||||||
pyyaml==5.3.1
|
|
||||||
requests==2.24.0
|
|
||||||
ruamel.yaml==0.15.100
|
|
||||||
voluptuous==0.11.7
|
|
||||||
voluptuous-serialize==2.3.0
|
|
||||||
|
|
||||||
# homeassistant.components.nuimo_controller
|
# homeassistant.components.nuimo_controller
|
||||||
--only-binary=all nuimo==0.1.0
|
--only-binary=all nuimo==0.1.0
|
||||||
|
@ -14,8 +14,10 @@ astroid==2.3.3
|
|||||||
pylint-strict-informational==0.1
|
pylint-strict-informational==0.1
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
pytest-cov==2.10.0
|
pytest-cov==2.10.0
|
||||||
|
pytest-test-groups==1.0.3
|
||||||
pytest-sugar==0.9.3
|
pytest-sugar==0.9.3
|
||||||
pytest-timeout==1.3.4
|
pytest-timeout==1.3.4
|
||||||
|
pytest-xdist==1.32.0
|
||||||
pytest==5.4.3
|
pytest==5.4.3
|
||||||
requests_mock==1.8.0
|
requests_mock==1.8.0
|
||||||
responses==0.10.6
|
responses==0.10.6
|
@ -222,13 +222,22 @@ def generate_requirements_list(reqs):
|
|||||||
return "".join(output)
|
return "".join(output)
|
||||||
|
|
||||||
|
|
||||||
def requirements_all_output(reqs):
|
def requirements_output(reqs):
|
||||||
"""Generate output for requirements_all."""
|
"""Generate output for requirements."""
|
||||||
output = []
|
output = []
|
||||||
output.append("# Home Assistant core")
|
output.append("# Home Assistant Core")
|
||||||
output.append("\n")
|
output.append("\n")
|
||||||
output.append("\n".join(core_requirements()))
|
output.append("\n".join(core_requirements()))
|
||||||
output.append("\n")
|
output.append("\n")
|
||||||
|
|
||||||
|
return "".join(output)
|
||||||
|
|
||||||
|
|
||||||
|
def requirements_all_output(reqs):
|
||||||
|
"""Generate output for requirements_all."""
|
||||||
|
output = []
|
||||||
|
output.append("# Home Assistant Core, full dependency set\n")
|
||||||
|
output.append("-r requirements.txt\n")
|
||||||
output.append(generate_requirements_list(reqs))
|
output.append(generate_requirements_list(reqs))
|
||||||
|
|
||||||
return "".join(output)
|
return "".join(output)
|
||||||
@ -315,13 +324,15 @@ def main(validate):
|
|||||||
if data is None:
|
if data is None:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
reqs_file = requirements_all_output(data)
|
reqs_file = requirements_output(data)
|
||||||
|
reqs_all_file = requirements_all_output(data)
|
||||||
reqs_test_file = requirements_test_output(data)
|
reqs_test_file = requirements_test_output(data)
|
||||||
reqs_pre_commit_file = requirements_pre_commit_output()
|
reqs_pre_commit_file = requirements_pre_commit_output()
|
||||||
constraints = gather_constraints()
|
constraints = gather_constraints()
|
||||||
|
|
||||||
files = (
|
files = (
|
||||||
("requirements_all.txt", reqs_file),
|
("requirements.txt", reqs_file),
|
||||||
|
("requirements_all.txt", reqs_all_file),
|
||||||
("requirements_test_pre_commit.txt", reqs_pre_commit_file),
|
("requirements_test_pre_commit.txt", reqs_pre_commit_file),
|
||||||
("requirements_test_all.txt", reqs_test_file),
|
("requirements_test_all.txt", reqs_test_file),
|
||||||
("homeassistant/package_constraints.txt", constraints),
|
("homeassistant/package_constraints.txt", constraints),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user