Repository navigation
Expand file tree
/
Copy pathcase.example.json
More file actions
133 lines (133 loc) · 4.41 KB
/
Copy pathcase.example.json
File metadata and controls
133 lines (133 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
"name": "Argo JUnit 证据回收示例",
"description": "原生 Argo DAG,写入 JUnit 报告并通过共享结果卷回收和校验证据。",
"body": {
"schema_version": "workflow/v1alpha1",
"backend": "argo",
"template": {
"apiVersion": "argoproj.io/v1alpha1",
"kind": "WorkflowTemplate",
"metadata": {
"name": "malta-native-hello"
},
"spec": {
"entrypoint": "main",
"arguments": {
"parameters": [
{
"name": "malta_context"
}
]
},
"volumes": [
{
"name": "results",
"persistentVolumeClaim": {
"claimName": "replace-shared-results-pvc"
}
}
],
"templates": [
{
"name": "main",
"dag": {
"tasks": [
{
"name": "check",
"template": "check"
}
]
}
},
{
"name": "check",
"outputs": {
"parameters": [
{
"name": "evidence",
"valueFrom": {
"path": "/tmp/evidence-path"
}
}
]
},
"container": {
"image": "python:3.12-alpine",
"command": [
"python",
"-c"
],
"args": [
"import os,json,hashlib\nfrom pathlib import Path\nctx=json.loads(os.environ['MALTA_CONTEXT'])\nrun_id=os.environ['WORKFLOW_NAME']+'.'+os.environ['WORKFLOW_UID']\nstage_id=os.environ['NODE_ID']\nassert stage_id\nfolder=Path('/results')/run_id/stage_id\nfolder.mkdir(parents=True,exist_ok=True)\nraw=b'<testsuite tests=\"1\"><testcase classname=\"native\" name=\"arithmetic\"/></testsuite>'\nassert 2+2==4\n(folder/'junit.xml.tmp').write_bytes(raw)\n(folder/'junit.xml.tmp').replace(folder/'junit.xml')\nmanifest={'schema_version':'malta.evidence/v1','workflow_version_id':ctx['workflow_version_id'],'snapshot_hash':ctx['snapshot_hash'],'run_id':run_id,'node_id':'check','stage_run_id':stage_id,'attempt':0,'eviction_count':0,'environment_id':ctx['environment_id'],'software_version_id':ctx['software_version_id'],'parser':'junit','assertions':{},'files':[{'path':'junit.xml','size':len(raw),'sha256':hashlib.sha256(raw).hexdigest()}]}\n(folder/'manifest.tmp').write_text(json.dumps(manifest))\n(folder/'manifest.tmp').replace(folder/'manifest.json')\nPath('/tmp/evidence-path').write_text(str(folder/'manifest.json'))\n"
],
"env": [
{
"name": "MALTA_CONTEXT",
"value": "{{workflow.parameters.malta_context}}"
},
{
"name": "WORKFLOW_NAME",
"value": "{{workflow.name}}"
},
{
"name": "WORKFLOW_UID",
"value": "{{workflow.uid}}"
},
{
"name": "NODE_ID",
"valueFrom": {
"fieldRef": {
"fieldPath": "metadata.annotations['workflows.argoproj.io/node-id']"
}
}
}
],
"volumeMounts": [
{
"name": "results",
"mountPath": "/results"
}
],
"resources": {
"requests": {
"cpu": "100m",
"memory": "64Mi"
},
"limits": {
"cpu": "1",
"memory": "128Mi"
}
}
}
}
],
"nodeSelector": {
"kubernetes.io/hostname": "replace-client-node"
}
}
},
"timeout_seconds": 60,
"results": [
{
"node_id": "check",
"output": "evidence",
"parser": "junit",
"required": true
}
],
"bindings": [
{
"pointer": "/spec/volumes/0/persistentVolumeClaim/claimName",
"source": "profile",
"key": "results_pvc"
},
{
"pointer": "/spec/nodeSelector/kubernetes.io~1hostname",
"source": "profile",
"key": "node"
}
]
},
"base_revision": 0,
"change_note": "首次登记"
}