forked from redhat-developer/rhdh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenshift-ci-tests.sh
More file actions
executable file
·170 lines (156 loc) · 5.49 KB
/
Copy pathopenshift-ci-tests.sh
File metadata and controls
executable file
·170 lines (156 loc) · 5.49 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
export PS4='[$(date "+%Y-%m-%d %H:%M:%S")] ' # only for debugging with `set -x`
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export DIR
# Source logging library first before any log calls
# shellcheck source=.ci/pipelines/lib/log.sh
source "${DIR}/lib/log.sh"
export OPENSHIFT_CI="${OPENSHIFT_CI:-false}"
if [[ -z "${OPENSHIFT_CI}" || "${OPENSHIFT_CI}" == "false" ]]; then
# NOTE: Use this file to override the environment variables for the local testing.
if [[ -f "${DIR}/env_override.local.sh" ]]; then
log::debug "Sourcing env_override.local.sh"
# shellcheck source=.ci/pipelines/env_override.local.sh
source "${DIR}/env_override.local.sh"
fi
fi
log::debug "Sourcing env_variables.sh"
# shellcheck source=.ci/pipelines/env_variables.sh
source "${DIR}/env_variables.sh"
log::debug "Sourcing reporting.sh"
# shellcheck source=.ci/pipelines/reporting.sh
source "${DIR}/reporting.sh"
save_overall_result 0 # Initialize overall result to 0 (success).
log::debug "Saving platform environment variables"
save_is_openshift "${IS_OPENSHIFT}"
save_container_platform "${CONTAINER_PLATFORM}" "${CONTAINER_PLATFORM_VERSION}"
# Define a cleanup function to be executed upon script exit.
# shellcheck source=.ci/pipelines/cleanup.sh
source "${DIR}/cleanup.sh"
trap cleanup EXIT
log::debug "Sourcing utils.sh"
# shellcheck source=.ci/pipelines/utils.sh
source "${DIR}/utils.sh"
# Rotate among 5 pairs (showcase _1.._5 and RBAC_1..RBAC_5)
result=$((10#$(date +%N) % 5))
case $result in
0) override_github_app_env_with_prefix "1" ;;
1) override_github_app_env_with_prefix "2" ;;
2) override_github_app_env_with_prefix "3" ;;
3) override_github_app_env_with_prefix "4" ;;
4) override_github_app_env_with_prefix "5" ;;
esac
main() {
log::info "Log file: ${LOGFILE}"
log::info "JOB_NAME : $JOB_NAME"
if [[ -z "${CHART_VERSION:-}" ]]; then
CHART_VERSION=$(helm::get_chart_version)
else
log::info "Using preset CHART_VERSION (pinned or from env): ${CHART_VERSION}"
fi
export CHART_VERSION
case "$JOB_NAME" in
*aks*helm*nightly*)
log::info "Sourcing aks-helm.sh"
# shellcheck source=.ci/pipelines/jobs/aks-helm.sh
source "${DIR}/jobs/aks-helm.sh"
log::info "Calling handle_aks_helm"
handle_aks_helm
;;
*aks*operator*nightly*)
log::info "Sourcing aks-operator.sh"
# shellcheck source=.ci/pipelines/jobs/aks-operator.sh
source "${DIR}/jobs/aks-operator.sh"
log::info "Calling handle_aks_operator"
handle_aks_operator
;;
*eks*helm*nightly*)
log::info "Sourcing eks-helm.sh"
# shellcheck source=.ci/pipelines/jobs/eks-helm.sh
source "${DIR}/jobs/eks-helm.sh"
log::info "Calling handle_eks_helm"
handle_eks_helm
;;
*eks*operator*nightly*)
log::info "Sourcing eks-operator.sh"
# shellcheck source=.ci/pipelines/jobs/eks-operator.sh
source "${DIR}/jobs/eks-operator.sh"
log::info "Calling handle_eks_operator"
handle_eks_operator
;;
*gke*helm*nightly*)
log::info "Sourcing gke-helm.sh"
# shellcheck source=.ci/pipelines/jobs/gke-helm.sh
source "${DIR}/jobs/gke-helm.sh"
log::info "Calling handle_gke_helm"
handle_gke_helm
;;
*gke*operator*nightly*)
log::info "Sourcing gke-operator.sh"
# shellcheck source=.ci/pipelines/jobs/gke-operator.sh
source "${DIR}/jobs/gke-operator.sh"
log::info "Calling handle_gke_operator"
handle_gke_operator
;;
*ocp*operator*auth-providers*nightly*)
log::info "Sourcing auth-providers.sh"
# shellcheck source=.ci/pipelines/jobs/auth-providers.sh
source "${DIR}/jobs/auth-providers.sh"
log::info "Calling handle_auth_providers"
handle_auth_providers
;;
*ocp*helm*upgrade*nightly*)
log::info "Sourcing upgrade.sh"
# shellcheck source=.ci/pipelines/jobs/upgrade.sh
source "${DIR}/jobs/upgrade.sh"
log::info "Calling helm upgrade"
handle_ocp_helm_upgrade
;;
*ocp*helm*nightly*)
log::info "Sourcing ocp-nightly.sh"
# shellcheck source=.ci/pipelines/jobs/ocp-nightly.sh
source "${DIR}/jobs/ocp-nightly.sh"
log::info "Calling handle_ocp_nightly"
handle_ocp_nightly
;;
*ocp*operator*nightly*)
log::info "Sourcing ocp-operator.sh"
# shellcheck source=.ci/pipelines/jobs/ocp-operator.sh
source "${DIR}/jobs/ocp-operator.sh"
log::info "Calling handle_ocp_operator"
handle_ocp_operator
;;
*osd-gcp*helm*nightly*)
log::info "Sourcing ocp-nightly.sh"
# shellcheck source=.ci/pipelines/jobs/ocp-nightly.sh
source "${DIR}/jobs/ocp-nightly.sh"
log::info "Calling handle_ocp_nightly"
handle_ocp_nightly
;;
*osd-gcp*operator*nightly*)
log::info "Sourcing ocp-operator.sh"
# shellcheck source=.ci/pipelines/jobs/ocp-operator.sh
source "${DIR}/jobs/ocp-operator.sh"
log::info "Calling handle_ocp_operator"
handle_ocp_operator
;;
*pull*ocp*helm*)
log::info "Sourcing ocp-pull.sh"
# shellcheck source=.ci/pipelines/jobs/ocp-pull.sh
source "${DIR}/jobs/ocp-pull.sh"
log::info "Calling handle_ocp_pull"
handle_ocp_pull
;;
*)
log::error "Unknown JOB_NAME pattern: $JOB_NAME"
log::warn "No matching handler found for this job type"
save_overall_result 1
;;
esac
log::info "Main script completed with result: ${OVERALL_RESULT}"
exit "${OVERALL_RESULT}"
}
main