Merge pull request #59 from metalmatze/go-versions-ci

Test for 3 latest Go versions in CI
This commit is contained in:
Frederic Branczyk 2019-11-12 09:30:02 +01:00 committed by GitHub
commit d7829f6c7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 160 additions and 55 deletions

View file

@ -1,10 +1,7 @@
[
{ {
_config+:: {
golang: 'golang:1.13',
},
kind: 'pipeline', kind: 'pipeline',
name: 'build', name: 'go%s' % version,
platform: { platform: {
os: 'linux', os: 'linux',
arch: 'amd64', arch: 'amd64',
@ -12,7 +9,7 @@
local golang = { local golang = {
name: 'golang', name: 'golang',
image: $._config.golang, image: 'golang:%s' % version,
pull: 'always', pull: 'always',
environment: { environment: {
CGO_ENABLED: '0', CGO_ENABLED: '0',
@ -53,3 +50,5 @@
}, },
], ],
} }
for version in ['1.13', '1.12', '1.11']
]

View file

@ -1,6 +1,6 @@
--- ---
kind: pipeline kind: pipeline
name: build name: go1.13
platform: platform:
os: linux os: linux
@ -51,4 +51,110 @@ steps:
exclude: exclude:
- tag - tag
---
kind: pipeline
name: go1.12
platform:
os: linux
arch: amd64
steps:
- name: gomod
pull: always
image: golang:1.12
commands:
- go mod vendor
- git diff --exit-code
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build
pull: always
image: golang:1.12
commands:
- make build
- make test
- make test-integration
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: generate
pull: always
image: golang:1.12
commands:
- make check-license
- make generate
- git diff --exit-code
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
---
kind: pipeline
name: go1.11
platform:
os: linux
arch: amd64
steps:
- name: gomod
pull: always
image: golang:1.11
commands:
- go mod vendor
- git diff --exit-code
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build
pull: always
image: golang:1.11
commands:
- make build
- make test
- make test-integration
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: generate
pull: always
image: golang:1.11
commands:
- make check-license
- make generate
- git diff --exit-code
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
... ...

View file

@ -16,11 +16,11 @@ package pkg
import ( import (
"context" "context"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"github.com/jsonnet-bundler/jsonnet-bundler/spec" "github.com/jsonnet-bundler/jsonnet-bundler/spec"
"github.com/pkg/errors"
) )
type LocalPackage struct { type LocalPackage struct {
@ -36,7 +36,7 @@ func NewLocalPackage(source *spec.LocalSource) Interface {
func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (lockVersion string, err error) { func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (lockVersion string, err error) {
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get current working directory: %w", err) return "", errors.Wrap(err, "failed to get current working directory: %w")
} }
oldname := filepath.Join(wd, p.Source.Directory) oldname := filepath.Join(wd, p.Source.Directory)
@ -44,17 +44,17 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
err = os.RemoveAll(newname) err = os.RemoveAll(newname)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to clean previous destination path: %w", err) return "", errors.Wrap(err, "failed to clean previous destination path: %w")
} }
_, err = os.Stat(oldname) _, err = os.Stat(oldname)
if os.IsNotExist(err) { if os.IsNotExist(err) {
return "", fmt.Errorf("symlink destination path does not exist: %w", err) return "", errors.Wrap(err, "symlink destination path does not exist: %w")
} }
err = os.Symlink(oldname, newname) err = os.Symlink(oldname, newname)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to create symlink for local dependency: %w", err) return "", errors.Wrap(err, "failed to create symlink for local dependency: %w")
} }
return "", nil return "", nil