Skip to content

Commit

Permalink
Clean up YAML tests
Browse files Browse the repository at this point in the history
- Use generateName where appropriate in TaskRuns; this makes it easier
  to re-run them multiple times, and we should probably recommend this
  more widely.
- Create YAML resources instead of applying them (this is required to
  support generateName)
- Rename files to remove unnecessary "taskrun-" prefix.
- Rename TaskRuns to remove unnecessary "test-" prefix, and in general
  to match the name of the file -- this should help identifying the file
  that contains a failed TaskRun.
  • Loading branch information
imjasonh committed Sep 24, 2019
1 parent c3db348 commit 3932256
Show file tree
Hide file tree
Showing 37 changed files with 341 additions and 441 deletions.
2 changes: 1 addition & 1 deletion examples/taskruns/build-gcs-targz.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: build-gcs-targz
generateName: build-gcs-targz-
spec:
taskSpec:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion examples/taskruns/build-gcs-zip.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: build-gcs-zip
generateName: build-gcs-zip-
spec:
taskSpec:
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: build-push-run
name: build-push-kaniko
spec:
taskRef:
name: build-push-kaniko
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: v1
kind: Service
metadata:
Expand Down
17 changes: 17 additions & 0 deletions examples/taskruns/clustertask.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: tekton.dev/v1alpha1
kind: ClusterTask
metadata:
name: clustertask
spec:
steps:
- image: ubuntu
command: ['echo', 'hello']
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: clustertask-
spec:
taskRef:
name: clustertask
kind: ClusterTask
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -9,7 +8,7 @@ data:
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-configmap
generateName: configmap-
spec:
taskSpec:
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-custom-env-vars
generateName: custom-env-
spec:
taskSpec:
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-custom-volume
generateName: custom-volume-
spec:
taskSpec:
steps:
Expand All @@ -22,4 +21,4 @@ spec:
mountPath: /short/and/stout
volumes:
- name: custom
emptyDir: {}
emptyDir: {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: dind-sidecar-taskrun-1
generateName: dind-sidecar-
spec:
taskSpec:
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
apiVersion: v1
kind: Secret
metadata:
name: test-docker-basic
name: docker-basic
annotations:
tekton.dev/docker-0: https://us.gcr.io
tekton.dev/docker-1: https://eu.gcr.io
Expand All @@ -23,18 +22,18 @@ data:
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-robot-docker-basic
name: robot-docker-basic
secrets:
- name: test-docker-basic
- name: docker-basic
imagePullSecrets:
- name: test-docker-basic
- name: docker-basic
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-taskrun-with-serviceaccount-docker-basic
name: docker-creds
spec:
serviceAccount: test-robot-docker-basic
serviceAccount: robot-docker-basic
taskSpec:
steps:
- name: test
Expand Down
2 changes: 1 addition & 1 deletion examples/taskruns/gcs-resource.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: gcs-resource
generateName: gcs-resource-
spec:
taskSpec:
inputs:
Expand Down
27 changes: 0 additions & 27 deletions examples/taskruns/git-resource-spec-taskrun.yaml

This file was deleted.

74 changes: 74 additions & 0 deletions examples/taskruns/git-resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: git-resource-tag-
spec:
taskSpec:
inputs:
resources:
- name: skaffold
type: git
steps:
- name: read
image: ubuntu
command: ['cat', '/workspace/skaffold/README.md']
inputs:
resources:
- name: skaffold
resourceSpec:
type: git
params:
- name: revision
value: v0.32.0
- name: url
value: https://github.com/GoogleContainerTools/skaffold
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: git-resource-branch-
spec:
taskSpec:
inputs:
resources:
- name: skaffold
type: git
steps:
- name: read
image: ubuntu
command: ['cat', '/workspace/skaffold/README.md']
inputs:
resources:
- name: skaffold
resourceSpec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/GoogleContainerTools/skaffold
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: git-resource-ref-
spec:
taskSpec:
inputs:
resources:
- name: skaffold
type: git
steps:
- name: read
image: ubuntu
command: ['cat', '/workspace/skaffold/README.md']
inputs:
resources:
- name: skaffold
resourceSpec:
type: git
params:
- name: revision
value: pull/2932/head
- name: url
value: https://github.com/GoogleContainerTools/skaffold
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
apiVersion: v1
kind: Secret
metadata:
name: test-git-ssh
name: git-ssh
annotations:
tekton.dev/git-0: github.com
type: kubernetes.io/ssh-auth
Expand All @@ -18,16 +17,16 @@ data:
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-robot-git-ssh
name: robot-git-ssh
secrets:
- name: test-git-ssh
- name: git-ssh
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-taskrun-with-serviceaccount-git-ssh
name: git-ssh-creds
spec:
serviceAccount: test-robot-git-ssh
serviceAccount: robot-git-ssh
inputs:
resources:
- name: gitssh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-git-volume
generateName: git-volume-
spec:
taskSpec:
steps:
Expand All @@ -15,6 +15,7 @@ spec:

volumes:
- name: source
gitRepo:
gitRepo: # https://kubernetes.io/docs/concepts/storage/volumes/#gitrepo
# gitRepo is deprecated.
repository: "https://github.com/bazelbuild/rules_docker.git"
revision: "3caddbe7f75fde6afb2e2c63654b5bbeeeedf2ac"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-home-is-set
generateName: home-is-set-
spec:
taskSpec:
steps:
Expand All @@ -10,4 +10,4 @@ spec:
command: ['bash']
args:
- '-c'
- '[[ $HOME == /builder/home ]]'
- '[[ $HOME == /builder/home ]]'
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: test-home-volume
labels:
expect: succeeded
generateName: home-volume-
spec:
taskSpec:
steps:
Expand All @@ -25,4 +23,4 @@ spec:
mountPath: /builder/home
volumes:
- name: empty
emptyDir: {}
emptyDir: {}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ imagePullSecrets:
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: pull-private-image-run
generateName: pull-private-image-
spec:
serviceAccount: test-build-robot
taskSpec:
Expand Down
36 changes: 36 additions & 0 deletions examples/taskruns/pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: pullrequest-
spec:
inputs:
resources:
- name: pr
resourceSpec:
type: pullRequest
params:
- name: url
# I just picked a random PR. The first couple didn't have any interesting comments or labels.
value: https://github.com/tektoncd/pipeline/pull/100
taskSpec:
inputs:
resources:
- name: pr
type: pullRequest
steps:
- name: dump-workspace
image: ubuntu
command: ["sh"]
args: ["-c", "find $(inputs.resources.pr.path)/* -type f | xargs tail -n +1"]
- name: ensure-approved
image: ubuntu
command: ["/bin/bash"]
args:
- -c
- |
if [ -f "$(inputs.resources.pr.path)/labels/approved" ]; then
echo "PR is approved!"
else
echo "PR is not approved!"
exit 1
fi
Loading

0 comments on commit 3932256

Please sign in to comment.