Skip to content

Commit d9fd836

Browse files
authored
Merge pull request #311 from fanzhangio/ci
Speed up tests by caching deps
2 parents 01a605a + 7fed477 commit d9fd836

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

common.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,21 @@ function setup_envs {
146146
export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl
147147
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
148148
export TEST_ASSET_ETCD=/tmp/kubebuilder/bin/etcd
149+
export TEST_DEP=/tmp/kubebuilder/init_project
150+
}
151+
152+
function cache_dep {
153+
header_text "caching inited projects"
154+
if [ -d "$TEST_DEP" ]; then
155+
rm -rf "$TEST_DEP"
156+
fi
157+
mkdir -p "$TEST_DEP"
158+
cp -r $PWD/* $TEST_DEP
159+
}
160+
161+
function dump_cache {
162+
header_text "dump cached project and deps"
163+
if [ -d "$TEST_DEP" ]; then
164+
cp -r $TEST_DEP/* .
165+
fi
149166
}

testv1.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ function test_init_project {
2323
header_text "performing init project"
2424
kubebuilder init --project-version=v1 --domain example.com <<< "y"
2525
make
26+
cache_dep
2627
}
2728

29+
30+
2831
function test_init_project_manual_dep_ensure {
2932
header_text "performing init project w/o dep ensure"
3033
kubebuilder init --project-version=v1 --domain example.com <<< "n"
@@ -101,27 +104,27 @@ prepare_testdir_under_gopath
101104
test_init_project_manual_dep_ensure
102105

103106
prepare_testdir_under_gopath
104-
test_init_project
107+
dump_cache
105108
test_create_api_controller
106109

107110
prepare_testdir_under_gopath
108-
test_init_project
111+
dump_cache
109112
test_create_namespaced_api_controller
110113

111114
prepare_testdir_under_gopath
112-
test_init_project
115+
dump_cache
113116
test_create_api_only
114117

115118
prepare_testdir_under_gopath
116-
test_init_project
119+
dump_cache
117120
test_create_namespaced_api_only
118121

119122
prepare_testdir_under_gopath
120-
test_init_project
123+
dump_cache
121124
test_create_coretype_controller
122125

123126
prepare_testdir_under_gopath
124-
test_init_project
127+
dump_cache
125128
test_create_namespaced_coretype_controller
126129

127130
exit $rc

0 commit comments

Comments
 (0)