github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.tekton/ci-build/task.yaml (about) 1 # (c) Copyright IBM Corp. 2024 2 3 --- 4 apiVersion: tekton.dev/v1 5 kind: Task 6 metadata: 7 name: go-tracer-clone-task 8 spec: 9 params: 10 - name: revision 11 type: string 12 - name: SHA 13 type: string 14 workspaces: 15 - name: task-pvc 16 mountPath: /workspace 17 steps: 18 - name: clone 19 image: alpine/git@sha256:0cfba46c00b715c97df21cfa8854dfe73e7d606b95332d35637a6a6945acc341 20 workingDir: /workspace/ 21 script: | 22 #!/bin/sh 23 echo "Cloning repo!" 24 git clone --depth 1 -b $(params.revision) https://github.com/instana/go-sensor && cd /workspace/go-sensor && git checkout $(params.SHA) && git status 25 26 --- 27 apiVersion: tekton.dev/v1 28 kind: Task 29 metadata: 30 name: go-tracer-cache-restore-task 31 spec: 32 params: 33 - name: imageTag 34 type: string 35 workspaces: 36 - name: task-pvc 37 mountPath: /workspace 38 - name: cache-pvc 39 mountPath: /cache 40 steps: 41 - name: cache-restore 42 image: alpinelinux/rsyncd@sha256:6f8b68b4b15a8e6b0abfb7db0e2a765849c77a6104ac248810ff9a9fb97996fb 43 env: 44 - name: GO_VERSION 45 value: $(params.imageTag) 46 workingDir: /workspace/ 47 script: | 48 #!/bin/sh 49 echo "Creating Go path!" 50 mkdir -p ./go/pkg/mod 51 52 echo "Restoring cache!" 53 rsync -ah --progress /cache/${GO_VERSION}/mod/ ./go/pkg/mod || ls -lah ./go/pkg/mod 54 55 56 --- 57 apiVersion: tekton.dev/v1 58 kind: Task 59 metadata: 60 name: go-tracer-cache-update-task 61 spec: 62 params: 63 - name: imageTag 64 type: string 65 workspaces: 66 - name: task-pvc 67 mountPath: /workspace 68 - name: cache-pvc 69 mountPath: /cache 70 steps: 71 - name: cache-update 72 image: alpinelinux/rsyncd@sha256:6f8b68b4b15a8e6b0abfb7db0e2a765849c77a6104ac248810ff9a9fb97996fb 73 env: 74 - name: GO_VERSION 75 value: $(params.imageTag) 76 workingDir: /workspace/ 77 script: | 78 #!/bin/sh 79 echo "Sync cache path!" 80 mkdir -p /cache/${GO_VERSION}/mod 81 echo "Updating cache!" 82 rsync -ah --progress ./go/pkg/mod/ /cache/${GO_VERSION}/mod 83 ls -lah /cache/${GO_VERSION}/mod 84 85 --- 86 apiVersion: tekton.dev/v1 87 kind: Task 88 metadata: 89 name: go-tracer-unittest-task 90 spec: 91 params: 92 - name: imageTag 93 type: string 94 - name: excludeDirs 95 type: string 96 workspaces: 97 - name: task-pvc 98 mountPath: /workspace 99 - name: cache-pvc 100 mountPath: /cache 101 102 steps: 103 - name: unit-test 104 image: golang:$(params.imageTag) 105 env: 106 - name: GO_VERSION 107 value: $(params.imageTag) 108 - name: RUN_LINTER 109 # TODO : Change this to "yes" when the existing issues with linting are resolved. 110 value: "no" 111 - name: GO111MODULE 112 value: "auto" 113 - name: VENDOR_DEPS 114 value: "no" 115 - name: EXCLUDE_DIRS 116 value: $(params.excludeDirs) 117 - name: GOPATH 118 value: "/workspace/go" 119 workingDir: /workspace/go-sensor/ 120 script: | 121 #!/bin/sh 122 echo "Running unit tests!" 123 make test 124 if [ $? -ne 0 ]; then 125 echo "Unit tests failed. Retrying..." 126 make test 127 fi 128 129 --- 130 apiVersion: tekton.dev/v1 131 kind: Task 132 metadata: 133 name: go-tracer-gofmt-task 134 spec: 135 params: 136 - name: imageTag 137 type: string 138 - name: excludeDirs 139 type: string 140 workspaces: 141 - name: task-pvc 142 mountPath: /workspace 143 steps: 144 - name: go-fmt 145 image: golang:$(params.imageTag) 146 env: 147 - name: EXCLUDE_DIRS 148 value: $(params.excludeDirs) 149 workingDir: /workspace/go-sensor/ 150 script: | 151 #!/bin/sh 152 echo "Running go fmt check!" 153 make fmtcheck 154 155 --- 156 apiVersion: tekton.dev/v1 157 kind: Task 158 metadata: 159 name: go-tracer-goimports-task 160 spec: 161 params: 162 - name: imageTag 163 type: string 164 - name: excludeDirs 165 type: string 166 workspaces: 167 - name: task-pvc 168 mountPath: /workspace 169 steps: 170 - name: go-imports 171 image: golang:$(params.imageTag) 172 env: 173 - name: EXCLUDE_DIRS 174 value: $(params.excludeDirs) 175 workingDir: /workspace/go-sensor/ 176 script: | 177 #!/bin/sh 178 echo "Installing go imports!" 179 go install golang.org/x/tools/cmd/goimports@latest || true 180 echo "Running import check" 181 make importcheck 182 183 184 --- 185 apiVersion: tekton.dev/v1 186 kind: Task 187 metadata: 188 name: go-tracer-integration-common-task 189 spec: 190 sidecars: 191 - name: postgresql 192 image: postgres:14 193 env: 194 - name: POSTGRES_USER 195 value: "postgres" 196 - name: POSTGRES_DB 197 value: "postgres" 198 - name: POSTGRES_PASSWORD 199 value: "mysecretpassword" 200 params: 201 - name: imageTag 202 type: string 203 - name: excludeDirs 204 type: string 205 workspaces: 206 - name: task-pvc 207 mountPath: /workspace 208 - name: cache-pvc 209 mountPath: /cache 210 steps: 211 - name: integration-test-common 212 image: golang:$(params.imageTag) 213 env: 214 - name: GO_VERSION 215 value: $(params.imageTag) 216 - name: GO111MODULE 217 value: "auto" 218 - name: VENDOR_DEPS 219 value: "no" 220 - name: COSMOS_CONNECTION_URL 221 valueFrom: 222 secretKeyRef: 223 name: "cosmos-conn-url" 224 key: "connUrl" 225 - name: COSMOS_KEY 226 valueFrom: 227 secretKeyRef: 228 name: "cosmos-conn-key" 229 key: "connKey" 230 - name: EXCLUDE_DIRS 231 value: $(params.excludeDirs) 232 - name: GOPATH 233 value: "/workspace/go" 234 workingDir: /workspace/go-sensor/ 235 script: | 236 #!/bin/sh 237 echo "Running integration tests!" 238 make integration-common 239 if [ $? -ne 0 ]; then 240 echo "Common integration tests failed. Retrying..." 241 make integration-common 242 fi 243 244 --- 245 apiVersion: tekton.dev/v1 246 kind: Task 247 metadata: 248 name: go-tracer-integration-couchbase-task 249 spec: 250 sidecars: 251 - name: couchbase 252 image: couchbase/server-sandbox:7.2.4 253 readinessProbe: 254 httpGet: 255 path: /ui/index.html 256 port: 8091 257 initialDelaySeconds: 60 258 params: 259 - name: imageTag 260 type: string 261 - name: excludeDirs 262 type: string 263 workspaces: 264 - name: task-pvc 265 mountPath: /workspace 266 - name: cache-pvc 267 mountPath: /cache 268 steps: 269 - name: integration-test-couchbase 270 image: golang:$(params.imageTag) 271 env: 272 - name: GO_VERSION 273 value: $(params.imageTag) 274 - name: GO111MODULE 275 value: "auto" 276 - name: VENDOR_DEPS 277 value: "no" 278 - name: EXCLUDE_DIRS 279 value: $(params.excludeDirs) 280 - name: GOPATH 281 value: "/workspace/go" 282 workingDir: /workspace/go-sensor/ 283 script: | 284 #!/bin/sh 285 echo "Running couchbase integration tests!" 286 make integration-couchbase 287 if [ $? -ne 0 ]; then 288 echo "Couchbase integration tests failed. Retrying..." 289 make integration-couchbase 290 fi 291 292 --- 293 apiVersion: tekton.dev/v1 294 kind: Task 295 metadata: 296 name: github-set-status 297 spec: 298 params: 299 - name: SHA 300 - name: STATE 301 - name: PIPELINE_RUN_NAME 302 - name: go-version 303 steps: 304 - name: set-status 305 image: curlimages/curl@sha256:f2237028bed58de91f62aea74260bb2a299cf12fbcabc23cfaf125fef276c884 306 env: 307 - name: SHA 308 value: $(params.SHA) 309 - name: STATE 310 value: $(params.STATE) 311 - name: PIPELINE_RUN_NAME 312 value: $(params.PIPELINE_RUN_NAME) 313 - name: GO_VERSION 314 value: $(params.go-version) 315 - name: GITHUB_TOKEN 316 valueFrom: 317 secretKeyRef: 318 name: "github-token" 319 key: "token" 320 script: | 321 #!/bin/sh 322 323 if [ "$STATE" = "pending" ]; then 324 status="pending" 325 description="Tekton is running your tests" 326 elif [ "$STATE" = "Succeeded" ] || [ "$STATE" = "Completed" ]; then 327 status="success" 328 description="Your tests passed on Tekton" 329 else 330 status="failure" 331 description="Your tests failed on Tekton" 332 fi 333 echo $STATE,$status 334 335 curl -L \ 336 -X POST \ 337 -H "Accept: application/vnd.github+json" \ 338 -H "Authorization: Bearer ${GITHUB_TOKEN}" \ 339 -H "Content-Type: application/json" \ 340 -H "X-GitHub-Api-Version: 2022-11-28" \ 341 "https://api.github.com/repos/instana/go-sensor/statuses/${SHA}" \ 342 -d '{ 343 "state": "'"${status}"'", 344 "target_url":"http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/#/namespaces/default/pipelineruns/'"${PIPELINE_RUN_NAME}"'", 345 "description": "'"${description}"'", 346 "context":"Tekton Build Pipeline: go'"${GO_VERSION}"'" 347 }'