100 lines
3.3 KiB
YAML
100 lines
3.3 KiB
YAML
---
|
|
name: Validate definitions
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.8'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v3
|
|
id: cache-venv
|
|
with:
|
|
path: ./.venv/
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m venv ./.venv
|
|
source ./.venv/bin/activate
|
|
python -m pip install -r requirements.txt
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
- name: Lint YAML files
|
|
run: |
|
|
source ./.venv/bin/activate
|
|
yamllint --format github --strict \
|
|
device-types/ module-types/
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.8'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v3
|
|
id: cache-venv
|
|
with:
|
|
path: ./.venv/
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m venv ./.venv
|
|
source ./.venv/bin/activate
|
|
python -m pip install -r requirements.txt
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
- name: Format YAML files (hooks)
|
|
run: |
|
|
source ./.venv/bin/activate
|
|
pre-commit run --config .pre-commit-hooks-config.yaml --all-files
|
|
- name: Format YAML files (yamlfmt)
|
|
run: |
|
|
source ./.venv/bin/activate
|
|
pre-commit run --config .pre-commit-yamlfmt-config.yaml --all-files
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: [lint, format]
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
id: setup_python
|
|
with:
|
|
python-version: '3.8'
|
|
- name: cache virtualenv
|
|
uses: actions/cache@v3
|
|
id: cache-venv-pytest
|
|
with:
|
|
path: ./.venv/
|
|
key: ${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-pytest-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-venv-pytest-
|
|
- name: Install dependencies
|
|
shell: bash
|
|
run: |
|
|
python -m venv ./.venv
|
|
source ./.venv/bin/activate
|
|
python -m pip install -r requirements.txt
|
|
python -m pip install pytest-github-actions-annotate-failures
|
|
if: steps.cache-venv-pytest.outputs.cache-hit != 'true'
|
|
- name: Run Test Cases
|
|
id: pytest
|
|
run: |
|
|
source ./.venv/bin/activate
|
|
pytest --tb=short -v
|