@@ -40,26 +40,28 @@ func TestMakeGitCloneTask(t *testing.T) {
4040 Workspaces : []pipelinev1.WorkspacePipelineTaskBinding {
4141 {Name : "source" , Workspace : workspaceName },
4242 },
43- TaskSpec : & pipelinev1.TaskSpec {
44- Workspaces : []pipelinev1.WorkspaceDeclaration {
45- {
46- Name : "source" ,
43+ TaskSpec : & pipelinev1.EmbeddedTask {
44+ TaskSpec : pipelinev1.TaskSpec {
45+ Workspaces : []pipelinev1.WorkspaceDeclaration {
46+ {
47+ Name : "source" ,
48+ },
4749 },
48- },
49- Steps : []pipelinev1. Step {
50- {
51- Container : corev1. Container {
52- Name : " git-clone " ,
53- Image : "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/ git-init" ,
54- Command : []string { "/ko-app/git-init" , "-url" , testRepoURL , "-revision" , "master" , "-path" , workspaceSourcePath },
55- Env : []corev1. EnvVar {
56- {
57- Name : "CI_PROJECT_DIR " ,
58- Value : "$(workspaces.source.path)" ,
59- },
60- {
61- Name : "TEKTON_RESOURCE_NAME " ,
62- Value : "tekton-ci-git-clone" ,
50+ Steps : []pipelinev1. Step {
51+ {
52+ Container : corev1. Container {
53+ Name : "git-clone" ,
54+ Image : "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/ git-init " ,
55+ Command : [] string { "/ko-app/ git-init", "-url" , testRepoURL , "-revision" , "master" , "-path" , workspaceSourcePath } ,
56+ Env : []corev1. EnvVar {
57+ {
58+ Name : "CI_PROJECT_DIR" ,
59+ Value : "$(workspaces.source.path) " ,
60+ } ,
61+ {
62+ Name : "TEKTON_RESOURCE_NAME" ,
63+ Value : "tekton-ci-git-clone " ,
64+ } ,
6365 },
6466 },
6567 },
@@ -91,21 +93,23 @@ func TestMakeScriptTask(t *testing.T) {
9193 Workspaces : []pipelinev1.WorkspacePipelineTaskBinding {
9294 {Name : "source" , Workspace : workspaceName },
9395 },
94- TaskSpec : & pipelinev1.TaskSpec {
95- Workspaces : []pipelinev1.WorkspaceDeclaration {
96- {
97- Name : "source" ,
98- },
99- },
100- Steps : []pipelinev1.Step {
101- {
102- Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "mkdir -p $GOPATH/src/$(dirname $REPO_NAME)" }, env , workspaceSourcePath ),
103- },
104- {
105- Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME" }, env , workspaceSourcePath ),
96+ TaskSpec : & pipelinev1.EmbeddedTask {
97+ TaskSpec : pipelinev1.TaskSpec {
98+ Workspaces : []pipelinev1.WorkspaceDeclaration {
99+ {
100+ Name : "source" ,
101+ },
106102 },
107- {
108- Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "cd $GOPATH/src/$REPO_NAME" }, env , workspaceSourcePath ),
103+ Steps : []pipelinev1.Step {
104+ {
105+ Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "mkdir -p $GOPATH/src/$(dirname $REPO_NAME)" }, env , workspaceSourcePath ),
106+ },
107+ {
108+ Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME" }, env , workspaceSourcePath ),
109+ },
110+ {
111+ Container : container ("" , "golang:latest" , "sh" , []string {"-c" , "cd $GOPATH/src/$REPO_NAME" }, env , workspaceSourcePath ),
112+ },
109113 },
110114 },
111115 },
@@ -182,50 +186,54 @@ func TestConvert(t *testing.T) {
182186 makeScriptTask (beforeStepTaskName , []string {gitCloneTaskName }, testEnv , p .Image , p .BeforeScript ),
183187 {
184188 Name : "format-stage-test" ,
185- TaskSpec : & pipelinev1.TaskSpec {
186- Steps : []pipelinev1.Step {
187- {
188- Container : corev1.Container {
189- Image : "golang:latest" ,
190- Command : []string {"sh" },
191- Args : []string {"-c" , "go fmt $(go list ./... | grep -v /vendor/)" },
192- WorkingDir : "$(workspaces.source.path)" ,
193- Env : testEnv ,
189+ TaskSpec : & pipelinev1.EmbeddedTask {
190+ TaskSpec : pipelinev1.TaskSpec {
191+ Steps : []pipelinev1.Step {
192+ {
193+ Container : corev1.Container {
194+ Image : "golang:latest" ,
195+ Command : []string {"sh" },
196+ Args : []string {"-c" , "go fmt $(go list ./... | grep -v /vendor/)" },
197+ WorkingDir : "$(workspaces.source.path)" ,
198+ Env : testEnv ,
199+ },
194200 },
195- },
196- {
197- Container : corev1. Container {
198- Image : "golang:latest" ,
199- Command : []string {"sh " },
200- Args : [] string { "-c" , "go vet $(go list ./... | grep -v /vendor/)" } ,
201- WorkingDir : "$(workspaces.source.path)" ,
202- Env : testEnv ,
201+ {
202+ Container : corev1. Container {
203+ Image : "golang:latest" ,
204+ Command : [] string { "sh" } ,
205+ Args : []string {"-c" , "go vet $(go list ./... | grep -v /vendor/) " },
206+ WorkingDir : "$(workspaces.source.path)" ,
207+ Env : testEnv ,
208+ } ,
203209 },
204- },
205- {
206- Container : corev1. Container {
207- Image : "golang:latest" ,
208- Command : []string {"sh " },
209- Args : [] string { "-c" , "go test -race $(go list ./... | grep -v /vendor/)" } ,
210- WorkingDir : "$(workspaces.source.path)" ,
211- Env : testEnv ,
210+ {
211+ Container : corev1. Container {
212+ Image : "golang:latest" ,
213+ Command : [] string { "sh" } ,
214+ Args : []string {"-c" , "go test -race $(go list ./... | grep -v /vendor/) " },
215+ WorkingDir : "$(workspaces.source.path)" ,
216+ Env : testEnv ,
217+ } ,
212218 },
213219 },
220+ Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
214221 },
215- Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
216222 },
217223 RunAfter : []string {beforeStepTaskName },
218224 Workspaces : []pipelinev1.WorkspacePipelineTaskBinding {{Name : "source" , Workspace : "git-checkout" }},
219225 },
220226 {
221227 Name : "compile-stage-build" ,
222- TaskSpec : & pipelinev1.TaskSpec {
223- Steps : []pipelinev1.Step {
224- {
225- Container : container ("" , "test-compile-image" , "sh" , []string {"-c" , `go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary` }, testEnv , workspaceSourcePath ),
228+ TaskSpec : & pipelinev1.EmbeddedTask {
229+ TaskSpec : pipelinev1.TaskSpec {
230+ Steps : []pipelinev1.Step {
231+ {
232+ Container : container ("" , "test-compile-image" , "sh" , []string {"-c" , `go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary` }, testEnv , workspaceSourcePath ),
233+ },
226234 },
235+ Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
227236 },
228- Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
229237 },
230238 RunAfter : []string {"format-stage-test" },
231239 Workspaces : []pipelinev1.WorkspacePipelineTaskBinding {{Name : "source" , Workspace : "git-checkout" }},
@@ -234,15 +242,17 @@ func TestConvert(t *testing.T) {
234242 Name : "compile-archiver" ,
235243 RunAfter : []string {"format-stage-test" },
236244 Workspaces : []pipelinev1.WorkspacePipelineTaskBinding {{Name : "source" , Workspace : "git-checkout" }},
237- TaskSpec : & pipelinev1.TaskSpec {
238- Steps : []pipelinev1.Step {
239- {
240- Container : container ("compile-archiver-archiver" , testArchiverImage , "" ,
241- []string {"archive" , "--bucket-url" ,
242- testArchiveURL , "my-test-binary" }, testEnv , workspaceSourcePath ),
245+ TaskSpec : & pipelinev1.EmbeddedTask {
246+ TaskSpec : pipelinev1.TaskSpec {
247+ Steps : []pipelinev1.Step {
248+ {
249+ Container : container ("compile-archiver-archiver" , testArchiverImage , "" ,
250+ []string {"archive" , "--bucket-url" ,
251+ testArchiveURL , "my-test-binary" }, testEnv , workspaceSourcePath ),
252+ },
243253 },
254+ Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
244255 },
245- Workspaces : []pipelinev1.WorkspaceDeclaration {{Name : "source" }},
246256 },
247257 },
248258 makeScriptTask (afterStepTaskName , []string {"compile-archiver" }, testEnv , p .Image , p .AfterScript ),
0 commit comments