Skip to content

Commit e50fbf7

Browse files
authored
Merge pull request #28 from bhcopeland/fix-ci-branch-name
ci: target the main branch instead of mainline
2 parents 0f9c0d2 + 9168508 commit e50fbf7

12 files changed

Lines changed: 45 additions & 52 deletions

File tree

.github/workflows/basic-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Basic CI
22

33
on:
44
push:
5-
branches: [ mainline ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ mainline ]
7+
branches: [ main ]
88

99
permissions:
1010
contents: read
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.11", "3.12"]
1818

1919
steps:
2020
- uses: actions/checkout@v4

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [ mainline ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ mainline ]
7+
branches: [ main ]
88

99
jobs:
1010
analyze:

.github/workflows/coverage-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
- name: Get base branch coverage
3131
run: |
32-
git checkout origin/mainline
32+
git checkout origin/main
3333
pip install -e ".[dev]"
3434
python -m pytest tests/ -m "not integration" --cov=src --cov-report=json:coverage-base.json --tb=no -q || true
3535
BASE_COVERAGE=$(python -c "import json; print(json.load(open('coverage-base.json'))['totals']['percent_covered'])")

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
version="1.0.0",
2626
description="Kernel-ci-cloud-labs",
2727
long_description=long_description,
28+
long_description_content_type="text/markdown",
2829
package_dir={"": "src"},
2930
packages=find_packages(where="src"),
3031
python_requires=">=3.11",
@@ -45,6 +46,9 @@
4546
"isort>=5.0",
4647
"pre-commit>=2.0",
4748
"pytest-cov>=2.0",
49+
"pandas>=1.3.0",
50+
"matplotlib>=3.4.0",
51+
"seaborn>=0.11.0",
4852
],
4953
"analysis": [
5054
"pandas>=1.3.0",

src/kernel_ci_cloud_labs/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ def main():
292292
val_parser.add_argument("--bucket", help="S3 bucket to verify (and create with --fix)")
293293
val_parser.add_argument("--role", help="IAM role name used by VM instance profiles")
294294
val_parser.add_argument("--region", default="us-west-2", help="AWS region (default: us-west-2)")
295-
val_parser.add_argument("--api-url", help=f"KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296-
val_parser.add_argument("--fix", action="store_true", help="Create missing resources (S3 bucket) instead of just reporting them")
295+
val_parser.add_argument("--api-url", help="KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296+
val_parser.add_argument(
297+
"--fix", action="store_true",
298+
help="Create missing resources (S3 bucket) instead of just reporting them",
299+
)
297300
val_parser.set_defaults(func=cmd_setup_validate)
298301

299302
args = parser.parse_args()

src/kernel_ci_cloud_labs/core/artifacts.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,3 @@ def collect_run_artifacts(
262262
manifest_path,
263263
)
264264
return manifest
265-
266-

src/kernel_ci_cloud_labs/pull_labs_poller.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
from kernel_ci_cloud_labs.kcidb_submit import (
4747
build_test_row,
48-
submit_tests,
4948
to_kcidb_status,
5049
)
5150
from kernel_ci_cloud_labs.pull_labs_translate import translate_job
@@ -314,7 +313,7 @@ def _validate_default_executor_deps() -> None:
314313

315314
problems: List[str] = []
316315
try:
317-
import boto3 # noqa: F401,PLC0415
316+
import boto3 # noqa: F401,PLC0415 # pylint: disable=unused-import
318317
except ImportError as e:
319318
problems.append(
320319
f"boto3 import failed ({e}) — run: python3.11 -m pip install -e ."

src/kernel_ci_cloud_labs/setup_validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _check_bucket_policy_statement(s3, bucket_name: str, fix: bool) -> bool:
200200
print(f"✗ Could not read bucket policy ({code}): {e}")
201201
return False
202202
existing = None
203-
except (ValueError, json.JSONDecodeError) as e:
203+
except ValueError as e:
204204
print(f"✗ Bucket policy is not valid JSON: {e}")
205205
return False
206206

@@ -365,7 +365,7 @@ def check_kcidb_jwt() -> bool:
365365
# JWT payload is base64url; pad to a multiple of 4 before decoding.
366366
payload_b64 = parts[1] + "=" * (-len(parts[1]) % 4)
367367
payload = json.loads(base64.urlsafe_b64decode(payload_b64))
368-
except (ValueError, json.JSONDecodeError) as e:
368+
except ValueError as e:
369369
print(f"✗ JWT payload not decodable: {e}")
370370
return False
371371

tests/test_kcidb_submit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ def test_submit_revision_posts_with_bearer_auth(self):
187187
class FakeResp:
188188
def __enter__(self):
189189
return self
190+
190191
def __exit__(self, *a):
191192
return False
193+
192194
def read(self):
193195
return b'{"status":"ok","id":"sub-1"}'
194196

@@ -237,7 +239,7 @@ def __enter__(self): return self
237239
def __exit__(self, *a): return False
238240
def read(self): return b'{}'
239241

240-
def fake_urlopen(req, timeout=None):
242+
def fake_urlopen(req, timeout=None): # pylint: disable=unused-argument
241243
captured["body"] = json.loads(req.data.decode("utf-8"))
242244
return FakeResp()
243245

@@ -264,7 +266,7 @@ def __enter__(self): return self
264266
def __exit__(self, *a): return False
265267
def read(self): return b'{}'
266268

267-
def fake_urlopen(req, timeout=None):
269+
def fake_urlopen(req, timeout=None): # pylint: disable=unused-argument
268270
captured["body"] = json.loads(req.data.decode("utf-8"))
269271
return FakeResp()
270272

tests/test_pull_labs_poller.py

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# SPDX-License-Identifier: Apache-2.0
22
#
33
# Copyright (C) 2026 Collabora Limited
4+
# pylint: disable=protected-access
45
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
56

67
"""Unit tests for pull_labs_poller (no network, no AWS)."""
78

89
import json
910
import logging
1011
import os
11-
import tempfile
1212
import urllib.error
1313
from unittest.mock import patch
1414

@@ -626,14 +626,16 @@ class TestProcessEventNodeResult:
626626
def _run(self, poller, event, translate=None):
627627
translate = translate or {"return_value": {}}
628628
captured = {}
629-
with patch.object(poller, "_claim_node", return_value=True), \
630-
patch.object(
631-
poller, "_finish_node",
632-
side_effect=lambda nid, outcome: captured.update(outcome=outcome),
633-
), \
634-
patch(_GET, return_value={"artifacts": {}}), \
635-
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job", **translate), \
636-
patch("kernel_ci_cloud_labs.pull_labs_poller.submit_tests", return_value={}):
629+
with (
630+
patch.object(poller, "_claim_node", return_value=True),
631+
patch.object(
632+
poller, "_finish_node",
633+
side_effect=lambda nid, outcome: captured.update(outcome=outcome),
634+
),
635+
patch(_GET, return_value={"artifacts": {}}),
636+
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job",
637+
**translate),
638+
):
637639
poller.process_event(event)
638640
return captured["outcome"]
639641

@@ -682,9 +684,10 @@ def test_translate_failure_finishes_invalid_job_params(self):
682684
assert "missing artifacts.kernel" in outcome.error_msg
683685

684686
def test_per_instance_rows_carry_log_url_and_stable_test_id(self):
685-
"""When executor returns per-instance rows with log_url, the submitted
686-
KCIDB rows must each carry that URL and a test_id derived from the
687-
instance_id (not the positional index)."""
687+
"""When executor returns per-instance rows with log_url, the node
688+
outcome must carry those URLs in artifacts.test_log (first URL) and
689+
test_log_N (subsequent URLs), and the node result must reflect the
690+
aggregated per-instance statuses."""
688691
per_test = [
689692
{"name": "boot", "status": "PASS", "instance_id": "i-aaaa1111",
690693
"log_url": "https://b.s3.eu-west-1.amazonaws.com/a.log"},
@@ -695,31 +698,15 @@ def test_per_instance_rows_carry_log_url_and_stable_test_id(self):
695698
_minimal_kc(),
696699
job_executor=lambda cfg: (per_test, None),
697700
)
698-
seen = {}
699-
with patch.object(p, "_claim_node", return_value=True), \
700-
patch.object(p, "_finish_node"), \
701-
patch(_GET, return_value={"artifacts": {}}), \
702-
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job",
703-
return_value={}), \
704-
patch(
705-
"kernel_ci_cloud_labs.pull_labs_poller.submit_tests",
706-
side_effect=lambda url, jwt, origin, build_id, rows: seen.update(rows=rows),
707-
):
708-
p.process_event(_job_event(node_id="ndX"))
709-
710-
rows = seen["rows"]
711-
assert len(rows) == 2
712-
by_id = {r["id"]: r for r in rows}
713-
# test_id derived from instance_id => stable across retries.
714-
assert set(by_id) == {"pullab_cloud_aws:ndX.i-aaaa1111", "pullab_cloud_aws:ndX.i-bbbb2222"}
715-
# Per-row log_url survives the build_test_row pass-through.
716-
assert by_id["pullab_cloud_aws:ndX.i-aaaa1111"]["log_url"] == \
701+
outcome = self._run(p, _job_event(node_id="ndX"))
702+
703+
# One FAIL among results -> overall node result is "fail".
704+
assert outcome.result == "fail"
705+
# Log URLs are attached to the outcome artifacts for send_kcidb.
706+
assert outcome.artifacts["test_log"] == \
717707
"https://b.s3.eu-west-1.amazonaws.com/a.log"
718-
assert by_id["pullab_cloud_aws:ndX.i-bbbb2222"]["log_url"] == \
708+
assert outcome.artifacts["test_log_1"] == \
719709
"https://b.s3.eu-west-1.amazonaws.com/b.log"
720-
# instance_id surfaces in misc for traceability.
721-
assert by_id["pullab_cloud_aws:ndX.i-aaaa1111"]["misc"]["instance_id"] == "i-aaaa1111"
722-
# Aggregated node outcome from per-instance statuses.
723710
# (one fail among two -> fail; verified indirectly via existing tests).
724711

725712

0 commit comments

Comments
 (0)