mirror of
https://github.com/home-assistant/operating-system.git
synced 2026-02-14 23:18:57 +00:00
Create foundation for Labgrid-based OS tests (#2812)
* Create foundation for Labgrid-based OS tests Add foundation for Labgrid-based tests of OS builds. Currently uses just the QEMU driver, which starts a virtual machine with pristine OS, and generates few log reports which are saved as build artifacts. Workflow is currently triggered either manually by specifying an OS version, or by OS build job, which now saves an artifact of the OVA image. This allows for some modularity. If we eventually add the possibility to run builds on PRs, we could also add the workflow_call trigger and turn the workflow into a reusable one. TBD (in future PRs): some meaningful tests and possibility to test on real hardware (either local or distributed). * Apply suggestions from @agners Co-authored-by: Stefan Agner <stefan@agner.ch> * Wrap test command in a script, create venv for local tests * Make shellcheck happy --------- Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
92
.github/workflows/test.yaml
vendored
Normal file
92
.github/workflows/test.yaml
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: Test HAOS image
|
||||
run-name: "Test HAOS ${{ inputs.version || format('(OS build #{0})', github.event.workflow_run.run_number) }}"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Version of HAOS to test
|
||||
required: true
|
||||
type: string
|
||||
|
||||
workflow_run:
|
||||
workflows: ["OS build"] # must be in sync with build workflow `name`
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
|
||||
|
||||
env:
|
||||
NO_KVM: 1
|
||||
|
||||
name: Test in QEMU
|
||||
runs-on: ubuntu-22.04
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./tests
|
||||
steps:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y qemu-system-x86 ovmf
|
||||
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.12
|
||||
|
||||
- name: Install Python requirements
|
||||
run:
|
||||
pip install -r requirements.txt
|
||||
|
||||
- name: Download HAOS image
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
run: |
|
||||
curl -sfL -o haos.qcow2.xz https://os-artifacts.home-assistant.io/${{github.event.inputs.version}}/haos_ova-${{github.event.inputs.version}}.qcow2.xz
|
||||
|
||||
- name: Get OS image artifact
|
||||
if: ${{ github.event_name == 'workflow_run' }}
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: build.yaml
|
||||
workflow_conclusion: success
|
||||
name: ova-image
|
||||
|
||||
- name: Extract OS image
|
||||
run: |
|
||||
unxz haos.qcow2.xz
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
./run_tests.sh
|
||||
|
||||
- name: Archive logs
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: logs
|
||||
path: |
|
||||
lg_logs/*
|
||||
|
||||
- name: Archive JUnit reports
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: junit_reports
|
||||
path: |
|
||||
junit_reports/*.xml
|
||||
|
||||
- name: Publish test report
|
||||
uses: mikepenz/action-junit-report@v4
|
||||
if: always()
|
||||
with:
|
||||
report_paths: 'junit_reports/*.xml'
|
||||
annotate_only: true
|
||||
detailed_summary: true
|
||||
Reference in New Issue
Block a user