Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions .github/workflows/snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ jobs:
--lg-log ${{ matrix.device }}/ \
--junitxml=${{ matrix.device }}/report.xml \
--lg-colored-steps \
--log-cli-level=CONSOLE \
--alluredir allure-results
--log-cli-level=CONSOLE

- name: Poweroff and unlock device
if: always()
Expand All @@ -143,13 +142,6 @@ jobs:
name: results-${{ matrix.device }}
path: ${{ matrix.device }}/*

- name: Upload allure results
uses: actions/upload-artifact@v4
if: always()
with:
name: allure-results-${{ matrix.device }}
path: allure-results

test-qemu:
name: QEMU ${{ matrix.target }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -208,7 +200,6 @@ jobs:
--junitxml=${{ matrix.target }}/report.xml \
--lg-colored-steps \
--log-cli-level=CONSOLE \
--alluredir allure-results \
--firmware $GITHUB_WORKSPACE/${firmware/.gz/}

- name: Upload results
Expand All @@ -218,14 +209,7 @@ jobs:
name: results-qemu_${{ matrix.target }}
path: ${{ matrix.target }}/*

- name: Upload allure results
uses: actions/upload-artifact@v4
if: always()
with:
name: allure-results-${{ matrix.target }}
path: allure-results

allure:
results:
name: Deploy results page
runs-on: ubuntu-latest
if: always()
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
__pycache__
console_*
results.json
alluredir/
allure3
ansible/host_vars
env
firmware
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dependencies = [
labgrid = { git = "https://github.com/aparcar/labgrid.git", branch = "aparcar/staging" }

[dependency-groups]
dev = ["allure-pytest>=2.14.3", "isort>=6.0.1", "ruff>=0.12.0"]
dev = ["isort>=6.0.1", "ruff>=0.12.0"]
46 changes: 1 addition & 45 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,15 @@

import json
import logging
from os import getenv, path
from pathlib import Path
from os import getenv

import allure
import pytest
from pytest_harvest import get_fixture_store

logger = logging.getLogger(__name__)

device = getenv("LG_ENV", "Unknown").split("/")[-1].split(".")[0]


@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
result = outcome.get_result()

if result.when == "call":
allure.dynamic.parent_suite(device)


def pytest_addoption(parser):
parser.addoption("--firmware", action="store", default="firmware.bin")

Expand All @@ -45,38 +33,6 @@ def pytest_configure(config):
config._metadata["environment"] = "staging"


def pytest_sessionfinish(session):
"""Gather all results and save them to a JSON file."""

fixture_store = get_fixture_store(session)
if "results_bag" not in fixture_store:
return

results = fixture_store["results_bag"]

Path("results.json").write_text(json.dumps(results, indent=2))

alluredir = session.config.getoption("--alluredir")

if not alluredir or not path.isdir(alluredir):
return

# workaround for allure to accept multiple devices as suites
for json_file in Path(alluredir).glob("*.json"):
json_data = json.loads(json_file.read_text())
if "testCaseId" in json_data:
json_data["parameters"] = [{"name": "device", "value": device}]
json_data["testCaseId"] = device + json_data["testCaseId"]
json_data["historyId"] = device + json_data["historyId"]
json_file.write_text(json.dumps(json_data))

allure_properties_file = Path(alluredir, "environment.properties")
allure_properties_file.write_text(
f"Version={results['tests/test_base.py::test_ubus_system_board']['version']}\n"
f"Revision={results['tests/test_base.py::test_ubus_system_board']['revision']}\n"
)


def ubus_call(command, namespace, method, params={}):
output = command.run_check(f"ubus call {namespace} {method} '{json.dumps(params)}'")

Expand Down
7 changes: 0 additions & 7 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import tarfile
import time

import allure
import pytest
from conftest import ubus_call

Expand Down Expand Up @@ -59,12 +58,6 @@ def test_ubus_system_board(ssh_command, results_bag):
results_bag["target"] = output["release"]["target"]
results_bag["version"] = output["release"]["version"]

allure.dynamic.label("board_name", output["board_name"])
allure.dynamic.label("kernel", output["kernel"])
allure.dynamic.label("revision", output["release"]["revision"])
allure.dynamic.label("target", output["release"]["target"])
allure.dynamic.label("version", output["release"]["version"])


def test_free_memory(ssh_command, results_bag):
used_memory = int(ssh_command.run_check("free -m")[1].split()[2])
Expand Down