Merge pull request 'feature/test' (#1) from feature/test into master
agola/agola-test/agola go example The run finished successfully

Reviewed-on: https://git.labdevops.net:3000/starkers/agola-test/pulls/1
This commit was merged in pull request #1.
This commit is contained in:
2020-05-16 00:23:30 +00:00
4 changed files with 8 additions and 53 deletions
+3 -2
View File
@@ -13,7 +13,7 @@ local task_build_go(version, arch) = {
{ type: 'clone' }, { type: 'clone' },
{ type: 'restore_cache', keys: ['cache-sum-{{ md5sum "go.sum" }}', 'cache-date-'], dest_dir: '/go/pkg/mod/cache' }, { 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: '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-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' }] }, { type: 'save_cache', key: 'cache-date-{{ year }}-{{ month }}-{{ day }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] },
], ],
@@ -40,7 +40,8 @@ local task_build_go(version, arch) = {
}, },
steps: [ steps: [
{ type: 'restore_workspace', dest_dir: '.' }, { type: 'restore_workspace', dest_dir: '.' },
{ type: 'run', command: './bin/agola-example-go' }, { type: 'run', command: 'find /bin ; pwd ; ls -la' },
{ type: 'run', command: './bin/agola-test' },
], ],
depends: [ depends: [
'build go 1.12 amd64', 'build go 1.12 amd64',
-51
View File
@@ -1,51 +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
+3
View File
@@ -1,5 +1,8 @@
# Agola Go example # 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) 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) 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)
+2
View File
@@ -9,4 +9,6 @@ import (
func main() { func main() {
// we use an external go module // we use an external go module
fmt.Println(quote.Hello()) fmt.Println(quote.Hello())
foo := "bla"
fmt.Println(foo)
} }