Skip to content

Commit

Permalink
This patch splits golang-build task from the golang directory
Browse files Browse the repository at this point in the history
Changes include:
  - moves the golang-build task to the task directory
  - copies and modifies readme file to golang-build task from golang directory
  - copies OWNERS file from golang directory
  - copies test directory from golang directory to golang-build task
  - changes the yaml filename to match the resource name

Issue: tektoncd#386

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 authored and popcor255 committed Jul 14, 2020
1 parent 5107274 commit 26f7c1c
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
4 changes: 4 additions & 0 deletions task/golang-build/0.1/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- vdemeester
reviewers:
- vdemeester
49 changes: 49 additions & 0 deletions task/golang-build/0.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Golang Build

This Task is Golang task to build Go projects.

## Install the task

```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/golang-build/0.1/golang-build.yaml
```


### Parameters

* **package**: base package under test
* **packages**: packages to test (_default:_ ./...)
* **version**: golang version to use for tests (_default:_ latest)
* **flags**: flags to use for `go build` command (_default:_ -v)
* **GOOS**: operating system target (_default:_ linux)
* **GOARCH**: architecture target (_default:_ amd64)
* **GO111MODULE**: value of module support (_default:_ auto)

### Workspaces

* **source**: A [Workspace](https://github.com/tektoncd/pipeline/blob/master/docs/workspaces.md) volume containing the source to build.


## Usage

This TaskRun runs the Task to compile commands from
[`tektoncd/pipeline`](https://github.com/tektoncd/pipeline).
`golangci-lint`.

```yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: build-my-code
spec:
taskRef:
name: golang-build
workspaces:
- name: source
persistentVolumeClaim:
claimName: my-source
params:
- name: package
value: github.com/tektoncd/pipeline
```
File renamed without changes.
8 changes: 8 additions & 0 deletions task/golang-build/0.1/test/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Add an internal registry as sidecar to the task so we can upload it directly
# from our tests without having to go to an external registry.
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
10 changes: 10 additions & 0 deletions task/golang-build/0.1/test/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: golang-source-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
68 changes: 68 additions & 0 deletions task/golang-build/0.1/test/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: golang-test-pipeline
spec:
workspaces:
- name: shared-workspace
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: shared-workspace
params:
- name: url
value: https://github.com/tektoncd/pipeline
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: run-lint
taskRef:
name: golangci-lint
runAfter:
- fetch-repository
workspaces:
- name: source
workspace: shared-workspace
params:
- name: package
value: github.com/tektoncd/pipeline
- name: run-build
taskRef:
name: golang-build
runAfter:
- fetch-repository
workspaces:
- name: source
workspace: shared-workspace
params:
- name: package
value: github.com/tektoncd/pipeline
- name: run-test
taskRef:
name: golang-test
runAfter:
- fetch-repository
workspaces:
- name: source
workspace: shared-workspace
params:
- name: package
value: github.com/tektoncd/pipeline

---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: golang-test-pipeline-run
spec:
pipelineRef:
name: golang-test-pipeline
workspaces:
- name: shared-workspace
persistentvolumeclaim:
claimName: golang-source-pvc

0 comments on commit 26f7c1c

Please sign in to comment.