-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76f501e
commit aa58dcc
Showing
9 changed files
with
224 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
labels: | ||
- "dependencies" | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
labels: | ||
- "dependencies" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
name: Continuous Integration | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.16' | ||
- name: Setup build cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-go- | ||
- name: Build service | ||
run: make | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.16' | ||
- name: Setup build cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-go- | ||
- name: Lint | ||
run: | | ||
go get -u golang.org/x/lint/golint | ||
golint -set_exit_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build-tag-release: | ||
name: Build, tag, and release assets | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Setup release please | ||
uses: google-github-actions/release-please-action@v2 | ||
id: release | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release-type: simple | ||
package-name: stackie | ||
- name: Retrieve latest tag | ||
run: echo "TAG=$(cat version.txt)" >> $GITHUB_ENV | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.16' | ||
- name: Setup build cache | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: ${{ runner.os }}-go- | ||
# TODO: Add goreleaser? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Test and coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.15' | ||
- name: Run coverage | ||
run: go test -race -coverprofile=coverage.out -covermode=atomic | ||
- name: Upload coverage to Codecov | ||
run: bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= | ||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= | ||
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= | ||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,89 @@ | ||
package stackie | ||
|
||
import ( | ||
"os" | ||
"fmt" | ||
"path" | ||
"io/ioutil" | ||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/bjerkio/stackie/pkg/provider/pulumi" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/afero" | ||
) | ||
|
||
type ProjectConfig struct { | ||
Pulumi pulumi.PulumiProjectConfig | ||
} | ||
|
||
func getProjectConfig() (*ProjectConfig, error) { | ||
curPath, err := os.Getwd() | ||
if err != nil { | ||
// log. | ||
return nil, err | ||
} | ||
|
||
configPath := path.Join(curPath, ".stackie.yml") | ||
content, err := ioutil.ReadFile(configPath) | ||
if err != nil { | ||
log.Info("No stackie profile config found in this directory.") | ||
return nil, err | ||
func getConfigFileNames() []string { | ||
return []string{ | ||
".stackie.yml", | ||
".stackie.json", | ||
"stackie.yml", | ||
"stackie.json", | ||
} | ||
} | ||
|
||
type ConfigFS struct { | ||
fs afero.Fs | ||
} | ||
|
||
func NewConfigFS() ConfigFS { | ||
fs := afero.NewOsFs() | ||
c := ConfigFS{fs} | ||
return c | ||
} | ||
|
||
var config ProjectConfig | ||
err = yaml.Unmarshal(content, config) | ||
if err != nil { | ||
return nil, err | ||
func (config *ConfigFS) getPath(basePath string) (string, error) { | ||
configFileNames := getConfigFileNames() | ||
for _, f := range configFileNames { | ||
p := path.Join(basePath, f) | ||
_, err := config.fs.Stat(p) | ||
if err == nil { | ||
return p, nil | ||
} | ||
} | ||
|
||
log.Info(config) | ||
return nil, nil | ||
return "", fmt.Errorf("could not find configuration") | ||
} | ||
|
||
// func | ||
// func (config *ConfigFS) read(filePath string) (string, error) { | ||
// ext := filepath.Ext(filePath) | ||
|
||
// conf := &ProjectConfig{} | ||
|
||
// switch ext { | ||
// case "yml": | ||
// case "yaml": | ||
// err = yaml.Unmarshal(c, conf) | ||
// if err != nil { | ||
// return "", err | ||
// } | ||
// case "json": | ||
// err = json.Unmarshal(c., conf) | ||
// if err != nil { | ||
// return "", err | ||
// } | ||
// } | ||
// } | ||
|
||
// func getProjectConfig() (*ProjectConfig, error) { | ||
// curPath, err := os.Getwd() | ||
// if err != nil { | ||
// // log. | ||
// return nil, err | ||
// } | ||
|
||
// configPath := path.Join(curPath, ".stackie.yml") | ||
// content, err := ioutil.ReadFile(configPath) | ||
// if err != nil { | ||
// log.Info("No stackie profile config found in this directory.") | ||
// return nil, err | ||
// } | ||
|
||
// var config ProjectConfig | ||
// err = yaml.Unmarshal(content, config) | ||
// if err != nil { | ||
// return nil, err | ||
// } | ||
|
||
// log.Info(config) | ||
// return nil, nil | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
package stackie | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
func TestGetProjectConfig(t *testing.T) { | ||
|
||
} | ||
"github.com/spf13/afero" | ||
) | ||
|
||
func TestGetConfigPath(t *testing.T) { | ||
fs := afero.NewMemMapFs() | ||
fs.MkdirAll("project", 0755) | ||
afero.WriteFile(fs, "project/.stackie.json", []byte(""), 0644) | ||
|
||
c := &ConfigFS{ | ||
fs, | ||
} | ||
|
||
p, err := c.getPath("project") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if p != "project/.stackie.json" { | ||
t.Errorf("getConfigPath failed, expected %v, got %v", ".stackie.json", p) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package stackie | ||
|
||
func Setup() error { | ||
getProjectConfig() | ||
return nil | ||
} | ||
} |