-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-runner.yaml
145 lines (125 loc) · 4.65 KB
/
test-runner.yaml
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
134
135
136
137
138
139
140
141
142
143
144
apiVersion: tekton.dev/v1
kind: Task
metadata:
annotations:
tekton.dev/pipelines.minVersion: 0.12.1
tekton.dev/tags: test, konflux
labels:
app.kubernetes.io/version: "0.1"
build.appstudio.redhat.com/multi-platform-required: "true"
name: test-runner-mpc
spec:
description: test-runner-mpc
params:
- description: The platform to build on
name: PLATFORM
type: string
results:
- name: TEST_OUTPUT
description: the konflux test output string
stepTemplate:
env:
- name: BUILDER_IMAGE
value: quay.io/bcook/jq-ubi9@sha256:a158a654d0c82556256090b7cbfd66db58c39b8f594d69ef8c420a1a1e0b3b77
computeResources: {}
steps:
- env:
- name: COMMIT_SHA
value: "foo"
image: quay.io/redhat-appstudio/multi-platform-runner:01c7670e81d5120347cf0ad13372742489985e5f@sha256:246adeaaba600e207131d63a7f706cffdcdc37d8f600c56187123ec62823ff44
# per https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting
# the cluster will set imagePullPolicy to IfNotPresent
name: build
computeResources:
limits:
memory: 512Mi
requests:
cpu: 250m
memory: 128Mi
# the next script currently runs a bunch of stuff related to transferring workspace data, then rpm-ostree compose. I need to make it run git clone, then execute the test script.
script: |-
set -o verbose
set -eu
set -o pipefail
mkdir -p ~/.ssh
if [ -e "/ssh/error" ]; then
#no server could be provisioned
cat /ssh/error
exit 1
elif [ -e "/ssh/otp" ]; then
curl --cacert /ssh/otp-ca -XPOST -d @/ssh/otp $(cat /ssh/otp-server) >~/.ssh/id_rsa
echo "" >> ~/.ssh/id_rsa
else
cp /ssh/id_rsa ~/.ssh
fi
chmod 0400 ~/.ssh/id_rsa
export SSH_HOST=$(cat /ssh/host)
export BUILD_DIR=$(cat /ssh/user-dir)
export SSH_ARGS="-o StrictHostKeyChecking=no"
mkdir -p scripts
echo "$BUILD_DIR"
ssh $SSH_ARGS "$SSH_HOST" mkdir -p "$BUILD_DIR/workspaces" "$BUILD_DIR/scripts" "$BUILD_DIR/tmp"
echo -e local arch is: $(arch)
echo -e remote arch is:
ssh $SSH_ARGS "$SSH_HOST" /bin/bash -c "arch"
# transfers data
# rsync -ra $(workspaces.source.path)/ "$SSH_HOST:$BUILD_DIR/workspaces/source/"
# write the script to disk:
cat >scripts/script-build.sh <<'REMOTESSHEOF'
#!/bin/bash
set -o verbose
echo 'script-build.sh start'
echo -e $(uname -m)
# cd $(workspaces.source.path)
# if [ -z "$CONFIG_FILE" ] ; then
# CONFIG_FILE_ARG=""
# else
# CONFIG_FILE_ARG=" --image-config=source/$CONFIG_FILE "
#fi
# rpm-ostree compose image --initialize --format oci $CONFIG_FILE_ARG "source/$IMAGE_FILE" rhtap-final-image
echo 'script-build.sh end'
REMOTESSHEOF
# make it executable
chmod +x scripts/script-build.sh
# sync scripts dir to the SSH Host
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
# for debugging
ssh $SSH_ARGS "$SSH_HOST" /bin/bash -c "ls -alR /scripts"
ssh $SSH_ARGS "$SSH_HOST" /bin/bash -c "cat /script/script-build.sh"
# execute the script in a container on the SSH host
ssh $SSH_ARGS "$SSH_HOST" podman run \
-e PARAM_BUILDER_IMAGE="quay.io/bcook/jq-ubi9:latest" \
-v $BUILD_DIR/scripts:/script:Z \
--user=0 --rm "$BUILDER_IMAGE" /script/script-build.sh
# this is all bringing data back.
# rsync -ra "$SSH_HOST:$BUILD_DIR/workspaces/source/" "$(workspaces.source.path)/"
# rsync -ra "$SSH_HOST:$BUILD_DIR/tekton-results/" "/tekton/results/"
# buildah pull oci:rhtap-final-image
# buildah images
# buildah tag localhost/rhtap-final-image "$IMAGE"
# container=$(buildah from --pull-never "$IMAGE")
# buildah mount "$container" | tee /workspace/container_path
# echo $container > /workspace/container_name
env
# Hardcode result for now.
RESULT=SUCCESS
# emit a result like:
# TEST_OUTPUT: {"timestamp":"1717031352","namespace":"","successes":20,"failures":0,"warnings":0,"result":"SUCCESS"}
echo -n "{"timestamp":"${date +%s}","namespace":"","successes":${success},"failures":"","warnings":0,"result":${RESULT}}" > "$(results.TEST_OUTPUT.path)"
securityContext:
capabilities:
add:
- SETFCAP
volumeMounts:
- mountPath: /workspace
name: workspace
- mountPath: /ssh
name: ssh
readOnly: true
volumes:
- emptyDir: {}
name: workspace
- name: ssh
secret:
optional: false
secretName: multi-platform-ssh-$(context.taskRun.name)