1
1
#! /usr/bin/env bash
2
- # shellcheck disable=SC2038
2
+ # shellcheck disable=SC2038,SC2153
3
3
# Helper script for GitHub Actions CI, used from e2e tests.
4
4
set -exufo pipefail
5
5
6
6
create_pac_github_app_secret () {
7
- local app_private_key=" ${1} "
8
- local application_id=" ${2} "
9
- local webhook_secret=" ${3} "
7
+ # Read from environment variables instead of arguments
8
+ local app_private_key=" ${PAC_GITHUB_PRIVATE_KEY} "
9
+ local application_id=" ${PAC_GITHUB_APPLICATION_ID} "
10
+ local webhook_secret=" ${PAC_WEBHOOK_SECRET} "
11
+
10
12
kubectl delete secret -n pipelines-as-code pipelines-as-code-secret || true
11
13
kubectl -n pipelines-as-code create secret generic pipelines-as-code-secret \
12
14
--from-literal github-private-key=" ${app_private_key} " \
@@ -32,9 +34,10 @@ create_pac_github_app_secret() {
32
34
}
33
35
34
36
create_second_github_app_controller_on_ghe () {
35
- local test_github_second_smee_url=" ${1} "
36
- local test_github_second_private_key=" ${2} "
37
- local test_github_second_webhook_secret=" ${3} "
37
+ # Read from environment variables instead of arguments
38
+ local test_github_second_smee_url=" ${TEST_GITHUB_SECOND_SMEE_URL} "
39
+ local test_github_second_private_key=" ${TEST_GITHUB_SECOND_PRIVATE_KEY} "
40
+ local test_github_second_webhook_secret=" ${TEST_GITHUB_SECOND_WEBHOOK_SECRET} "
38
41
39
42
if [[ -n " $( type -p apt) " ]]; then
40
43
sudo apt update &&
@@ -80,62 +83,7 @@ get_tests() {
80
83
81
84
run_e2e_tests () {
82
85
set +x
83
- target=" ${1} "
84
- bitbucket_cloud_token=" ${2} "
85
- webhook_secret=" ${3} "
86
- test_gitea_smeeurl=" ${4} "
87
- installation_id=" ${5} "
88
- gh_apps_token=" ${6} "
89
- test_github_second_token=" ${7} "
90
- gitlab_token=" ${8} "
91
- bitbucket_server_token=" ${9} "
92
- bitbucket_server_api_url=" ${10} "
93
- bitbucket_server_webhook_secret=" ${11} "
94
-
95
- # Nothing specific to webhook here it just that repo is private in that org and that's what we want to test
96
- export TEST_GITHUB_PRIVATE_TASK_URL=" https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml"
97
- export TEST_GITHUB_PRIVATE_TASK_NAME=" task-remote"
98
-
99
- export TEST_BITBUCKET_CLOUD_API_URL=https://api.bitbucket.org/2.0
100
- export TEST_BITBUCKET_CLOUD_E2E_REPOSITORY=cboudjna/pac-e2e-tests
101
- export TEST_BITBUCKET_CLOUD_TOKEN=${bitbucket_cloud_token}
102
- export TEST_BITBUCKET_CLOUD_USER=cboudjna
103
-
104
- export TEST_EL_URL=" http://${CONTROLLER_DOMAIN_URL} "
105
- export TEST_EL_WEBHOOK_SECRET=" ${webhook_secret} "
106
-
107
- export TEST_GITEA_API_URL=" http://localhost:3000"
108
- # # This is the URL used to forward requests from the webhook to the paac controller
109
- # # badly named!
110
- export TEST_GITEA_SMEEURL=" ${test_gitea_smeeurl} "
111
- export TEST_GITEA_USERNAME=pac
112
- export TEST_GITEA_PASSWORD=pac
113
- export TEST_GITEA_REPO_OWNER=pac/pac
114
-
115
- export TEST_GITHUB_API_URL=api.github.com
116
- export TEST_GITHUB_REPO_INSTALLATION_ID=" ${installation_id} "
117
- export TEST_GITHUB_REPO_OWNER_GITHUBAPP=openshift-pipelines/pipelines-as-code-e2e-tests
118
- export TEST_GITHUB_REPO_OWNER_WEBHOOK=openshift-pipelines/pipelines-as-code-e2e-tests-webhook
119
- export TEST_GITHUB_TOKEN=" ${gh_apps_token} "
120
-
121
- export TEST_GITHUB_SECOND_API_URL=ghe.pipelinesascode.com
122
- export TEST_GITHUB_SECOND_EL_URL=http://ghe.paac-127-0-0-1.nip.io
123
- export TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP=pipelines-as-code/e2e
124
- # TODO: webhook repo for second github
125
- # export TEST_GITHUB_SECOND_REPO_OWNER_WEBHOOK=openshift-pipelines/pipelines-as-code-e2e-tests-webhook
126
- export TEST_GITHUB_SECOND_REPO_INSTALLATION_ID=1
127
- export TEST_GITHUB_SECOND_TOKEN=" ${test_github_second_token} "
128
-
129
- export TEST_GITLAB_API_URL=" https://gitlab.com"
130
- export TEST_GITLAB_PROJECT_ID=" 34405323"
131
- export TEST_GITLAB_TOKEN=${gitlab_token}
132
- # https://gitlab.com/gitlab-com/alliances/ibm-red-hat/sandbox/openshift-pipelines/pac-e2e-tests
133
-
134
- export TEST_BITBUCKET_SERVER_TOKEN=" ${bitbucket_server_token} "
135
- export TEST_BITBUCKET_SERVER_API_URL=" ${bitbucket_server_api_url} "
136
- export TEST_BITBUCKET_SERVER_WEBHOOK_SECRET=" ${bitbucket_server_webhook_secret} "
137
- export TEST_BITBUCKET_SERVER_USER=" pipelines"
138
- export TEST_BITBUCKET_SERVER_E2E_REPOSITORY=" PAC/pac-e2e-tests"
86
+ target=" ${TEST_PROVIDER} "
139
87
140
88
mapfile -t tests < <( get_tests " ${target} " )
141
89
echo " About to run ${# tests[@]} tests: ${tests[*]} "
@@ -144,8 +92,10 @@ run_e2e_tests() {
144
92
}
145
93
146
94
collect_logs () {
147
- test_gitea_smee_url=" ${1} "
148
- github_ghe_smee_url=" ${2} "
95
+ # Read from environment variables
96
+ local test_gitea_smee_url=" ${TEST_GITEA_SMEEURL} "
97
+ local github_ghe_smee_url=" ${TEST_GITHUB_SECOND_SMEE_URL} "
98
+
149
99
mkdir -p /tmp/logs
150
100
kind export logs /tmp/logs
151
101
[[ -d /tmp/gosmee-replay ]] && cp -a /tmp/gosmee-replay /tmp/logs/
@@ -186,36 +136,42 @@ detect_panic() {
186
136
187
137
help () {
188
138
cat << EOF
189
- Usage: $0 <command> [args]
139
+ Usage: $0 <command>
190
140
191
141
Shell script to run e2e tests from GitHub Actions CI
192
142
193
- create_pac_github_app_secret <application_id> <app_private_key> <webhook_secret>
143
+ Required environment variables depend on the command being executed.
144
+
145
+ create_pac_github_app_secret
194
146
Create the secret for the github app
147
+ Required env vars: PAC_GITHUB_PRIVATE_KEY, PAC_GITHUB_APPLICATION_ID, PAC_WEBHOOK_SECRET
195
148
196
- create_second_github_app_controller_on_ghe <test_github_second_smee_url> <test_github_second_private_key> <test_github_second_webhook_secret>
149
+ create_second_github_app_controller_on_ghe
197
150
Create the second controller on GHE
151
+ Required env vars: TEST_GITHUB_SECOND_SMEE_URL, TEST_GITHUB_SECOND_PRIVATE_KEY, TEST_GITHUB_SECOND_WEBHOOK_SECRET
198
152
199
- run_e2e_tests <target> <bitbucket_cloud_token> <webhook_secret> <test_gitea_smeeurl> <installation_id> <gh_apps_token> <test_github_second_token> <gitlab_token> <bitbucket_datacenter_token> <bitbucket_datacenter_api_url> <bitbucket_datacenter_webhook_secret>
153
+ run_e2e_tests
200
154
Run the e2e tests
155
+ Required env vars: TEST_PROVIDER plus many test-specific environment variables
201
156
202
157
collect_logs
203
158
Collect logs from the cluster
159
+ Required env vars: TEST_GITEA_SMEEURL, TEST_GITHUB_SECOND_SMEE_URL
204
160
EOF
205
161
}
206
162
207
163
case ${1-" " } in
208
164
create_pac_github_app_secret)
209
- create_pac_github_app_secret " ${2} " " ${3} " " ${4} "
165
+ create_pac_github_app_secret
210
166
;;
211
167
create_second_github_app_controller_on_ghe)
212
- create_second_github_app_controller_on_ghe " ${2} " " ${3} " " ${4} "
168
+ create_second_github_app_controller_on_ghe
213
169
;;
214
170
run_e2e_tests)
215
- run_e2e_tests " ${2} " " ${3} " " ${4} " " ${5} " " ${6} " " ${7} " " ${8} " " ${9} " " ${10} " " ${11} " " ${12} "
171
+ run_e2e_tests
216
172
;;
217
173
collect_logs)
218
- collect_logs " ${2} " " ${3} "
174
+ collect_logs
219
175
;;
220
176
help)
221
177
help
0 commit comments