Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix Test 👍🏿 Adding Go Actions Caching 🫡 #26

Merged
merged 3 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [ main, develop]
branches: [ main, develop,feature/test-goreleaser]
pull_request:
branches: [ main]
name: Test-MacOs
Expand All @@ -14,6 +14,30 @@ jobs:
go-version: '>=1.16'
- name: Checkout code
uses: actions/checkout@v2
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v3
env:
cache-name: cache-go-modules
with:
path: ~/go
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup config script
# using locals for mac-OS because github CI mac platforms don't have docker
run: |
Expand Down
34 changes: 31 additions & 3 deletions .github/workflows/test-ssh.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [ main, develop]
branches: [ main, develop,feature/test-goreleaser]
pull_request:
branches: [ main]
name: Test-Linux
Expand All @@ -14,13 +14,41 @@ jobs:
go-version: '>=1.16'
- name: Checkout code
uses: actions/checkout@v2

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v3
env:
cache-name: cache-go-modules
with:
path: ~/go
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup SSH server and config
# run docker ssh container for ssh tests
run: |
make prep-ci-ssh
make dependencies
make build-frontend
make prep-ci-ssh
- name: Test
run: |
go mod tidy
go mod tidy
go test -v ./...



26 changes: 25 additions & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [ main, develop]
branches: [ main, develop,feature/test-goreleaser]
pull_request:
branches: [ main]
name: Test-Windows
Expand All @@ -14,6 +14,30 @@ jobs:
go-version: '>=1.16'
- name: Checkout code
uses: actions/checkout@v2
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache go modules
id: cache-go-modules
uses: actions/cache@v3
env:
cache-name: cache-go-modules
with:
path: ~/go
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Choco Install make
uses: crazy-max/ghaction-chocolatey@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ endif
dependencies:
ifeq ($(bin),main.exe)
@make prep-ci-local-windows
yarn add react-scripts@latest
cd web && yarn add react-scripts@latest
else
@make prep-ci-local
endif
Expand Down
8 changes: 7 additions & 1 deletion client/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (hosts *HostsController) getDriver(address string) *driver.Driver {
func (hosts *HostsController) resetDriver(host config.Host) {
hosts.mu.Lock()
defer hosts.mu.Unlock()
hostDriver := host.Connection.ToDriver()
hostDriver := driver.ToDriver(*host.Connection)
hosts.Drivers[host.Address] = &hostDriver
}

Expand Down Expand Up @@ -175,6 +175,12 @@ func (hosts *HostsController) ServeHTTP(w http.ResponseWriter, req *http.Request
// NewHostsController : initialze host controller with config file
func NewHostsController(cfg *config.Config) *HostsController {
dashboardInfo := config.GetDashboardInfoConfig(cfg)
for metric, _ := range dashboardInfo.Metrics {
if !inspector.Valid(metric) {
log.Fatalf("%s is not a valid metric", metric)
}
}

hosts := &HostsController{
Info: dashboardInfo,
Drivers: make(map[string]*driver.Driver),
Expand Down
28 changes: 4 additions & 24 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"io/ioutil"

"github.com/bisohns/saido/driver"
"github.com/bisohns/saido/inspector"
// "github.com/bisohns/saido/driver"

"github.com/mitchellh/mapstructure"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -49,23 +49,6 @@ type Connection struct {
Host string
}

func (conn *Connection) ToDriver() driver.Driver {
switch conn.Type {
case "ssh":
return &driver.SSH{
User: conn.Username,
Host: conn.Host,
Port: int(conn.Port),
KeyFile: conn.PrivateKeyPath,
KeyPass: conn.PrivateKeyPassPhrase,
Password: conn.Password,
CheckKnownHosts: false,
}
default:
return &driver.Local{}
}
}

type Host struct {
Address string
Alias string
Expand Down Expand Up @@ -104,11 +87,8 @@ func GetDashboardInfoConfig(config *Config) *DashboardInfo {
dashboardInfo.Hosts = parseConfig("root", "", config.Hosts, &Connection{})
for metric, customCommand := range config.Metrics {
metric := fmt.Sprintf("%v", metric)
if inspector.Valid(metric) {
metrics[metric] = fmt.Sprintf("%v", customCommand)
} else {
log.Fatalf("Found invalid metric %v", metric)
}
metrics[metric] = fmt.Sprintf("%v", customCommand)

}
dashboardInfo.Metrics = metrics
for _, host := range dashboardInfo.Hosts {
Expand Down
19 changes: 19 additions & 0 deletions driver/driver.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package driver

import "github.com/bisohns/saido/config"

// SystemInfo gives more insight into system details
type SystemDetails struct {
IsWindows bool
Expand All @@ -26,3 +28,20 @@ type Driver interface {
// shows the driver details, not sure if we should be showing OS name
GetDetails() SystemDetails
}

func ToDriver(conn config.Connection) Driver {
switch conn.Type {
case "ssh":
return &SSH{
User: conn.Username,
Host: conn.Host,
Port: int(conn.Port),
KeyFile: conn.PrivateKeyPath,
KeyPass: conn.PrivateKeyPassPhrase,
Password: conn.Password,
CheckKnownHosts: false,
}
default:
return &Local{}
}
}
14 changes: 10 additions & 4 deletions driver/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ func NewSSHForTest() Driver {
yamlPath := fmt.Sprintf("%s/%s", workingDir, "config-test.yaml")
conf := config.LoadConfig(yamlPath)
dashboardInfo := config.GetDashboardInfoConfig(conf)
var host config.Host
for ind := range dashboardInfo.Hosts {
if dashboardInfo.Hosts[ind].Address == "0.0.0.0" {
host = dashboardInfo.Hosts[ind]
}
}
return &SSH{
User: dashboardInfo.Hosts[0].Connection.Username,
Host: dashboardInfo.Hosts[0].Address,
Port: int(dashboardInfo.Hosts[0].Connection.Port),
KeyFile: dashboardInfo.Hosts[0].Connection.PrivateKeyPath,
User: host.Connection.Username,
Host: host.Address,
Port: int(host.Connection.Port),
KeyFile: host.Connection.PrivateKeyPath,
KeyPass: "",
CheckKnownHosts: false,
}
Expand Down
15 changes: 11 additions & 4 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ func NewSSHForTest() driver.Driver {
yamlPath := fmt.Sprintf("%s/%s", workingDir, "config-test.yaml")
conf := config.LoadConfig(yamlPath)
dashboardInfo := config.GetDashboardInfoConfig(conf)
var host config.Host
for ind := range dashboardInfo.Hosts {
if dashboardInfo.Hosts[ind].Address == "0.0.0.0" {
host = dashboardInfo.Hosts[ind]
}
}

return &driver.SSH{
User: dashboardInfo.Hosts[0].Connection.Username,
Host: dashboardInfo.Hosts[0].Address,
Port: int(dashboardInfo.Hosts[0].Connection.Port),
KeyFile: dashboardInfo.Hosts[0].Connection.PrivateKeyPath,
User: host.Connection.Username,
Host: host.Address,
Port: int(host.Connection.Port),
KeyFile: host.Connection.PrivateKeyPath,
KeyPass: "",
CheckKnownHosts: false,
}
Expand Down