-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_variables.sh
executable file
·132 lines (125 loc) · 3.68 KB
/
export_variables.sh
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
#!/bin/sh
public_ranch="c8s c9s c10s fedora"
private_ranch="rhel8 rhel9 rhel9-unsubscribed rhel10 rhel10-unsubscribed"
all_os="$public_ranch $private_ranch"
os_test="$1" # options: c9s, c10s, fedora, rhel8, rhel9, rhel9-unsubscribed, rhel10, rhel10-unsubscribed
test_case="$2" # options: container, openshift-4, openshift-pytest
user_context="$3" # User can specify its own user-defined context, like 'Testing Farm - pytest - RHEL8'
if [ -z "$os_test" ] || ! echo "$all_os" | grep -q "$os_test" ; then
echo "::error::os_test '$os_test' is not valid"
echo "::warning::choose one of: $all_os"
exit 5
fi
# container tests vs openshift tests
case "$test_case" in
"container")
test_case="container"
tmt_plan_suffix="-docker$"
context_suffix=""
test_name="test"
;;
"container-pytest")
test_case="container-pytest"
tmt_plan_suffix="-docker-pytest$"
context_suffix=" - PyTest"
test_name="test-pytest"
;;
"openshift-4")
context_suffix=" - OpenShift 4"
tmt_plan_suffix="-openshift-4$"
test_name="test-openshift-4"
;;
"openshift-pytest")
context_suffix=" - PyTest - OpenShift 4"
tmt_plan_suffix="-openshift-pytest$"
test_name="test-openshift-pytest"
;;
"openshift-helms")
context_suffix=" - Helms - OpenShift 4"
tmt_plan_suffix="-openshift-helms$ "
test_name="test-openshift-pytest"
;;
""|*)
echo "::error::test_case '$test_case' is not valid"
exit 5
;;
esac
context_prefix=""
if [ -n "$user_context" ]; then
context_prefix="$user_context -"
fi
# public vs private ranch
if echo "$public_ranch" | grep -q "$os_test" ; then
api_key="public_api_key"
branch="main"
tf_scope="public"
tmt_repo="https://github.com/sclorg/sclorg-testing-farm"
else
api_key="private_api_key"
branch="master"
tf_scope="private"
tmt_repo="https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans"
fi
# variables based on operating system in test
dockerfile=Dockerfile."$os_test"
case "$os_test" in
"c9s")
tmt_plan="c9s"
context="$context_prefix CentOS Stream 9"
compose="CentOS-Stream-9"
;;
"c10s")
tmt_plan="c10s"
context="$context_prefix CentOS Stream 10"
compose="CentOS-Stream-10"
;;
"fedora")
tmt_plan="fedora"
context="Fedora"
compose="Fedora-latest"
;;
"rhel8")
tmt_plan="rhel8$tmt_plan_suffix"
context="$context_prefix RHEL8$context_suffix"
compose="RHEL-8.10.0-Nightly"
;;
"rhel9")
tmt_plan="rhel9$tmt_plan_suffix"
context="$context_prefix RHEL9$context_suffix"
compose="RHEL-9.4.0-Nightly"
;;
"rhel9-unsubscribed")
os_test="rhel9"
dockerfile="Dockerfile.$os_test"
tmt_plan="rhel9-unsubscribed-docker"
context="$context_prefix RHEL9 - Unsubscribed host"
compose="RHEL-9.4.0-Nightly"
;;
"rhel10")
tmt_plan="rhel10$tmt_plan_suffix"
context="$context_prefix RHEL10$context_suffix"
compose="RHEL-10-Nightly"
;;
"rhel10-unsubscribed")
os_test="rhel10"
dockerfile="Dockerfile.$os_test"
tmt_plan="rhel10-unsubscribed-docker"
context="$context_prefix RHEL10 - Unsubscribed host"
compose="RHEL-10-Nightly"
;;
""|*)
echo "::error::os_test '$os_test' is not valid"
exit 5
;;
esac
# shellcheck disable=SC2129
echo "api_key=$api_key" >> "$GITHUB_OUTPUT"
echo "branch=$branch" >> "$GITHUB_OUTPUT"
echo "tf_scope=$tf_scope" >> "$GITHUB_OUTPUT"
echo "tmt_repo=$tmt_repo" >> "$GITHUB_OUTPUT"
echo "os_test=$os_test" >> "$GITHUB_OUTPUT"
echo "tmt_plan=$tmt_plan" >> "$GITHUB_OUTPUT"
echo "context=$context" >> "$GITHUB_OUTPUT"
echo "compose=$compose" >> "$GITHUB_OUTPUT"
echo "test_name=$test_name" >> "$GITHUB_OUTPUT"
echo "dockerfile=$dockerfile" >> "$GITHUB_OUTPUT"