Skip to content

Commit 062cfe1

Browse files
committed
Add cleanup and test tekton tasks
1 parent cbc4598 commit 062cfe1

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.tekton/tasks.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Task
3+
metadata:
4+
name: cleanup
5+
spec:
6+
description: This task will clean up a workspace by deleting all of the files.
7+
workspaces:
8+
- name: source
9+
steps:
10+
- name: remove
11+
image: alpine:3
12+
env:
13+
- name: WORKSPACE_SOURCE_PATH
14+
value: $(workspaces.source.path)
15+
workingDir: $(workspaces.source.path)
16+
securityContext:
17+
runAsNonRoot: false
18+
runAsUser: 0
19+
script: |
20+
#!/usr/bin/env sh
21+
set -eu
22+
echo "Removing all files from ${WORKSPACE_SOURCE_PATH} ..."
23+
# Delete any existing contents of the directory if it exists.
24+
#
25+
# We don't just "rm -rf ${WORKSPACE_SOURCE_PATH}" because ${WORKSPACE_SOURCE_PATH} might be "/"
26+
# or the root of a mounted volume.
27+
if [ -d "${WORKSPACE_SOURCE_PATH}" ] ; then
28+
# Delete non-hidden files and directories
29+
rm -rf "${WORKSPACE_SOURCE_PATH:?}"/*
30+
# Delete files and directories starting with . but excluding ..
31+
rm -rf "${WORKSPACE_SOURCE_PATH}"/.[!.]*
32+
# Delete files and directories starting with .. plus any other character
33+
rm -rf "${WORKSPACE_SOURCE_PATH}"/..?*
34+
fi
35+
36+
---
37+
38+
apiVersion: tekton.dev/v1beta1
39+
kind: Task
40+
metadata:
41+
name: nose
42+
spec:
43+
params:
44+
- name: args
45+
description: Arguments to pass to nose
46+
type: string
47+
default: "-v"
48+
workspaces:
49+
- name: source
50+
steps:
51+
- name: nosetests
52+
image: python:3.9-slim
53+
workingDir: $(workspaces.source.path)
54+
script: |
55+
#!/bin/bash
56+
set -e
57+
pip install -r requirements.txt
58+
nosetests $(params.args)

0 commit comments

Comments
 (0)