diff --git a/README.md b/README.md index 40a88498a..5bbf6e72a 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,16 @@ spec: emptyDir: {} ``` +- you can as well redefine the `buildCommand` which by default do a `go build + -v ./` with the `buildCommand` parameter, for example if you want instead to + run the tests on a repo with caching: + +```shell +tkn pipeline start pipeline-go --param repo_url=https://github.com/chmouel/gosmee \ + --param revision=main --param registry=docker.io/username \ + --param=buildCommand="make test" -w name=source,emptyDir= +``` + ## License [Apache License 2.0](./LICENSE) diff --git a/examples/pipeline-go.yaml b/examples/pipeline-go.yaml index 308c196e5..b3ef3e835 100644 --- a/examples/pipeline-go.yaml +++ b/examples/pipeline-go.yaml @@ -11,17 +11,23 @@ spec: type: string - name: registry type: string + - name: buildCommand + type: string + default: go build -v . workspaces: - name: source tasks: - displayName: Build go application - name: noop-task + name: build-task workspaces: - name: source workspace: source taskSpec: workspaces: - name: source + params: + - name: buildCommand + default: $(params.buildCommand) steps: - name: create-repo image: cgr.dev/chainguard/go @@ -41,7 +47,7 @@ spec: value: $(params.repo_url) - name: revision value: $(params.revision) - - name: cache-fetch + - name: fetch-cache ref: resolver: http params: @@ -61,12 +67,15 @@ spec: - image: cgr.dev/chainguard/go workingDir: $(workspaces.source.path)/repo name: noop-task + env: + - name: GOCACHE + value: $(workspaces.source.path)/cache/gocache + - name: GOMODCACHE + value: $(workspaces.source.path)/cache/gomodcache script: | set -x git config --global --add safe.directory $(workspaces.source.path)/repo - export GOCACHE=$(workspaces.source.path)/cache/gocache - export GOMODCACHE=$(workspaces.source.path)/cache/gomodcache - go build -v . + $(params.buildCommand) du -shk $GOPATH du -shk $GOMODCACHE - name: cache-upload