-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: PuneetPunamiya <[email protected]>
- Loading branch information
1 parent
7409b33
commit 4483b77
Showing
4 changed files
with
257 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: pipeline | ||
spec: | ||
params: | ||
- name: repo_url | ||
type: string | ||
- name: revision | ||
type: string | ||
- name: registry | ||
type: string | ||
- name: buildCommand | ||
type: string | ||
default: go build -v . | ||
- name: cachePatterns | ||
type: array | ||
default: [ "**go.mod", "**go.sum" ] | ||
- name: image | ||
type: string | ||
default: golang:latest | ||
- name: force-cache-upload | ||
type: string | ||
default: "false" | ||
workspaces: | ||
- name: source | ||
- name: cred | ||
tasks: | ||
- displayName: Build go application | ||
name: build-task | ||
workspaces: | ||
- name: source | ||
workspace: source | ||
taskSpec: | ||
results: | ||
- name: test-fetched | ||
workspaces: | ||
- name: source | ||
- name: cred | ||
params: | ||
- name: buildCommand | ||
default: $(params.buildCommand) | ||
- name: cachePatterns | ||
default: $(params.cachePatterns) | ||
- name: image | ||
default: $(params.image) | ||
steps: | ||
- name: create-repo | ||
image: $(params.image) | ||
script: | | ||
mkdir -p $(workspaces.source.path)/repo | ||
chmod 777 $(workspaces.source.path)/repo | ||
- name: fetch-repo | ||
ref: | ||
resolver: http | ||
params: | ||
- name: url | ||
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml | ||
params: | ||
- name: output-path | ||
value: $(workspaces.source.path)/repo | ||
- name: url | ||
value: $(params.repo_url) | ||
- name: revision | ||
value: $(params.revision) | ||
- name: cache-fetch | ||
ref: | ||
name: cache-fetch | ||
params: | ||
- name: patterns | ||
value: $(params.cachePatterns) | ||
- name: source | ||
value: $(params.registry)/cache-go:{{hash}} | ||
- name: cachePath | ||
value: $(workspaces.source.path)/cache | ||
- name: workingdir | ||
value: $(workspaces.source.path)/repo | ||
- name: awsCredentialFile | ||
value: $(workspaces.cred.path)/credentials | ||
- name: awsConfigFile | ||
value: $(workspaces.cred.path)/config | ||
- name: googleCredentialsPath | ||
value: $(workspaces.cred.path)/creds.json | ||
|
||
- name: run-go-build | ||
workingDir: $(workspaces.source.path)/repo | ||
image: $(params.image) | ||
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 | ||
$(params.buildCommand) | ||
echo "Cache size is $(du -sh $(workspaces.source.path)/cache)" | ||
- name: cache-upload | ||
ref: | ||
name: cache-upload | ||
params: | ||
- name: patterns | ||
value: $(params.cachePatterns) | ||
- name: target | ||
value: $(params.registry)/cache-go:{{hash}} | ||
- name: cachePath | ||
value: $(workspaces.source.path)/cache | ||
- name: workingdir | ||
value: $(workspaces.source.path)/repo | ||
- name: dockerConfig | ||
value: $(workspaces.cred.path) | ||
- name: awsCredentialFile | ||
value: $(workspaces.cred.path)/credentials | ||
- name: awsConfigFile | ||
value: $(workspaces.cred.path)/config | ||
- name: force-cache-upload | ||
value: $(params.force-cache-upload) | ||
- name: googleCredentialsPath | ||
value: $(workspaces.cred.path)/creds.json | ||
|
||
- name: cache-fetch-2 | ||
ref: | ||
name: cache-fetch | ||
params: | ||
- name: patterns | ||
value: $(params.cachePatterns) | ||
- name: source | ||
value: $(params.registry)/cache-go:{{hash}} | ||
- name: cachePath | ||
value: $(workspaces.source.path)/cache | ||
- name: workingdir | ||
value: $(workspaces.source.path)/repo | ||
- name: awsCredentialFile | ||
value: $(workspaces.cred.path)/credentials | ||
- name: awsConfigFile | ||
value: $(workspaces.cred.path)/config | ||
- name: googleCredentialsPath | ||
value: $(workspaces.cred.path)/creds.json | ||
|
||
- name: verify | ||
image: bash:latest | ||
env: | ||
- name: test | ||
value: $(steps.cache-fetch-2.results.fetched) | ||
script: | | ||
#!/usr/bin/env bash | ||
res=${test} | ||
echo ${res} | ||
echo -n ${res} > $(results.test-fetched.path) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: PipelineRun | ||
metadata: | ||
name: pipelinerun-oci-test | ||
spec: | ||
pipelineRef: | ||
name: pipeline | ||
params: | ||
- name: repo_url | ||
value: https://github.com/chmouel/go-helloworld | ||
- name: revision | ||
value: main | ||
# This uses S3 bucket to upload Caches | ||
- name: registry | ||
value: oci://127.0.0.1:5000/cache/go | ||
- name: buildCommand | ||
value: go build -v ./ | ||
- name: image | ||
value: golang:1.21 | ||
workspaces: | ||
- name: cred | ||
emptyDir: {} | ||
- name: source | ||
emptyDir: {} |