Skip to content

Commit

Permalink
Update CI post migration (flyteorg#68)
Browse files Browse the repository at this point in the history
* Update CI post migration

* Migrate to github workflows

* length check

* debug

* Avoid installing pflags from repo

* Update deps

* update go action

* try import path

* update protos

* set checkout depth

* cleanup

* typo in master wf
  • Loading branch information
EngHabu authored Jan 31, 2021
1 parent 519a271 commit 5cf5567
Show file tree
Hide file tree
Showing 12 changed files with 961 additions and 101 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Master

on:
push:
branches:
- master

jobs:
bump-version:
name: Bump Version
if: github.event.commits[0].author.name != 'goreleaserbot'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump-version.outputs.tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Bump version and push tag
id: bump-version
uses: anothrNick/github-tag-action@1.17.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch

goreleaser:
name: Goreleaser
runs-on: ubuntu-latest
needs: [bump-version]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

tests-lint:
name: Run tests and lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Unit Tests
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make mod_download && make test_unit_codecov
- name: Push CodeCov
uses: codecov/codecov-action@v1
with:
file: coverage.txt
flags: unittests
fail_ci_if_error: true
- name: Lint
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make install && make lint
- name: Bench tests
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make install && make test_benchmark
37 changes: 37 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Pull Request

on: pull_request

jobs:
tests-lint:
name: Run tests and lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Unit Tests
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make mod_download && make test_unit_codecov
- name: Push CodeCov
uses: codecov/codecov-action@v1
with:
file: coverage.txt
flags: unittests
fail_ci_if_error: true
- name: Lint
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make install && make lint
- name: Bench tests
uses: cedrickring/golang-action@1.6.0
env:
GO111MODULE: "on"
with:
args: make install && make test_benchmark
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ codecov_bash.sh
coverage.txt

# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode

.vscode/*
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X github.com/lyft/flytestdlib/version.Version={{.Version}} -X github.com/lyft/flytestdlib/version.Build={{.ShortCommit}} -X github.com/lyft/flytestdlib/version.BuildTime={{.Date}}
- -s -w -X github.com/flyteorg/flytestdlib/version.Version={{.Version}} -X github.com/flyteorg/flytestdlib/version.Build={{.ShortCommit}} -X github.com/flyteorg/flytestdlib/version.BuildTime={{.Date}}
archives:
- replacements:
darwin: macOS
Expand Down Expand Up @@ -49,7 +49,7 @@ scoop:

# Your app's homepage.
# Default is empty.
homepage: "https://godoc.org/github.com/lyft/flytestdlib"
homepage: "https://godoc.org/github.com/flyteorg/flytestdlib"

# Your app's description.
# Default is empty.
Expand Down
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions cli/pflags/api/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ func discoverFieldsRecursive(ctx context.Context, typ *types.Named, defaultValue
func NewGenerator(pkg, targetTypeName, defaultVariableName string) (*PFlagProviderGenerator, error) {
ctx := context.Background()
var err error

// Resolve package path
if pkg == "" || pkg[0] == '.' {
pkg, err = filepath.Abs(filepath.Clean(pkg))
if err != nil {
return nil, err
}

pkg = gogenutil.StripGopath(pkg)
logger.InfofNoCtx("Loading package from path [%v]", pkg)
}

targetPackage, err := loadPackage(pkg)
Expand Down Expand Up @@ -340,11 +343,18 @@ func NewGenerator(pkg, targetTypeName, defaultVariableName string) (*PFlagProvid
func loadPackage(pkg string) (*types.Package, error) {
config := &packages.Config{
Mode: packages.NeedTypes | packages.NeedTypesInfo,
Logf: logger.InfofNoCtx,
}

loadedPkgs, err := packages.Load(config, pkg)
if err != nil {
return nil, err
}

if len(loadedPkgs) == 0 {
return nil, fmt.Errorf("No packages loaded")
}

targetPackage := loadedPkgs[0].Types
return targetPackage, nil
}
Expand Down
20 changes: 15 additions & 5 deletions cli/pflags/api/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,29 @@ func TestElemValueOrNil(t *testing.T) {
}

func TestNewGenerator(t *testing.T) {
g, err := NewGenerator(".", "TestType", "DefaultTestType")
assert.NoError(t, err)
g, err := NewGenerator("github.com/lyft/flytestdlib/cli/pflags/api", "TestType", "DefaultTestType")
if !assert.NoError(t, err) {
t.FailNow()
}

ctx := context.Background()
p, err := g.Generate(ctx)
assert.NoError(t, err)
if !assert.NoError(t, err) {
t.FailNow()
}

codeOutput, err := ioutil.TempFile("", "output-*.go")
assert.NoError(t, err)
if !assert.NoError(t, err) {
t.FailNow()
}

defer func() { assert.NoError(t, os.Remove(codeOutput.Name())) }()

testOutput, err := ioutil.TempFile("", "output-*_test.go")
assert.NoError(t, err)
if !assert.NoError(t, err) {
t.FailNow()
}

defer func() { assert.NoError(t, os.Remove(testOutput.Name())) }()

assert.NoError(t, p.WriteCodeFile(codeOutput.Name()))
Expand Down
79 changes: 49 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,67 @@ module github.com/lyft/flytestdlib
go 1.13

require (
cloud.google.com/go v0.52.0 // indirect
github.com/Azure/azure-sdk-for-go v38.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.9.4 // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.1 // indirect
github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
github.com/aws/aws-sdk-go v1.28.9
cloud.google.com/go v0.75.0 // indirect
cloud.google.com/go/storage v1.12.0 // indirect
github.com/Azure/azure-sdk-for-go v51.0.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.17 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.10 // indirect
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/aws/aws-sdk-go v1.37.1
github.com/benlaurie/objecthash v0.0.0-20180202135721-d1e3d6079fc1
github.com/coocood/freecache v1.1.0
github.com/dnaeon/go-vcr v1.0.1 // indirect
github.com/coocood/freecache v1.1.1
github.com/coreos/go-etcd v2.0.0+incompatible // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/ernesto-jimenez/gogen v0.0.0-20180125220232-d7d4131e6607
github.com/fatih/color v1.9.0
github.com/fatih/color v1.10.0
github.com/fatih/structtag v1.2.0
github.com/fsnotify/fsnotify v1.4.8-0.20191012010759-4bf2d1fec783
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
github.com/go-test/deep v1.0.7
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.3.2
github.com/graymeta/stow v0.2.4
github.com/golang/protobuf v1.4.3
github.com/graymeta/stow v0.2.7
github.com/hashicorp/golang-lru v0.5.4
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/magiconair/properties v1.8.1
github.com/magiconair/properties v1.8.4
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/mapstructure v1.1.2
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/ncw/swift v1.0.53 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.3.0
github.com/prometheus/common v0.9.1 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/prometheus/client_golang v1.9.0
github.com/prometheus/procfs v0.3.0 // indirect
github.com/sirupsen/logrus v1.7.0
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/cobra v1.1.1
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.6.2
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/tools v0.0.0-20200124170513-3f4d10fc73b4
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150 // indirect
gopkg.in/ini.v1 v1.51.1 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
k8s.io/apimachinery v0.17.2
github.com/spf13/viper v1.7.1
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/ugorji/go v1.1.4 // indirect
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
go.opencensus.io v0.22.6 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
golang.org/x/tools v0.1.0
google.golang.org/api v0.38.0 // indirect
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506 // indirect
google.golang.org/grpc v1.35.0 // indirect
google.golang.org/protobuf v1.25.0
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apimachinery v0.20.2
k8s.io/client-go v11.0.0+incompatible
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.5.0 // indirect
)

// Pin the version of client-go to something that's compatible with katrogan's fork of api and apimachinery
Expand Down
Loading

0 comments on commit 5cf5567

Please sign in to comment.