parent
2b506b1a2a
commit
a2a1f4dfbd
3
.github/workflows/micro-examples.yml
vendored
3
.github/workflows/micro-examples.yml
vendored
@ -16,6 +16,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.13
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
|
- name: Install Protoc
|
||||||
|
uses: arduino/setup-protoc@master
|
||||||
|
|
||||||
- name: Check out this code
|
- name: Check out this code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
3
.github/workflows/micro-main.yml
vendored
3
.github/workflows/micro-main.yml
vendored
@ -16,6 +16,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.13
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
|
- name: Install Protoc
|
||||||
|
uses: arduino/setup-protoc@master
|
||||||
|
|
||||||
- name: Check out this code
|
- name: Check out this code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -264,8 +264,8 @@ func ParseSource(source string) (*Source, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseSourceLocal detects and handles local pathes too
|
// ParseSourceLocal a version of ParseSource that detects and handles local paths.
|
||||||
// workdir should be used only from the CLI @todo better interface for this function.
|
// Workdir should be used only from the CLI @todo better interface for this function.
|
||||||
// PathExistsFunc exists only for testing purposes, to make the function side effect free.
|
// PathExistsFunc exists only for testing purposes, to make the function side effect free.
|
||||||
func ParseSourceLocal(workDir, source string, pathExistsFunc ...func(path string) (bool, error)) (*Source, error) {
|
func ParseSourceLocal(workDir, source string, pathExistsFunc ...func(path string) (bool, error)) (*Source, error) {
|
||||||
var pexists func(string) (bool, error)
|
var pexists func(string) (bool, error)
|
||||||
@ -274,13 +274,19 @@ func ParseSourceLocal(workDir, source string, pathExistsFunc ...func(path string
|
|||||||
} else {
|
} else {
|
||||||
pexists = pathExistsFunc[0]
|
pexists = pathExistsFunc[0]
|
||||||
}
|
}
|
||||||
var localFullPath string
|
isLocal := false
|
||||||
if len(workDir) > 0 {
|
localFullPath := ""
|
||||||
localFullPath = filepath.Join(workDir, source)
|
// Check for absolute path
|
||||||
} else {
|
// @todo "/" won't work for Windows
|
||||||
|
if exists, err := pexists(source); strings.HasPrefix(source, "/") && err == nil && exists {
|
||||||
|
isLocal = true
|
||||||
localFullPath = source
|
localFullPath = source
|
||||||
|
// Check for path relative to workdir
|
||||||
|
} else if exists, err := pexists(filepath.Join(workDir, source)); err == nil && exists {
|
||||||
|
isLocal = true
|
||||||
|
localFullPath = filepath.Join(workDir, source)
|
||||||
}
|
}
|
||||||
if exists, err := pexists(localFullPath); err == nil && exists {
|
if isLocal {
|
||||||
localRepoRoot, err := GetRepoRoot(localFullPath)
|
localRepoRoot, err := GetRepoRoot(localFullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -3,6 +3,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -46,6 +47,27 @@ func newService(s *Service, c CreateOptions) *service {
|
|||||||
exec = strings.Join(c.Command, " ")
|
exec = strings.Join(c.Command, " ")
|
||||||
args = c.Args
|
args = c.Args
|
||||||
|
|
||||||
|
dir := s.Source
|
||||||
|
|
||||||
|
// For uploaded packages, we upload the whole repo
|
||||||
|
// so the correct working directory to do a `go run .`
|
||||||
|
// needs to include the relative path from the repo root
|
||||||
|
// which is the service name.
|
||||||
|
//
|
||||||
|
// Could use a better upload check.
|
||||||
|
if strings.Contains(s.Source, "uploads") {
|
||||||
|
// There are two cases to consider here:
|
||||||
|
// a., if the uploaded code comes from a repo - in this case
|
||||||
|
// the service name is the relative path.
|
||||||
|
// b., if the uploaded code comes from a non repo folder -
|
||||||
|
// in this case the service name is the folder name.
|
||||||
|
// Because of this, we only append the service name to the source in
|
||||||
|
// case `a`
|
||||||
|
if ex, err := exists(filepath.Join(s.Source, s.Name)); err == nil && ex {
|
||||||
|
dir = filepath.Join(s.Source, s.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &service{
|
return &service{
|
||||||
Service: s,
|
Service: s,
|
||||||
Process: new(proc.Process),
|
Process: new(proc.Process),
|
||||||
@ -56,7 +78,7 @@ func newService(s *Service, c CreateOptions) *service {
|
|||||||
},
|
},
|
||||||
Env: c.Env,
|
Env: c.Env,
|
||||||
Args: args,
|
Args: args,
|
||||||
Dir: s.Source,
|
Dir: dir,
|
||||||
},
|
},
|
||||||
closed: make(chan bool),
|
closed: make(chan bool),
|
||||||
output: c.Output,
|
output: c.Output,
|
||||||
|
Loading…
Reference in New Issue
Block a user