ci(lesavka): publish categorized test metrics reliably
This commit is contained in:
parent
bebba543fe
commit
c0fd97afab
26
Jenkinsfile
vendored
26
Jenkinsfile
vendored
@ -16,21 +16,35 @@ spec:
|
||||
image: rust:1.92-slim-bookworm
|
||||
command: ["cat"]
|
||||
tty: true
|
||||
env:
|
||||
- name: CARGO_HOME
|
||||
value: /home/jenkins/agent/.cargo-home
|
||||
- name: RUSTUP_HOME
|
||||
value: /home/jenkins/agent/.rustup-home
|
||||
- name: CARGO_TARGET_DIR
|
||||
value: /home/jenkins/agent/workspace/lesavka/target
|
||||
resources:
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: "1024Mi"
|
||||
ephemeral-storage: "6Gi"
|
||||
ephemeral-storage: "4Gi"
|
||||
limits:
|
||||
memory: "6Gi"
|
||||
ephemeral-storage: "12Gi"
|
||||
ephemeral-storage: "8Gi"
|
||||
volumeMounts:
|
||||
- name: workspace-volume
|
||||
mountPath: /home/jenkins/agent
|
||||
volumes:
|
||||
- name: workspace-volume
|
||||
emptyDir:
|
||||
sizeLimit: 12Gi
|
||||
ephemeral:
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: 40Gi
|
||||
"""
|
||||
}
|
||||
}
|
||||
@ -54,6 +68,10 @@ spec:
|
||||
IMAGE_PREFIX = "${REGISTRY}/lesavka"
|
||||
CARGO_TERM_COLOR = 'always'
|
||||
CARGO_BUILD_JOBS = '1'
|
||||
CARGO_HOME = "${WORKSPACE}/.cargo-home"
|
||||
RUSTUP_HOME = "${WORKSPACE}/.rustup-home"
|
||||
CARGO_TARGET_DIR = "${WORKSPACE}/target"
|
||||
PATH = "${WORKSPACE}/.cargo-home/bin:/usr/local/cargo/bin:${PATH}"
|
||||
DOCKER_BUILDKIT = '1'
|
||||
LESAVKA_CI_PROFILE = "${params.LESAVKA_CI_PROFILE}"
|
||||
QUALITY_GATE_PUSHGATEWAY_URL = "${params.QUALITY_GATE_PUSHGATEWAY_URL}"
|
||||
|
||||
@ -86,6 +86,7 @@ current_target = ''
|
||||
|
||||
manifest_path = pathlib.Path('tests/test-taxonomy-manifest.json')
|
||||
category_by_path = {}
|
||||
category_by_test_name = {}
|
||||
test_categories = set()
|
||||
if manifest_path.exists():
|
||||
for item in json.loads(manifest_path.read_text(encoding='utf-8')):
|
||||
@ -93,12 +94,63 @@ if manifest_path.exists():
|
||||
category = item.get('category', '')
|
||||
if path and category:
|
||||
category_by_path[path] = category
|
||||
category_by_test_name[pathlib.PurePosixPath(path).stem] = category
|
||||
if category not in {'fixtures', 'golden', 'helpers'}:
|
||||
test_categories.add(category)
|
||||
|
||||
def category_for_path(path: str) -> str:
|
||||
if path in category_by_path:
|
||||
return category_by_path[path]
|
||||
parts = pathlib.PurePosixPath(path).parts
|
||||
if len(parts) >= 2 and parts[0] == 'tests':
|
||||
return parts[1]
|
||||
if path.startswith('src/'):
|
||||
return 'unit'
|
||||
return 'uncategorized'
|
||||
|
||||
cargo_toml_path = pathlib.Path('Cargo.toml')
|
||||
if cargo_toml_path.exists():
|
||||
current_name = ''
|
||||
current_path = ''
|
||||
in_test_section = False
|
||||
for raw in cargo_toml_path.read_text(encoding='utf-8').splitlines():
|
||||
line = raw.strip()
|
||||
if line == '[[test]]':
|
||||
if current_name and current_path:
|
||||
category_by_test_name[current_name] = category_for_path(current_path)
|
||||
current_name = ''
|
||||
current_path = ''
|
||||
in_test_section = True
|
||||
continue
|
||||
if line.startswith('['):
|
||||
if in_test_section and current_name and current_path:
|
||||
category_by_test_name[current_name] = category_for_path(current_path)
|
||||
current_name = ''
|
||||
current_path = ''
|
||||
in_test_section = False
|
||||
continue
|
||||
if not in_test_section or '=' not in line:
|
||||
continue
|
||||
key, value = [part.strip() for part in line.split('=', 1)]
|
||||
value = value.strip('"')
|
||||
if key == 'name':
|
||||
current_name = value
|
||||
elif key == 'path':
|
||||
current_path = value
|
||||
if in_test_section and current_name and current_path:
|
||||
category_by_test_name[current_name] = category_for_path(current_path)
|
||||
|
||||
def category_for_target(target: str) -> str:
|
||||
if target in category_by_path:
|
||||
return category_by_path[target]
|
||||
target_path = pathlib.PurePosixPath(target)
|
||||
target_name = target_path.stem
|
||||
if target_name in category_by_test_name:
|
||||
return category_by_test_name[target_name]
|
||||
if len(target_path.parts) >= 3 and target_path.parts[-3:-1] == ('debug', 'deps'):
|
||||
binary_name = target_path.name.rsplit('-', 1)[0]
|
||||
if binary_name in category_by_test_name:
|
||||
return category_by_test_name[binary_name]
|
||||
parts = pathlib.PurePosixPath(target).parts
|
||||
if len(parts) >= 2 and parts[0] == 'tests':
|
||||
return parts[1]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user