Skip to content

Commit

Permalink
[#27] In a Github workflow, run unit tests inside a HA DevContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Senart committed Jan 11, 2025
1 parent 06a51f6 commit bb458a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ on:
workflow_dispatch:
inputs:
skip-lint:
description: 'Skip linting'
description: "Skip linting"
required: false
default: false
type: boolean
skip-tests:
description: 'Skip tests'
description: "Skip tests"
required: false
default: false
type: boolean
Expand All @@ -27,7 +27,8 @@ permissions:

env:
DEFAULT_PYTHON_VERSION: "3.12"
TARGET_PYTHON_VERSIONS: "[ '3.9', '3.10', '3.11', '3.12', '3.13' ]"
#TARGET_PYTHON_VERSIONS: "[ '3.9', '3.10', '3.11', '3.12', '3.13' ]"
TARGET_PYTHON_VERSIONS: "[ '3.12' ]"

jobs:
#----------------------------------------------
Expand Down Expand Up @@ -107,3 +108,4 @@ jobs:
uses: ./.github/workflows/python-test
with:
python-version: ${{ matrix.python-version }}
use-devcontainer: true
32 changes: 26 additions & 6 deletions .github/workflows/python-test/action.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: 'python-test'
description: 'Python testing workflow'
name: "python-test"
description: "Python testing workflow"

inputs:
python-version:
description: 'Python version'
description: "Python version"
required: true
default: '3.13'
default: "3.13"
use-devcontainer:
description: "Use devcontainer"
required: false
default: false
type: boolean

runs:
using: "composite"
Expand All @@ -14,7 +19,7 @@ runs:
# Set-up python
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
python-version: ${{ inputs.python-version }}

#----------------------------------------------
# Install poetry
Expand Down Expand Up @@ -48,7 +53,22 @@ runs:
run: poetry install --no-interaction

#----------------------------------------------
# Run test suite and output coverage file
# If not using devcontainer, run tests
- name: Test with pytest
if: ${{ !inputs.use-devcontainer }}
shell: bash
run: poetry run pytest

#----------------------------------------------
# If using devcontainer, run tests
- name: Build and run dev container task
if: ${{ inputs.use-devcontainer }}
uses: devcontainers/ci@v0.3
with:
runCmd: |
# Start HA supervisor
supervisor_run &
# Wait a few for HA to start
sleep 10
# Run tests
poetry run pytest

0 comments on commit bb458a2

Please sign in to comment.