Skip to content

CI

CI #1619

Workflow file for this run

name: CI
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
schedule:
- cron: 0 12 * * *
permissions:
contents: read
env:
FORCE_COLOR: 1
DEFAULT_PYTHON: "3.11"
PYUPGRADE_TARGET: "--py311-plus"
concurrency:
# yamllint disable-line rule:line-length
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
yamllint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run yamllint
uses: frenck/action-yamllint@34b4bbcaeabedcfefad6adea8c5bbc42af0e2d47 # v1.5.0
with:
config: .yamllint
bundle:
name: Bundle external component and ESPHome
runs-on: ubuntu-24.04
outputs:
repo-hash: ${{ github.sha }}
steps:
- name: Check out this project
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check out code from ESPHome project
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: esphome/esphome
ref: dev
path: esphome
- name: Copy external component into the esphome project
run: |
cd esphome
ln -sf ../venv venv
- name: Archive prepared repository
uses: pyTooling/upload-artifact@a59f191f676112c140f4330026bbb6ac19b7a44d # v7
with:
name: bundle
path: .
include-hidden-files: true
retention-days: 1
common:
name: Create common environment
runs-on: ubuntu-24.04
needs: bundle
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Download prepared repository
uses: pyTooling/download-artifact@dc575e4e9df4b6e3580712285f1c90f579bb8712 # v8
with:
name: bundle
path: .
- name: Update index to make "git diff-index" happy
run: git update-index -q --really-refresh
- name: Generate cache-key
id: cache-key
run: echo key="${{ hashFiles('esphome/requirements.txt', 'esphome/requirements_test.txt') }}" >> $GITHUB_OUTPUT
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: venv
# yamllint disable-line rule:line-length
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ steps.cache-key.outputs.key }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python --version
cd esphome
pip install -r requirements.txt -r requirements_test.txt
pip install -e .
esphome-config:
name: Validate example configurations
runs-on: ubuntu-24.04
needs:
- bundle
- common
steps:
- name: Download prepared repository
uses: pyTooling/download-artifact@dc575e4e9df4b6e3580712285f1c90f579bb8712 # v8
with:
name: bundle
path: .
- name: Restore Python
uses: ./.github/actions/restore-python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Validate example configurations
run: |
. venv/bin/activate
for YAML in *example.yaml; do
if [ "${{ github.event_name }}" = "pull_request" ]; then
sed -i "s#ref: main#ref: ${{ github.event.pull_request.head.ref }}#" $YAML
fi
esphome config $YAML
done
esphome-compile:
name: Build example configurations
runs-on: ubuntu-24.04
needs:
- bundle
- common
steps:
- name: Download prepared repository
uses: pyTooling/download-artifact@dc575e4e9df4b6e3580712285f1c90f579bb8712 # v8
with:
name: bundle
path: .
- name: Restore Python
uses: ./.github/actions/restore-python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Compile example configurations
run: |
. venv/bin/activate
for YAML in *example.yaml; do
if [ "${{ github.event_name }}" = "pull_request" ]; then
sed -i "s#ref: main#ref: ${{ github.event.pull_request.head.ref }}#" $YAML
fi
esphome compile $YAML
done