Skip to content

Osfv ci tests scope determining - Testing #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 4, 2025
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
54 changes: 54 additions & 0 deletions .github/workflows/develop-pr-regression.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2024 3mdeb <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

name: Smoke tests on selected platforms

# Only try to run if a robot file or a lib was modified in the PR
on:
pull_request:
branches:
- develop
paths:
- '**.robot'
- 'lib/**'

concurrency:
group: shared-resource-lock
cancel-in-progress: false

jobs:
build:
runs-on: self-hosted

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: 'recursive'
fetch-depth: 0

- name: Fetch develop branch
run: git fetch origin develop

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Execute robot command
run: |
scripts/ci/develop_pr_auto_regression.sh

- name: Upload HTML files as artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: HTML-Reports
path: |
logs/
1 change: 0 additions & 1 deletion .github/workflows/qemu-self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ on:
- 'scripts/ci/qemu-self-test.sh'
- 'scripts/ci/qemu-run.sh'
- 'requirements.txt'
workflow_dispatch:

jobs:
qemu:
Expand Down
59 changes: 59 additions & 0 deletions scripts/ci/develop_pr_auto_regression.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "Comparing $(git rev-parse HEAD) with develop branch. Changed files:"
git diff --name-only origin/develop

mapfile -t commands < <(${SCRIPT_DIR}/regression-scope/osfv_regression_scope.py commands --compare_to origin/develop)
echo "Commands to run:"
echo "${commands[@]}"
printf "\n"

if [[ ${#commands[@]} -eq 0 ]]; then
echo "No tests required to run for these changes."
fi

pids=()
statuses=()
LOGS_DIR="./logs"
mkdir $LOGS_DIR/ || true
i=1
for command in "${commands[@]}"; do
(
echo "Executing: ${command}"
eval ${command} > "$LOGS_DIR/run_${i}.log" 2>&1
) &
pids[${i}]=$!
(( i++ ))
done

sleep 1

for idx in "${!pids[@]}"; do
echo "Waiting for run $idx to finish..."
if wait ${pids[$idx]}; then
statuses[idx]=0
echo "run $idx is done."
else
statuses[idx]=$?
echo "run $idx failed."
fi
done


exit_code=0
i=0
for code in "${statuses[@]}"; do
if [[ "$code" -ne 0 ]]; then
echo "Run ${i} failed with exit code ${code}. Check $LOGS_DIR/run_${i}.log for details."
exit_code=1
fi
(( i++))
done

exit $exit_code
14 changes: 8 additions & 6 deletions scripts/ci/regression-scope/lib/parser_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ def _assemble_commands_from_runs_data(self, runs_data):
"""
commands = []
for data in runs_data:
run = []
if len(data["env"]) > 0:
commands.append(data["env"])
run.extend(data["env"])
run.append("&&")
if len(data["files"]) > 0:
commands.append(
self._assemble_robot_command(data["files"], data["args"])
)
run.extend(self._assemble_robot_command(data["files"], data["args"]))
else:
commands.append(data["command"])
run.extend(data["command"])
commands.append(run)
return commands

def _uniqeuify_runs_data(self, parser_runs_data, by=["env", "args"]):
Expand Down Expand Up @@ -86,7 +87,8 @@ def commands(self):
Each line is one command.
"""
uniquified = self._uniqeuify_runs_data(self.runs_data, ["env", "args"])
return self._assemble_commands_from_runs_data(uniquified)
commands = self._assemble_commands_from_runs_data(uniquified)
return commands

def wrapper_args(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci/regression-scope/osfv_regression_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def commands(
self.changed_files = get_changed_files(compare_to)
parser = ParserManager(self.rules, self.changed_files)
parser.parse()
print(" ".join(cmd for sublist in parser.commands() for cmd in sublist))
for command in parser.commands():
print(" ".join(command))

def robot_args(
self, rules_file="scripts/ci/regression-scope/rules.json", compare_to="HEAD"
Expand Down
6 changes: 2 additions & 4 deletions scripts/ci/regression-scope/regression_scope_selftests.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def test_single_module_single_change(self):
"FW_FILE=scripts/ci/qemu_q35.rom",
"export",
"CONFIG=qemu",
],
[
"&&",
"scripts/run.sh",
"dasharo-compatibility/audio-subsystem.robot",
"--",
Expand Down Expand Up @@ -214,8 +213,7 @@ def test_single_module_multiple_changes(self):
"FW_FILE=scripts/ci/qemu_q35.rom",
"export",
"CONFIG=qemu",
],
[
"&&",
"scripts/run.sh",
"dasharo-compatibility/audio-subsystem.robot",
"dasharo-compatibility/cpu-status.robot",
Expand Down
39 changes: 31 additions & 8 deletions scripts/ci/regression-scope/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
"run": [
{
"env_vars": {
"RTE_IP": "127.0.0.1",
"FW_FILE": "scripts/ci/qemu_q35.rom",
"CONFIG": "qemu"
"RTE_IP": "192.168.10.199",
"SONOFF_IP": "192.168.10.169",
"PIKVM_IP": "192.168.10.120",
"SNIPEIT_NO": "true",
"CONFIG": "msi-pro-z690-a-wifi-ddr4"
},
"files": {
"mode": "${FULL_FILENAME_MATCH}"
}
},
{
"env_vars": {
"RTE_IP": "192.168.10.171",
"SNIPEIT_NO": "true",
"CONFIG": "pcengines-apu3"
},
"snipeit": "no"
"files": {
"mode": "${FULL_FILENAME_MATCH}"
}
}
]
},
Expand All @@ -23,15 +34,27 @@
"run": [
{
"env_vars": {
"RTE_IP": "127.0.0.1",
"FW_FILE": "scripts/ci/qemu_q35.rom",
"CONFIG": "qemu"
"RTE_IP": "192.168.10.199",
"SNIPEIT_NO": "true",
"SONOFF_IP": "192.168.10.169",
"PIKVM_IP": "192.168.10.16",
"CONFIG": "msi-pro-z690-a-wifi-ddr4"
},
"files": {
"mode": "${FILE_CONTAINS_MATCH}",
"search_in": ["dasharo-compatibility", "dasharo-security", "dasharo-performance", "dasharo-stability"]
}
},
{
"env_vars": {
"RTE_IP": "192.168.10.171",
"SNIPEIT_NO": "true",
"CONFIG": "pcengines-apu3"
},
"snipeit": "no"
"files": {
"mode": "${FILE_CONTAINS_MATCH}",
"search_in": ["dasharo-compatibility", "dasharo-security", "dasharo-performance", "dasharo-stability"]
}
}
]
}
Expand Down
Loading