forked from cerc-io/ipld-eth-server
fix for issue with Travis building plugin from plugin repo
This commit is contained in:
parent
06fab13c54
commit
5fd9a59027
@ -273,7 +273,6 @@ The config provides information for composing a set of transformers:
|
|||||||
|
|
||||||
[exporter]
|
[exporter]
|
||||||
home = "github.com/vulcanize/vulcanizedb"
|
home = "github.com/vulcanize/vulcanizedb"
|
||||||
clone = false
|
|
||||||
name = "exampleTransformerExporter"
|
name = "exampleTransformerExporter"
|
||||||
save = false
|
save = false
|
||||||
transformerNames = [
|
transformerNames = [
|
||||||
@ -304,7 +303,6 @@ The config provides information for composing a set of transformers:
|
|||||||
migrations = "to/db/migrations"
|
migrations = "to/db/migrations"
|
||||||
```
|
```
|
||||||
- `home` is the name of the package you are building the plugin for, in most cases this is github.com/vulcanize/vulcanizedb
|
- `home` is the name of the package you are building the plugin for, in most cases this is github.com/vulcanize/vulcanizedb
|
||||||
- `clone` this signifies whether or not to retrieve plugin transformer packages by `git clone`ing them; by default we attempt to work with transformer packages located in
|
|
||||||
our `$GOPATH` but setting this to `true` overrides that. This needs to be set to `true` for the configs used in tests in order for them to work with Travis.
|
our `$GOPATH` but setting this to `true` overrides that. This needs to be set to `true` for the configs used in tests in order for them to work with Travis.
|
||||||
- `name` is the name used for the plugin files (.so and .go)
|
- `name` is the name used for the plugin files (.so and .go)
|
||||||
- `save` indicates whether or not the user wants to save the .go file instead of removing it after .so compilation. Sometimes useful for debugging/trouble-shooting purposes.
|
- `save` indicates whether or not the user wants to save the .go file instead of removing it after .so compilation. Sometimes useful for debugging/trouble-shooting purposes.
|
||||||
|
@ -45,7 +45,6 @@ var composeCmd = &cobra.Command{
|
|||||||
|
|
||||||
[exporter]
|
[exporter]
|
||||||
home = "github.com/vulcanize/vulcanizedb"
|
home = "github.com/vulcanize/vulcanizedb"
|
||||||
clone = false
|
|
||||||
name = "exampleTransformerExporter"
|
name = "exampleTransformerExporter"
|
||||||
save = false
|
save = false
|
||||||
transformerNames = [
|
transformerNames = [
|
||||||
@ -168,6 +167,5 @@ func prepConfig() {
|
|||||||
FileName: viper.GetString("exporter.name"),
|
FileName: viper.GetString("exporter.name"),
|
||||||
Save: viper.GetBool("exporter.save"),
|
Save: viper.GetBool("exporter.save"),
|
||||||
Home: viper.GetString("exporter.home"),
|
Home: viper.GetString("exporter.home"),
|
||||||
Clone: viper.GetBool("exporter.clone"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ var composeAndExecuteCmd = &cobra.Command{
|
|||||||
|
|
||||||
[exporter]
|
[exporter]
|
||||||
home = "github.com/vulcanize/vulcanizedb"
|
home = "github.com/vulcanize/vulcanizedb"
|
||||||
clone = false
|
|
||||||
name = "exampleTransformerExporter"
|
name = "exampleTransformerExporter"
|
||||||
save = false
|
save = false
|
||||||
transformerNames = [
|
transformerNames = [
|
||||||
|
@ -29,7 +29,6 @@ type Plugin struct {
|
|||||||
FileName string
|
FileName string
|
||||||
Save bool
|
Save bool
|
||||||
Home string
|
Home string
|
||||||
Clone bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Transformer struct {
|
type Transformer struct {
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/plugin/helpers"
|
"github.com/vulcanize/vulcanizedb/pkg/plugin/helpers"
|
||||||
@ -87,37 +86,24 @@ func (b *builder) setupBuildEnv() error {
|
|||||||
|
|
||||||
// Import transformer dependencies so that we can build our plugin
|
// Import transformer dependencies so that we can build our plugin
|
||||||
for importPath := range repoPaths {
|
for importPath := range repoPaths {
|
||||||
dstPath := filepath.Join(vendorPath, importPath)
|
dst := filepath.Join(vendorPath, importPath)
|
||||||
// When testing on Travis we need to clone the libs
|
src, err := helpers.CleanPath(filepath.Join("$GOPATH/src", importPath))
|
||||||
if b.GenConfig.Clone {
|
|
||||||
// And if we want to be able to work with a private repo we need to use ssh instead of https
|
|
||||||
// and upload a permissioned ssh key to travis before deploying tests there
|
|
||||||
index := strings.Index(importPath, "/")
|
|
||||||
gitPath := importPath[:index] + ":" + importPath[index+1:]
|
|
||||||
importURL := "git@" + gitPath + ".git"
|
|
||||||
err = exec.Command("git", "clone", importURL, dstPath).Run()
|
|
||||||
if err != nil {
|
|
||||||
return errors.New(fmt.Sprintf("unable to clone transformer dependency from %s to %s: %s", importPath, dstPath, err.Error()))
|
|
||||||
}
|
|
||||||
} else { // If not on Travis we can work with libs at $GOPATH
|
|
||||||
srcDir, err := helpers.CleanPath(filepath.Join("$GOPATH/src", importPath))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sp := strings.Split(dstPath, "/")
|
|
||||||
spj := strings.Join(sp[:len(sp)-1], "/")
|
err = helpers.CopyDir(src, dst, "vendor")
|
||||||
err = exec.Command("rsync", "-a", srcDir, spj).Run()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New(fmt.Sprintf("unable to copy transformer dependency from %s to %s: %s", srcDir, dstPath, err.Error()))
|
return errors.New(fmt.Sprintf("unable to copy transformer dependency from %s to %s: %v", src, dst, err))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have to clear out the copied over vendor lib or plugin won't build (see issue above)
|
// Have to clear out the copied over vendor lib or plugin won't build (see issue above)
|
||||||
err := os.RemoveAll(filepath.Join(dstPath, "vendor"))
|
err = os.RemoveAll(filepath.Join(dst, "vendor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Keep track of this vendor directory to clear later
|
// Keep track of this vendor directory to clear later
|
||||||
b.tmpVenDirs = append(b.tmpVenDirs, dstPath)
|
b.tmpVenDirs = append(b.tmpVenDirs, dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -18,6 +18,7 @@ package helpers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -62,16 +63,51 @@ func CopyFile(src, dst string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer in.Close()
|
|
||||||
out, err := os.OpenFile(dst, syscall.O_CREAT|syscall.O_EXCL|os.O_WRONLY, os.FileMode(0666)) // Doesn't overwrite files
|
out, err := os.OpenFile(dst, syscall.O_CREAT|syscall.O_EXCL|os.O_WRONLY, os.FileMode(0666)) // Doesn't overwrite files
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
in.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer out.Close()
|
|
||||||
|
|
||||||
_, err = io.Copy(out, in)
|
_, err = io.Copy(out, in)
|
||||||
|
in.Close()
|
||||||
|
out.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func CopyDir(src string, dst string, excludeRecursiveDir string) error {
|
||||||
|
var err error
|
||||||
|
var fds []os.FileInfo
|
||||||
|
var srcinfo os.FileInfo
|
||||||
|
|
||||||
|
if srcinfo, err = os.Stat(src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if fds, err = ioutil.ReadDir(src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, fd := range fds {
|
||||||
|
srcfp := filepath.Join(src, fd.Name())
|
||||||
|
dstfp := filepath.Join(dst, fd.Name())
|
||||||
|
|
||||||
|
if fd.IsDir() {
|
||||||
|
if fd.Name() != excludeRecursiveDir {
|
||||||
|
err = CopyDir(srcfp, dstfp, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return out.Close()
|
}
|
||||||
|
} else {
|
||||||
|
err = CopyFile(srcfp, dstfp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user