From 7026fc7c6fdec2d4739e10c676b862b42fcc3374 Mon Sep 17 00:00:00 2001 From: David Stark Date: Sat, 16 May 2020 00:54:48 +0100 Subject: [PATCH 1/4] test --- .agola/config.yml | 97 +++++++++++++++++++++++------------------------ README.md | 3 ++ 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/.agola/config.yml b/.agola/config.yml index 6637a3d..1593121 100644 --- a/.agola/config.yml +++ b/.agola/config.yml @@ -1,51 +1,50 @@ version: v0 - runs: - - name: agola go example - tasks: - - name: build go 1.12 - runtime: - type: pod - arch: amd64 - containers: - - image: golang:1.12-stretch - steps: - - clone: - - restore_cache: - keys: - - cache-sum-{{ md5sum "go.sum" }} - - cache-date- - ## golang image sets GOPATH to /go - dest_dir: /go/pkg/mod/cache - ## This will create a binary called `agola-example-go` under ./bin - - run: - name: build the program - command: go build . - ## Copy the built binary to the workspace - - save_to_workspace: - contents: - - source_dir: . - dest_dir: /bin/ - paths: - - agola-example-go - - save_cache: - key: cache-sum-{{ md5sum "go.sum" }} - contents: - - source_dir: /go/pkg/mod/cache - - save_cache: - key: cache-date-{{ year }}-{{ month }}-{{ day }} - contents: - - source_dir: /go/pkg/mod/cache - - name: run - ## This task will run the built binary in the parent task and leverages the workspace capabilities - runtime: - type: pod - arch: amd64 - containers: - - image: debian:stretch - steps: - - restore_workspace: - dest_dir: . - - run: ./bin/agola-example-go - depends: - - build go 1.12 +- name: agola go example + tasks: + - name: build go 1.12 + runtime: + type: pod + arch: amd64 + containers: + - image: golang:1.12-stretch + steps: + - clone: + - restore_cache: + keys: + - cache-sum-{{ md5sum "go.sum" }} + - cache-date- + ## golang image sets GOPATH to /go + dest_dir: /go/pkg/mod/cache + - ## This will create a binary called `agola-example-go` under ./bin + run: + name: build the program + command: go build . + - ## Copy the built binary to the workspace + save_to_workspace: + contents: + - source_dir: . + dest_dir: /bin/ + paths: + - agola-example-go + - save_cache: + key: cache-sum-{{ md5sum "go.sum" }} + contents: + - source_dir: /go/pkg/mod/cache + - save_cache: + key: cache-date-{{ year }}-{{ month }}-{{ day }} + contents: + - source_dir: /go/pkg/mod/cache + - name: run + ## This task will run the built binary in the parent task and leverages the workspace capabilities + runtime: + type: pod + arch: amd64 + containers: + - image: debian:stretch + steps: + - restore_workspace: + dest_dir: . + - run: ./bin/agola-example-go + depends: + - build go 1.12 diff --git a/README.md b/README.md index c3638a9..ecf759c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Agola Go example + +stuff + This is just a simple example to test an agola run that'll build a simple go program using a matrix build (multiple Go versions and optionally multiple architectures) It uses the jsonnet config format. There's also a (less powerful) yaml config file (to try it delete the jsonnet config since it takes precedence) From d3b518c2d4dafdd083ff381a17860e75445753cf Mon Sep 17 00:00:00 2001 From: David Stark Date: Sat, 16 May 2020 01:08:38 +0100 Subject: [PATCH 2/4] testing --- .agola/config.jsonnet | 3 ++- .agola/config.yml | 50 ------------------------------------------- main.go | 2 ++ 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 .agola/config.yml diff --git a/.agola/config.jsonnet b/.agola/config.jsonnet index a0df7f3..a419134 100644 --- a/.agola/config.jsonnet +++ b/.agola/config.jsonnet @@ -40,7 +40,8 @@ local task_build_go(version, arch) = { }, steps: [ { type: 'restore_workspace', dest_dir: '.' }, - { type: 'run', command: './bin/agola-example-go' }, + { type: 'list', command: 'find .' }, + { type: 'run', command: './bin/agola-test' }, ], depends: [ 'build go 1.12 amd64', diff --git a/.agola/config.yml b/.agola/config.yml deleted file mode 100644 index 1593121..0000000 --- a/.agola/config.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: v0 -runs: -- name: agola go example - tasks: - - name: build go 1.12 - runtime: - type: pod - arch: amd64 - containers: - - image: golang:1.12-stretch - steps: - - clone: - - restore_cache: - keys: - - cache-sum-{{ md5sum "go.sum" }} - - cache-date- - ## golang image sets GOPATH to /go - dest_dir: /go/pkg/mod/cache - - ## This will create a binary called `agola-example-go` under ./bin - run: - name: build the program - command: go build . - - ## Copy the built binary to the workspace - save_to_workspace: - contents: - - source_dir: . - dest_dir: /bin/ - paths: - - agola-example-go - - save_cache: - key: cache-sum-{{ md5sum "go.sum" }} - contents: - - source_dir: /go/pkg/mod/cache - - save_cache: - key: cache-date-{{ year }}-{{ month }}-{{ day }} - contents: - - source_dir: /go/pkg/mod/cache - - name: run - ## This task will run the built binary in the parent task and leverages the workspace capabilities - runtime: - type: pod - arch: amd64 - containers: - - image: debian:stretch - steps: - - restore_workspace: - dest_dir: . - - run: ./bin/agola-example-go - depends: - - build go 1.12 diff --git a/main.go b/main.go index 230a344..bccfa29 100644 --- a/main.go +++ b/main.go @@ -9,4 +9,6 @@ import ( func main() { // we use an external go module fmt.Println(quote.Hello()) + foo := "bla" + fmt.Println(foo) } From 6c010ae670c9bc652aacb5de3ba42ba64c3696e7 Mon Sep 17 00:00:00 2001 From: David Stark Date: Sat, 16 May 2020 01:09:46 +0100 Subject: [PATCH 3/4] ahh.. "step types" --- .agola/config.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.agola/config.jsonnet b/.agola/config.jsonnet index a419134..9cb7deb 100644 --- a/.agola/config.jsonnet +++ b/.agola/config.jsonnet @@ -40,7 +40,7 @@ local task_build_go(version, arch) = { }, steps: [ { type: 'restore_workspace', dest_dir: '.' }, - { type: 'list', command: 'find .' }, + { type: 'run', command: 'find .' }, { type: 'run', command: './bin/agola-test' }, ], depends: [ From 8d2fec4429e7de23f88a926ade1e6e3e2c7c499d Mon Sep 17 00:00:00 2001 From: David Stark Date: Sat, 16 May 2020 01:12:01 +0100 Subject: [PATCH 4/4] testing --- .agola/config.jsonnet | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.agola/config.jsonnet b/.agola/config.jsonnet index 9cb7deb..8edbc8a 100644 --- a/.agola/config.jsonnet +++ b/.agola/config.jsonnet @@ -13,7 +13,7 @@ local task_build_go(version, arch) = { { type: 'clone' }, { type: 'restore_cache', keys: ['cache-sum-{{ md5sum "go.sum" }}', 'cache-date-'], dest_dir: '/go/pkg/mod/cache' }, { type: 'run', name: 'build the program', command: 'go build .' }, - { type: 'save_to_workspace', contents: [{ source_dir: '.', dest_dir: '/bin/', paths: ['agola-example-go'] }] }, + { type: 'save_to_workspace', contents: [{ source_dir: '.', dest_dir: '/bin/', paths: ['agola-test'] }] }, { type: 'save_cache', key: 'cache-sum-{{ md5sum "go.sum" }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] }, { type: 'save_cache', key: 'cache-date-{{ year }}-{{ month }}-{{ day }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] }, ], @@ -40,7 +40,7 @@ local task_build_go(version, arch) = { }, steps: [ { type: 'restore_workspace', dest_dir: '.' }, - { type: 'run', command: 'find .' }, + { type: 'run', command: 'find /bin ; pwd ; ls -la' }, { type: 'run', command: './bin/agola-test' }, ], depends: [