Skip to content

Linting

Linting #483

Workflow file for this run

name: Linting
on:
push:
branches:
- main
- master
- dev
pull_request:
schedule:
- cron: "0 0 * * *"
env:
DEFAULT_PYTHON: 3.11
jobs:
test:
timeout-minutes: 45
defaults:
run:
shell: bash
runs-on: "ubuntu-latest"
env:
OS: "ubuntu-latest"
PYTHON: 3.11
steps:
- name: Set OS Environment Variables (not Windows)
if: runner.os != 'Windows'
run: |
echo 'ACTIVATE_PYTHON_VENV=.venv/bin/activate' >> $GITHUB_ENV
- name: Check out repository
uses: actions/checkout@v4
- name: Cache $HOME/.local # Significantly speeds up Poetry Install
uses: actions/cache@v3
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('.github/workflows/tests.yaml') }}
- name: Set up python ${{ env.PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON }}
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: false # Currently there seems to be some race-condition in windows
- name: Install library
run: poetry install --no-interaction
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Pre-commit run
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
pre-commit run --show-diff-on-failure --color=always --all-files
- name: Check tests folder existence
id: check_test_files
uses: andstor/file-existence-action@v2
with:
files: "tests"
- name: Run tests
if: steps.check_test_files.outputs.files_exists == 'true'
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
python -m pytest \
--cov=pythontemplate --cov-report term --cov-report xml --junitxml=testresults.xml
--timeout=9 \
--durations=10 \
-n auto \
-p no:sugar \
tests
coverage report
hacs:
runs-on: "ubuntu-latest"
name: HACS
steps:
- name: Check out the repository
uses: "actions/checkout@v4.1.1"
- name: HACS validation
uses: "hacs/action@22.5.0"
with:
category: "integration"
ignore: brands
hassfest:
runs-on: "ubuntu-latest"
name: Hassfest
steps:
- name: Check out the repository
uses: "actions/checkout@v4.1.1"
- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"