@@ -3,164 +3,201 @@ source setup-local-dev-repos.sh
3
3
source init-tas-vars.sh
4
4
eval " $( hack/get-trustification-env.sh) "
5
5
6
+ # sed behaves differently on different platforms
7
+ # sed --version is not valid on BSD, while it is valid on the GNU version
8
+ SED_CMD () {
9
+ if sed --version > /dev/null 2>&1 ; then
10
+ # GNU version
11
+ sed -i " $@ "
12
+ else
13
+ # BSD version
14
+ sed -i " " " $@ "
15
+ fi
16
+ }
17
+
6
18
# setting secrets for the dev repos is slow
7
19
# after the first setting, you can skip this step
8
20
# warning, if your secrets are stale, do not skip this step
9
21
SKIP_SECRETS=${SKIP_SECRETS:- false}
10
22
USE_RHTAP_IMAGES=${USE_RHTAP_IMAGES:- false}
11
23
12
- if [ $SKIP_SECRETS == " true" ]; then
24
+ if [ " $SKIP_SECRETS " == " true" ]; then
13
25
echo " WARNING SKIP_SECRETS set to true, skipping configuration of secrets"
14
26
fi
15
- if [ $USE_RHTAP_IMAGES == " true" ]; then
27
+ if [ " $USE_RHTAP_IMAGES " == " true" ]; then
16
28
echo " USE_RHTAP_IMAGES is set to $USE_RHTAP_IMAGES "
17
29
echo " Note - configuration is going to use the runner images and Jenkins from redhat-appstudio"
18
30
else
19
31
echo " USE_RHTAP_IMAGES is set to $USE_RHTAP_IMAGES "
20
32
echo " Note - configuration is going to use the runner images#MY_QUAY_USER and Jenkins MY_GITHUB_USER"
21
33
fi
22
34
23
- if [ $TEST_REPO_ORG == " redhat-appstudio" ]; then
35
+ if [ " $TEST_REPO_ORG " == " redhat-appstudio" ]; then
24
36
echo " Cannot do CI testing using the redhat-appstudio org"
25
37
echo " You must create forks in your own org and set up MY_TEST_REPO_ORG (github) and MY_TEST_REPO_GITLAB_ORG"
26
38
exit
27
39
fi
28
40
29
41
function updateGitAndQuayRefs() {
30
- if [ $USE_RHTAP_IMAGES == " true" ]; then
42
+ if [ " $USE_RHTAP_IMAGES " == " true" ]; then
31
43
echo " USE_RHTAP_IMAGES is set to $USE_RHTAP_IMAGES "
32
44
echo " No images or Jenkins references patched"
33
45
else
34
46
echo " USE_RHTAP_IMAGES is set to $USE_RHTAP_IMAGES "
35
47
echo " images or Jenkins references patched to quay.io/$MY_QUAY_USER and github.com/$MY_GITHUB_USER "
36
- if [ -f $1 ]; then
37
- sed -i " s!quay.io/redhat-appstudio/rhtap-task-runner.*!quay.io/$MY_QUAY_USER /rhtap-task-runner:dev!g" $1
38
- sed -i " s!https://github.com/redhat-appstudio!https://github.com/$MY_GITHUB_USER !g" $1
39
- sed -i " s!RHTAP_Jenkins@.*'!RHTAP_Jenkins@dev'!g" $1
48
+ if [ -f " $1 " ]; then
49
+ SED_CMD " s!quay.io/redhat-appstudio/rhtap-task-runner.*!quay.io/$MY_QUAY_USER /rhtap-task-runner:dev!g" " $1 "
50
+ SED_CMD " s!https://github.com/redhat-appstudio!https://github.com/$MY_GITHUB_USER !g" " $1 "
51
+ SED_CMD " s!RHTAP_Jenkins@.*'!RHTAP_Jenkins@dev'!g" " $1 "
40
52
fi
41
53
fi
42
54
}
43
55
44
56
function updateBuild() {
45
57
REPO=$1
46
58
GITOPS_REPO_UPDATE=$2
47
- mkdir -p $REPO /rhtap
59
+ mkdir -p " $REPO /rhtap"
48
60
SETUP_ENV=$REPO /rhtap/env.sh
49
- cp rhtap/env.template.sh $SETUP_ENV
50
- sed -i " s!\$ {{ values.image }}!$IMAGE_TO_BUILD !g" $SETUP_ENV
51
- sed -i " s!\$ {{ values.dockerfile }}!Dockerfile!g" $SETUP_ENV
52
- sed -i " s!\$ {{ values.buildContext }}!.!g" $SETUP_ENV
53
- sed -i " s!\$ {{ values.repoURL }}!$GITOPS_REPO_UPDATE !g" $SETUP_ENV
61
+ cp rhtap/env.template.sh " $SETUP_ENV "
62
+ SED_CMD " s!\$ {{ values.image }}!$IMAGE_TO_BUILD !g" " $SETUP_ENV "
63
+ SED_CMD " s!\$ {{ values.dockerfile }}!Dockerfile!g" " $SETUP_ENV "
64
+ SED_CMD " s!\$ {{ values.buildContext }}!.!g" " $SETUP_ENV "
65
+ SED_CMD " s!\$ {{ values.repoURL }}!$GITOPS_REPO_UPDATE !g" " $SETUP_ENV "
54
66
# Update REKOR_HOST and TUF_MIRROR values directly
55
- sed -i ' /export REKOR_HOST=/d' $SETUP_ENV
56
- sed -i ' /export TUF_MIRROR=/d' $SETUP_ENV
57
- sed -i ' /export IGNORE_REKOR=/d' $SETUP_ENV
58
-
59
- echo " " >> $SETUP_ENV
60
- echo " export REKOR_HOST=$REKOR_HOST " >> $SETUP_ENV
61
- echo " export IGNORE_REKOR=$IGNORE_REKOR " >> $SETUP_ENV
62
- echo " export TUF_MIRROR=$TUF_MIRROR " >> $SETUP_ENV
63
- echo " # Update forced CI test $( date) " >> $SETUP_ENV
67
+ SED_CMD ' /export REKOR_HOST=/d' " $SETUP_ENV "
68
+ SED_CMD ' /export TUF_MIRROR=/d' " $SETUP_ENV "
69
+ SED_CMD ' /export IGNORE_REKOR=/d' " $SETUP_ENV "
70
+
71
+ {
72
+ echo " "
73
+ echo " export REKOR_HOST=$REKOR_HOST "
74
+ echo " export IGNORE_REKOR=$IGNORE_REKOR "
75
+ echo " export TUF_MIRROR=$TUF_MIRROR "
76
+ echo " # Update forced CI test $( date) "
77
+ } >> " $SETUP_ENV "
64
78
65
79
if [[ " $TEST_PRIVATE_REGISTRY " == " true" ]]; then
66
80
echo " WARNING Due to private repos, disabling ACS"
67
- sed -i ' /export DISABLE_ACS=/d' $SETUP_ENV
68
- echo " export DISABLE_ACS=true" >> $SETUP_ENV
81
+ SED_CMD ' /export DISABLE_ACS=/d' " $SETUP_ENV "
82
+ echo " export DISABLE_ACS=true" >> " $SETUP_ENV "
69
83
fi
70
84
71
- updateGitAndQuayRefs $SETUP_ENV
72
- cat $SETUP_ENV
85
+ updateGitAndQuayRefs " $SETUP_ENV "
86
+ cat " $SETUP_ENV "
73
87
}
74
88
75
- # create latest images for dev github and gitlab
76
- make build-push-image
77
- # update the jenkins library in the dev branch
78
- bash hack/update-jenkins-library
79
-
80
- # Repos on github and gitlab, github and jenkins
81
- # source repos are updated with the name of the corresponding GITOPS REPO for update-deployment
82
- updateBuild $BUILD $TEST_GITOPS_REPO
83
- updateBuild $GITOPS
84
- updateBuild $GITLAB_BUILD $TEST_GITOPS_GITLAB_REPO
85
- updateBuild $GITLAB_GITOPS
86
- updateBuild $JENKINS_BUILD $TEST_GITOPS_JENKINS_REPO
87
- updateBuild $JENKINS_GITOPS
88
-
89
- # source repos for copying the generated manifests
90
- GEN_SRC=generated/source-repo
91
- GEN_GITOPS=generated/gitops-template
92
-
93
- # Jenkins
94
- echo " Update Jenkins file in $JENKINS_BUILD and $JENKINS_GITOPS "
95
- echo " NEW - JENKINS USES A SEPARATE REPO FROM GITHUB ACTIONS"
96
- cp $GEN_SRC /jenkins/Jenkinsfile $JENKINS_BUILD /Jenkinsfile
97
- cp $GEN_GITOPS /jenkins/Jenkinsfile $JENKINS_GITOPS /Jenkinsfile
98
- updateGitAndQuayRefs $JENKINS_BUILD /Jenkinsfile
99
- updateGitAndQuayRefs $JENKINS_GITOPS /Jenkinsfile
100
-
101
- # Gitlab CI
102
- echo " Update .gitlab-ci.yml file in $GITLAB_BUILD and $GITLAB_GITOPS "
103
- cp $GEN_SRC /gitlabci/.gitlab-ci.yml $GITLAB_BUILD /.gitlab-ci.yml
104
- cp $GEN_GITOPS /gitlabci/.gitlab-ci.yml $GITLAB_GITOPS /.gitlab-ci.yml
105
- updateGitAndQuayRefs $GITLAB_BUILD /.gitlab-ci.yml
106
- updateGitAndQuayRefs $GITLAB_GITOPS /.gitlab-ci.yml
107
-
108
- # Github Actions
109
- echo " Update .github workflows in $BUILD and $GITOPS "
110
- cp -r $GEN_SRC /githubactions/.github $BUILD
111
- cp -r $GEN_GITOPS /githubactions/.github $GITOPS
112
- for wf in $BUILD /.github/workflows/* $GITOPS /.github/workflows/* ; do
113
- updateGitAndQuayRefs $wf
114
- done
115
-
116
89
function updateRepos() {
117
90
REPO=$1
118
91
echo
119
92
echo " Updating $REPO "
120
- pushd $REPO
93
+ pushd " $REPO "
121
94
git add .
122
95
git commit -m " Testing in CI"
123
96
git push
124
97
popd
125
98
}
126
99
127
- # set secrets and then push to repos to ensure pipeline runs are
128
- # with correct values
129
- # github
130
- if [ $SKIP_SECRETS == " false" ]; then
131
- bash hack/ghub-set-vars $TEST_BUILD_REPO
132
- bash hack/ghub-set-vars $TEST_GITOPS_REPO
133
- fi
100
+ function test_jenkins() {
101
+ echo " Testing Jenkins..."
102
+ echo
134
103
135
- updateRepos $BUILD
136
- updateRepos $GITOPS
104
+ # update the jenkins library in the dev branch
105
+ bash hack/update-jenkins-library
137
106
138
- # gitlab
139
- if [ $SKIP_SECRETS == " false" ]; then
140
- bash hack/glab-set-vars $( basename $TEST_BUILD_GITLAB_REPO )
141
- bash hack/glab-set-vars $( basename $TEST_GITOPS_GITLAB_REPO )
142
- fi
143
- updateRepos $GITLAB_BUILD
144
- updateRepos $GITLAB_GITOPS
107
+ # source repos are updated with the name of the corresponding GITOPS REPO for update-deployment
108
+ updateBuild " $JENKINS_BUILD " " $TEST_GITOPS_JENKINS_REPO "
109
+ updateBuild " $JENKINS_GITOPS "
145
110
146
- # Jenkins
147
- # note, jenkins secrets are global so set once"
148
- if [ $SKIP_SECRETS == " false" ]; then
149
- bash hack/jenkins-set-secrets
150
- fi
151
- updateRepos $JENKINS_BUILD
152
- updateRepos $JENKINS_GITOPS
153
- bash hack/jenkins-run-pipeline $( basename $TEST_BUILD_JENKINS_REPO )
154
-
155
- echo
156
- echo " Github Build and Gitops Repos"
157
- echo " Build: $TEST_BUILD_REPO "
158
- echo " Gitops: $TEST_GITOPS_REPO "
159
- echo
160
- echo " Gitlab Build and Gitops Repos"
161
- echo " Build: $TEST_BUILD_GITLAB_REPO "
162
- echo " Gitops: $TEST_GITOPS_GITLAB_REPO "
163
- echo
164
- echo " Jenkins Build and Gitops Repos"
165
- echo " Build: $TEST_BUILD_JENKINS_REPO "
166
- echo " Gitops: $TEST_GITOPS_JENKINS_REPO "
111
+ echo " Update Jenkins file in $JENKINS_BUILD and $JENKINS_GITOPS "
112
+ echo " NEW - JENKINS USES A SEPARATE REPO FROM GITHUB ACTIONS"
113
+ cp $GEN_SRC /jenkins/Jenkinsfile " $JENKINS_BUILD " /Jenkinsfile
114
+ cp $GEN_GITOPS /jenkins/Jenkinsfile " $JENKINS_GITOPS " /Jenkinsfile
115
+ updateGitAndQuayRefs " $JENKINS_BUILD " /Jenkinsfile
116
+ updateGitAndQuayRefs " $JENKINS_GITOPS " /Jenkinsfile
117
+
118
+ # note, jenkins secrets are global so set once
119
+ if [ " $SKIP_SECRETS " == " false" ]; then
120
+ bash hack/jenkins-set-secrets
121
+ fi
122
+ updateRepos " $JENKINS_BUILD "
123
+ updateRepos " $JENKINS_GITOPS "
124
+
125
+ bash hack/jenkins-run-pipeline " $( basename " $TEST_BUILD_JENKINS_REPO " ) "
126
+
127
+ echo
128
+ echo " Jenkins Build and Gitops Repos"
129
+ echo " Build: $TEST_BUILD_JENKINS_REPO "
130
+ echo " Gitops: $TEST_GITOPS_JENKINS_REPO "
131
+ }
132
+
133
+ function test_gh_actions() {
134
+ echo " Testing GitHub Actions..."
135
+ echo
136
+
137
+ # source repos are updated with the name of the corresponding GITOPS REPO for update-deployment
138
+ updateBuild " $BUILD " " $TEST_GITOPS_REPO "
139
+ updateBuild " $GITOPS "
140
+
141
+ echo " Update .github workflows in $BUILD and $GITOPS "
142
+ cp -r $GEN_SRC /githubactions/.github " $BUILD "
143
+ cp -r $GEN_GITOPS /githubactions/.github " $GITOPS "
144
+ for wf in " $BUILD " /.github/workflows/* " $GITOPS " /.github/workflows/* ; do
145
+ updateGitAndQuayRefs " $wf "
146
+ done
147
+
148
+ # set secrets and then push to repos to ensure pipeline runs are
149
+ # with correct values
150
+ # github
151
+ if [ " $SKIP_SECRETS " == " false" ]; then
152
+ bash hack/ghub-set-vars " $TEST_BUILD_REPO "
153
+ bash hack/ghub-set-vars " $TEST_GITOPS_REPO "
154
+ fi
155
+
156
+ updateRepos " $BUILD "
157
+ updateRepos " $GITOPS "
158
+
159
+ echo
160
+ echo " Github Build and Gitops Repos"
161
+ echo " Build: $TEST_BUILD_REPO "
162
+ echo " Gitops: $TEST_GITOPS_REPO "
163
+ }
164
+
165
+ function test_gitlab_ci() {
166
+ echo " Testing GitLab CI..."
167
+ echo
168
+
169
+ # source repos are updated with the name of the corresponding GITOPS REPO for update-deployment
170
+ updateBuild " $GITLAB_BUILD " " $TEST_GITOPS_GITLAB_REPO "
171
+ updateBuild " $GITLAB_GITOPS "
172
+
173
+ # Gitlab CI
174
+ echo " Update .gitlab-ci.yml file in $GITLAB_BUILD and $GITLAB_GITOPS "
175
+ cp $GEN_SRC /gitlabci/.gitlab-ci.yml " $GITLAB_BUILD " /.gitlab-ci.yml
176
+ cp $GEN_GITOPS /gitlabci/.gitlab-ci.yml " $GITLAB_GITOPS " /.gitlab-ci.yml
177
+ updateGitAndQuayRefs " $GITLAB_BUILD " /.gitlab-ci.yml
178
+ updateGitAndQuayRefs " $GITLAB_GITOPS " /.gitlab-ci.yml
179
+
180
+ # gitlab
181
+ if [ " $SKIP_SECRETS " == " false" ]; then
182
+ bash hack/glab-set-vars " $( basename " $TEST_BUILD_GITLAB_REPO " ) "
183
+ bash hack/glab-set-vars " $( basename " $TEST_GITOPS_GITLAB_REPO " ) "
184
+ fi
185
+ updateRepos " $GITLAB_BUILD "
186
+ updateRepos " $GITLAB_GITOPS "
187
+
188
+ echo " "
189
+ echo " Gitlab Build and Gitops Repos"
190
+ echo " Build: $TEST_BUILD_GITLAB_REPO "
191
+ echo " Gitops: $TEST_GITOPS_GITLAB_REPO "
192
+ }
193
+
194
+ # create latest images for dev github and gitlab
195
+ make build-push-image
196
+
197
+ # source repos for copying the generated manifests
198
+ GEN_SRC=generated/source-repo
199
+ GEN_GITOPS=generated/gitops-template
200
+
201
+ test_gh_actions
202
+ test_gitlab_ci
203
+ test_jenkins
0 commit comments