From f1b13bd42d052ef55361b6ff824f79eb380eac60 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Sun, 10 Nov 2019 13:44:10 +0100 Subject: [PATCH 1/2] Test for 3 latest Go versions in CI --- .drone.jsonnet | 97 ++++++++++++++++++++++---------------------- .drone.yml | 108 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 50 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 8eeb882..6fb3f4a 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,55 +1,54 @@ -{ - _config+:: { - golang: 'golang:1.13', - }, - - kind: 'pipeline', - name: 'build', - platform: { - os: 'linux', - arch: 'amd64', - }, - - local golang = { - name: 'golang', - image: $._config.golang, - pull: 'always', - environment: { - CGO_ENABLED: '0', - GO111MODULE: 'on', +[ + { + kind: 'pipeline', + name: 'go%s' % version, + platform: { + os: 'linux', + arch: 'amd64', }, - when: { - event: { - exclude: ['tag'], + + local golang = { + name: 'golang', + image: 'golang:%s' % version, + pull: 'always', + environment: { + CGO_ENABLED: '0', + GO111MODULE: 'on', + }, + when: { + event: { + exclude: ['tag'], + }, }, }, - }, - steps: [ - golang { - name: 'gomod', - commands: [ - 'go mod vendor', - 'git diff --exit-code', - ], - }, + steps: [ + golang { + name: 'gomod', + commands: [ + 'go mod vendor', + 'git diff --exit-code', + ], + }, - golang { - name: 'build', - commands: [ - 'make build', - 'make test', - 'make test-integration', - ], - }, + golang { + name: 'build', + commands: [ + 'make build', + 'make test', + 'make test-integration', + ], + }, - golang { - name: 'generate', - commands: [ - 'make check-license', - 'make generate', - 'git diff --exit-code', - ], - }, - ], -} + golang { + name: 'generate', + commands: [ + 'make check-license', + 'make generate', + 'git diff --exit-code', + ], + }, + ], + } + for version in ['1.13', '1.12', '1.11'] +] diff --git a/.drone.yml b/.drone.yml index abc3f81..6331965 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: build +name: go1.13 platform: os: linux @@ -51,4 +51,110 @@ steps: exclude: - 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 + ... From 442ccc505a56e3323d774655be2b30cd9eb0171c Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Tue, 12 Nov 2019 01:41:33 +0100 Subject: [PATCH 2/2] Revert to pkg/errors usage for Go 1.11 & 1.12 --- pkg/local.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/local.go b/pkg/local.go index a9eb0c9..81d77ef 100644 --- a/pkg/local.go +++ b/pkg/local.go @@ -16,11 +16,11 @@ package pkg import ( "context" - "fmt" "os" "path/filepath" "github.com/jsonnet-bundler/jsonnet-bundler/spec" + "github.com/pkg/errors" ) 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) { wd, err := os.Getwd() 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) @@ -44,17 +44,17 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) ( err = os.RemoveAll(newname) 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) 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) 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