Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb307409a0 | |||
| dd202c63ec | |||
| 9dd80d7d66 | |||
| bf07077154 | |||
| bd2f305d80 | |||
| e32fc5947e | |||
| ac6b02808c | |||
| 0a55a7076f | |||
| 9e10f3bf50 | |||
| f410e60235 | |||
| 1d35b14c9d | |||
| aff9a0b258 | |||
| 9ffc55ba13 | |||
| 99ec2eb2dc | |||
| 7e78fb4e7d | |||
| 4bd3dd4311 | |||
| f27883ea4c | |||
| 1e18086c4d |
@@ -27,22 +27,31 @@ jobs:
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: 1
|
||||
run: |
|
||||
apt-get update && apt-get install -y file
|
||||
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
echo "###### Build Web ######"
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
echo "###### Build Collector ######"
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-amd64
|
||||
chmod +x scrutiny-collector-metrics-linux-amd64
|
||||
|
||||
file scrutiny-web-linux-amd64
|
||||
ldd scrutiny-web-linux-amd64 || true
|
||||
file scrutiny-collector-metrics-linux-amd64
|
||||
ldd scrutiny-collector-metrics-linux-amd64 || true
|
||||
- name: Build arm
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: arm
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=arm" -o scrutiny-web-linux-arm -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=arm" -o scrutiny-collector-metrics-linux-arm -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-web-linux-arm -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-collector-metrics-linux-arm -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-arm
|
||||
chmod +x scrutiny-collector-metrics-linux-arm
|
||||
@@ -53,8 +62,8 @@ jobs:
|
||||
GOARCH: arm64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-arm64
|
||||
chmod +x scrutiny-collector-metrics-linux-arm64
|
||||
@@ -74,8 +83,8 @@ jobs:
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-web-freebsd-amd64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-collector-metrics-freebsd-amd64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-web-freebsd-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-collector-metrics-freebsd-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-freebsd-amd64
|
||||
chmod +x scrutiny-collector-metrics-freebsd-amd64
|
||||
|
||||
@@ -29,24 +29,75 @@ jobs:
|
||||
version_bump_type: ${{ github.event.inputs.version_bump_type }}
|
||||
version_metadata_path: ${{ github.event.inputs.version_metadata_path }}
|
||||
github_token: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
- name: Build
|
||||
- name: Test
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
mkdir -p $PROJECT_PATH
|
||||
cp -a $GITHUB_WORKSPACE/. $PROJECT_PATH/
|
||||
cp -a $GITHUB_WORKSPACE/* $PROJECT_PATH/
|
||||
cd $PROJECT_PATH
|
||||
|
||||
go mod vendor
|
||||
|
||||
go test -v -tags "static" $(go list ./... | grep -v /vendor/)
|
||||
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
- name: Build amd64
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-amd64
|
||||
chmod +x scrutiny-collector-metrics-linux-amd64
|
||||
|
||||
- name: Build arm
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: arm
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-web-linux-arm -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-collector-metrics-linux-arm -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-arm
|
||||
chmod +x scrutiny-collector-metrics-linux-arm
|
||||
|
||||
- name: Build arm64
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: arm64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-linux-arm64
|
||||
chmod +x scrutiny-collector-metrics-linux-arm64
|
||||
|
||||
- name: Build windows
|
||||
env:
|
||||
GOOS: windows
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-web-windows-amd64.exe -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-collector-metrics-windows-amd64.exe -tags "static" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
- name: Build freebsd
|
||||
env:
|
||||
GOOS: freebsd
|
||||
GOARCH: amd64
|
||||
run: |
|
||||
cd $PROJECT_PATH
|
||||
go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-web-freebsd-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go
|
||||
go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-collector-metrics-freebsd-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
|
||||
|
||||
chmod +x scrutiny-web-freebsd-amd64
|
||||
chmod +x scrutiny-collector-metrics-freebsd-amd64
|
||||
|
||||
- name: Commit
|
||||
uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
|
||||
with:
|
||||
@@ -71,7 +122,8 @@ jobs:
|
||||
release_name: Release ${{ steps.bump_version.outputs.release_version }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload Web Backend Release Asset
|
||||
|
||||
- name: Release Asset - Web - linux-amd64
|
||||
id: upload-release-asset1
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
@@ -81,7 +133,7 @@ jobs:
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-amd64
|
||||
asset_name: scrutiny-web-linux-amd64
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload Collector Release Asset
|
||||
- name: Release Asset - Collector - linux-amd64
|
||||
id: upload-release-asset2
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
@@ -91,3 +143,67 @@ jobs:
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-amd64
|
||||
asset_name: scrutiny-collector-metrics-linux-amd64
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
|
||||
- name: Release Asset - Web - linux-arm64
|
||||
id: upload-release-asset3
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm64
|
||||
asset_name: scrutiny-web-linux-arm64
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Release Asset - Collector - linux-arm64
|
||||
id: upload-release-asset4
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm64
|
||||
asset_name: scrutiny-collector-metrics-linux-arm64
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: Release Asset - Web - linux-arm
|
||||
id: upload-release-asset5
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm
|
||||
asset_name: scrutiny-web-linux-arm
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Release Asset - Collector - linux-arm
|
||||
id: upload-release-asset6
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm
|
||||
asset_name: scrutiny-collector-metrics-linux-arm
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: Release Asset - Web - freebsd-amd64
|
||||
id: upload-release-asset7
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-freebsd-amd64
|
||||
asset_name: scrutiny-web-freebsd-amd64
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Release Asset - Collector - freebsd-amd64
|
||||
id: upload-release-asset8
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-freebsd-amd64
|
||||
asset_name: scrutiny-collector-metrics-freebsd-amd64
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ scrutiny.db
|
||||
/dist/
|
||||
vendor
|
||||
/scrutiny
|
||||
/scrutiny-collector-metrics-linux-amd64
|
||||
/scrutiny-web-linux-amd64
|
||||
/scrutiny-collector-metrics-*
|
||||
/scrutiny-web-*
|
||||
scrutiny-*.db
|
||||
scrutiny_test.db
|
||||
scrutiny.yaml
|
||||
|
||||
@@ -100,7 +100,7 @@ So you'll need to install the v7+ version using one of the following commands:
|
||||
- **Centos8:**
|
||||
- `dnf install https://extras.getpagespeed.com/release-el8-latest.rpm`
|
||||
- `dnf install smartmontools`
|
||||
|
||||
- **FreeBSD:** `pkg install smartmontools`
|
||||
|
||||
### Directory Structure
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/analogj/go-util/utils"
|
||||
"github.com/analogj/scrutiny/webapp/backend/pkg/config"
|
||||
"github.com/analogj/scrutiny/webapp/backend/pkg/errors"
|
||||
"github.com/analogj/scrutiny/webapp/backend/pkg/web/handler"
|
||||
"github.com/analogj/scrutiny/webapp/backend/pkg/web/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -10,6 +12,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type AppEngine struct {
|
||||
@@ -77,6 +80,13 @@ func (ae *AppEngine) Start() error {
|
||||
logger.SetOutput(io.MultiWriter(os.Stderr, logFile))
|
||||
}
|
||||
|
||||
//check if the database parent directory exists, fail here rather than in a handler.
|
||||
if !utils.FileExists(filepath.Dir(ae.Config.GetString("web.database.location"))) {
|
||||
return errors.ConfigValidationError(fmt.Sprintf(
|
||||
"Database parent directory does not exist. Please check path (%s)",
|
||||
filepath.Dir(ae.Config.GetString("web.database.location"))))
|
||||
}
|
||||
|
||||
r := ae.Setup(logger)
|
||||
|
||||
return r.Run(fmt.Sprintf("%s:%s", ae.Config.GetString("web.listen.host"), ae.Config.GetString("web.listen.port")))
|
||||
|
||||
@@ -164,29 +164,30 @@ func TestPopulateMultiple(t *testing.T) {
|
||||
//assert
|
||||
}
|
||||
|
||||
func TestSendTestNotificationRoute(t *testing.T) {
|
||||
//setup
|
||||
parentPath, _ := ioutil.TempDir("", "")
|
||||
defer os.RemoveAll(parentPath)
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
fakeConfig := mock_config.NewMockInterface(mockCtrl)
|
||||
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db"))
|
||||
fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
|
||||
fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"})
|
||||
ae := web.AppEngine{
|
||||
Config: fakeConfig,
|
||||
}
|
||||
router := ae.Setup(logrus.New())
|
||||
|
||||
//test
|
||||
wr := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}"))
|
||||
router.ServeHTTP(wr, req)
|
||||
|
||||
//assert
|
||||
require.Equal(t, 200, wr.Code)
|
||||
}
|
||||
//TODO: this test should use a recorded request/response playback.
|
||||
//func TestSendTestNotificationRoute(t *testing.T) {
|
||||
// //setup
|
||||
// parentPath, _ := ioutil.TempDir("", "")
|
||||
// defer os.RemoveAll(parentPath)
|
||||
// mockCtrl := gomock.NewController(t)
|
||||
// defer mockCtrl.Finish()
|
||||
// fakeConfig := mock_config.NewMockInterface(mockCtrl)
|
||||
// fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db"))
|
||||
// fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
|
||||
// fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"})
|
||||
// ae := web.AppEngine{
|
||||
// Config: fakeConfig,
|
||||
// }
|
||||
// router := ae.Setup(logrus.New())
|
||||
//
|
||||
// //test
|
||||
// wr := httptest.NewRecorder()
|
||||
// req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}"))
|
||||
// router.ServeHTTP(wr, req)
|
||||
//
|
||||
// //assert
|
||||
// require.Equal(t, 200, wr.Code)
|
||||
//}
|
||||
|
||||
func TestSendTestNotificationRoute_WebhookFailure(t *testing.T) {
|
||||
//setup
|
||||
|
||||
Reference in New Issue
Block a user