Skip to content

Commit

Permalink
Merge branch 'main' into async_process_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Apr 11, 2024
2 parents 837c4b7 + cf80a76 commit 09d0ebe
Show file tree
Hide file tree
Showing 305 changed files with 17,077 additions and 2,428 deletions.
13 changes: 1 addition & 12 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@
source = custom_components

omit =
# omit pieces of code that rely on external API calls
# These should be mocked one day....
custom_components/hacs/helpers/get_defaults.py
custom_components/hacs/operational/setup_actions/load_hacs_repository.py
custom_components/hacs/operational/factory.py
custom_components/hacs/operational/relaod.py
custom_components/hacs/operational/remove.py
custom_components/hacs/operational/setup.py
custom_components/hacs/config_flow.py
custom_components/hacs/__init__.py

# omit tests
tests/*

# omit scripts
scripts/*
scripts/update/*

[report]
exclude_lines =
Expand Down
2 changes: 1 addition & 1 deletion .github/pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
files: ^((custom_components|script|tests)/.+)?[^/]+\.py$

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.6
hooks:
- id: codespell
stages: [manual]
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/generate-hacs-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
if: github.repository == 'hacs/integration'
name: Generate ${{ matrix.category }} data
strategy:
fail-fast: false
matrix:
category: ${{ fromJSON( needs.generate-matrix.outputs.categories )}}
steps:
Expand Down Expand Up @@ -92,6 +93,11 @@ jobs:
jq -c . outputdata/${{ matrix.category }}/data.json
jq -c . outputdata/${{ matrix.category }}/repositories.json
- name: Validate output with schema
if: steps.updated.outputs.updated == 'true'
run: |
python3 -m scripts.data.validate_category_data ${{ matrix.category }} outputdata/${{ matrix.category }}/data.json
- name: Generate diff
if: steps.updated.outputs.updated == 'true'
run: |
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/pull_requests_labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
pull_request:
types:
- labeled
- opened
- synchronize
- unlabeled
branches:
- main
Expand All @@ -19,9 +21,10 @@ jobs:
uses: actions/[email protected]

- name: Check the labels
uses: ludeeus/action-require-labels@1.0.0
uses: ludeeus/action-require-labels@1.1.0
with:
labels: >-
Breaking Change, Experimental, pr: new-feature,
pr: enhancement, pr: refactor, pr: bugfix,
pr: dependency-update
pr: dependency-update, pr: action, pr: test,
pr: repository
59 changes: 17 additions & 42 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,8 @@ concurrency:
cancel-in-progress: true

jobs:
run:
name: With pytest for Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: 📥 Checkout the repository
uses: actions/[email protected]

- name: 🛠️ Set up Python
uses: actions/[email protected]
id: python
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements_base.txt
requirements_test.txt
- name: 📦 Install requirements
run: |
scripts/install/frontend
scripts/install/pip_packages --requirement requirements_test.txt
- name: 🏃 Run tests
env:
PYTEST: true
run: |
python3 -m pytest
- name: 📤 Upload coverage to Codecov
if: ${{ matrix.python-version == '3.11' }}
run: |
scripts/coverage
curl -sfSL https://codecov.io/bash | bash -
legacy:
name: With pytest with Home Assistant 2023.6.0
name: With pytest with Home Assistant (min. supported version)
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout the repository
Expand All @@ -78,17 +41,23 @@ jobs:
run: |
python3 -m pytest
core_dev:
name: With pytest with Home Assistant dev
dev:
name: With pytest with Home Assistant (${{ matrix.homeassistant-version }}) & Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
homeassistant-version:
- "dev"
python-version:
- "3.12"
steps:
- name: 📥 Checkout the repository
uses: actions/[email protected]

- name: 🛠️ Set up Python 3.12
- name: 🛠️ Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: "3.12"
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements_base.txt
Expand All @@ -105,3 +74,9 @@ jobs:
PYTEST: true
run: |
python3 -m pytest
- name: 📤 Upload coverage to Codecov
if: ${{ matrix.python-version == '3.12' }}
run: |
scripts/coverage
curl -sfSL https://codecov.io/bash | bash -
152 changes: 108 additions & 44 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,109 @@ on:
branches:
- main
schedule:
- cron: "0 0 * * *"
- cron: "0 12 * * *"

concurrency:
group: validate-${{ github.ref }}
cancel-in-progress: true
group: validate-${{ github.ref }}

jobs:
preflight:
if: ${{ github.repository == 'hacs/integration' }}
runs-on: ubuntu-latest
name: Preflight
steps:
- name: Validation preflight
env:
ACTOR: ${{ github.actor }}
EVENT_NAME: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
REF: ${{ github.ref }}
SHA: ${{ github.sha }}
run: |
echo "**Start:** $(date)" >> $GITHUB_STEP_SUMMARY
echo "**Actor:** $ACTOR" >> $GITHUB_STEP_SUMMARY
echo "**Event:** $EVENT_NAME" >> $GITHUB_STEP_SUMMARY
echo "**Ref name:** $REF_NAME" >> $GITHUB_STEP_SUMMARY
echo "**Ref:** $REF" >> $GITHUB_STEP_SUMMARY
echo "**SHA:** $SHA" >> $GITHUB_STEP_SUMMARY
validate-hassfest:
needs:
- "preflight"
runs-on: ubuntu-latest
name: With hassfest
steps:
- name: 📥 Checkout the repository
uses: actions/[email protected]
- name: Checkout the repository
uses: actions/[email protected]

- name: 🏃 Hassfest validation
uses: "home-assistant/actions/hassfest@master"
# Test files conflics with running hassfest
- name: Remove tests
run: rm -rf tests

- name: 📨 Discord notification
if: ${{ github.event_name == 'schedule' && failure() }}
run: |
curl \
-H "Content-Type: application/json" \
-d '{"username": "GitHub action failure", "content": "[Scheduled action failed!](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"}' \
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }}
- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"

validate-hacs:
needs:
- "preflight"
runs-on: ubuntu-latest
name: With HACS Action
steps:
- name: 🏃 HACS validation
uses: hacs/action@main
with:
category: integration
- name: HACS validation
uses: hacs/action@main
with:
category: integration

validate-hacs-local:
if: ${{ github.event_name != 'schedule' }}
needs:
- "preflight"
runs-on: ubuntu-latest
name: Check ${{matrix.entry.category}} ${{matrix.entry.repository}} with HACS Action (local)
strategy:
matrix:
entry:
- repository: "hacs/integration"
category: "integration"
- repository: "piitaya/lovelace-mushroom"
category: "plugin"
steps:
- name: Checkout the repository
uses: actions/[email protected]

- name: 📨 Discord notification
if: ${{ github.event_name == 'schedule' && failure() }}
run: |
curl \
-H "Content-Type: application/json" \
-d '{"username": "GitHub action failure", "content": "[Scheduled action failed!](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"}' \
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }}
- name: Build Container
run: |
cd action
docker build . -t hacs/action:local
- name: Run Action
run: |
docker run --name hacs_action_local \
--env INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--env INPUT_REPOSITORY=${{matrix.entry.repository}} \
--env INPUT_CATEGORY=${{matrix.entry.category}} \
hacs/action:local
validata-hacs-data:
if: ${{ github.event_name != 'schedule' }}
needs:
- "preflight"
runs-on: ubuntu-latest
name: Validate HACS data generation
name: Check ${{matrix.entry.category}} ${{matrix.entry.repository}} with HACS data generation
strategy:
matrix:
entry:
- repository: "hacs/integration"
category: "integration"
- repository: "piitaya/lovelace-mushroom"
category: "plugin"
steps:
- name: Checkout the repository
if: ${{ github.event_name == 'push' }}
uses: actions/[email protected]

- name: Set up Python
if: ${{ github.event_name == 'push' }}
uses: actions/[email protected]
id: python
uses: actions/[email protected]
with:
python-version: "3.11"
cache: 'pip'
Expand All @@ -71,34 +119,45 @@ jobs:
requirements_generate_data.txt
- name: Install dependencies
if: ${{ github.event_name == 'push' }}
run: |
scripts/install/frontend
scripts/install/pip_packages --requirement requirements_generate_data.txt
- name: Generate data
if: ${{ github.event_name == 'push' }}
run: python3 -m scripts.data.generate_category_data integration hacs/integration
run: |
python3 -m scripts.data.generate_category_data \
${{ matrix.entry.category }} \
${{ matrix.entry.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate output with JQ
if: ${{ github.event_name == 'push' }}
run: |
jq -c . outputdata/integration/data.json
jq -c . outputdata/integration/repositories.json
jq -c . outputdata/${{ matrix.entry.category }}/data.json
jq -c . outputdata/${{ matrix.entry.category }}/repositories.json
- name: Validate output with schema
run: |
python3 -m scripts.data.validate_category_data ${{ matrix.entry.category }} outputdata/${{ matrix.entry.category }}/data.json
validate-homeassistant:
name: With Home Assistant
needs:
- "preflight"
runs-on: ubuntu-latest
name: With Home Assistant ${{ matrix.channel }}
strategy:
matrix:
channel: [stable, beta, dev, "2023.6.0"]
runs-on: ubuntu-latest
channel:
- "stable"
- "beta"
- "dev"
- "2023.6.0"
steps:
- name: 📥 Checkout the repository
- name: Checkout the repository
uses: actions/[email protected]

- name: 📋 Copy sample configuration for Home Assistant
- name: Copy sample configuration for Home Assistant
run: |
mkdir ./test_configuration
bash scripts/install/frontend
Expand All @@ -107,17 +166,22 @@ jobs:
echo "hacs:" >> ./test_configuration/configuration.yaml
echo " token: CHANGE_ME" >> ./test_configuration/configuration.yaml
- name: 🛠️ Setup Home Assistant
- name: Setup Home Assistant
id: homeassistant
uses: ludeeus/setup-homeassistant@main
with:
tag: ${{ matrix.channel }}
config-dir: test_configuration

- name: 📨 Discord notification
if: ${{ github.event_name == 'schedule' && failure() }}
notify_on_failure:
runs-on: ubuntu-latest
name: Trigger Discord notification when jobs fail
needs: ["preflight","validate-hassfest", "validate-hacs", "validate-homeassistant"]
steps:
- name: Send notification
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && github.event_name == 'schedule' }}
run: |
curl \
-H "Content-Type: application/json" \
-d '{"username": "GitHub action failure", "content": "[Scheduled action failed!](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"}' \
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }}
${{ secrets.DISCORD_WEBHOOK_ACTION_FAILURE }}
Loading

0 comments on commit 09d0ebe

Please sign in to comment.