Merge pull request #89 from AnalogJ/static_binary

pull/77/head
Jason Kulatunga 4 years ago committed by GitHub
commit bd2f305d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,22 +27,31 @@ jobs:
env: env:
GOOS: linux GOOS: linux
GOARCH: amd64 GOARCH: amd64
CGO_ENABLED: 1
run: | run: |
apt-get update && apt-get install -y file
cd $PROJECT_PATH 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 echo "###### Build Web ######"
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 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-web-linux-amd64
chmod +x scrutiny-collector-metrics-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 - name: Build arm
env: env:
GOOS: linux GOOS: linux
GOARCH: arm GOARCH: arm
run: | run: |
cd $PROJECT_PATH 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 "-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 "-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-collector-metrics-linux-arm -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
chmod +x scrutiny-web-linux-arm chmod +x scrutiny-web-linux-arm
chmod +x scrutiny-collector-metrics-linux-arm chmod +x scrutiny-collector-metrics-linux-arm
@ -53,8 +62,8 @@ jobs:
GOARCH: arm64 GOARCH: arm64
run: | run: |
cd $PROJECT_PATH 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 "-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 "-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-collector-metrics-linux-arm64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
chmod +x scrutiny-web-linux-arm64 chmod +x scrutiny-web-linux-arm64
chmod +x scrutiny-collector-metrics-linux-arm64 chmod +x scrutiny-collector-metrics-linux-arm64
@ -74,8 +83,8 @@ jobs:
GOARCH: amd64 GOARCH: amd64
run: | run: |
cd $PROJECT_PATH 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 "-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 "-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-collector-metrics-freebsd-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go
chmod +x scrutiny-web-freebsd-amd64 chmod +x scrutiny-web-freebsd-amd64
chmod +x scrutiny-collector-metrics-freebsd-amd64 chmod +x scrutiny-collector-metrics-freebsd-amd64

@ -100,7 +100,7 @@ So you'll need to install the v7+ version using one of the following commands:
- **Centos8:** - **Centos8:**
- `dnf install https://extras.getpagespeed.com/release-el8-latest.rpm` - `dnf install https://extras.getpagespeed.com/release-el8-latest.rpm`
- `dnf install smartmontools` - `dnf install smartmontools`
- **FreeBSD:** `pkg install smartmontools`
### Directory Structure ### Directory Structure

@ -164,29 +164,30 @@ func TestPopulateMultiple(t *testing.T) {
//assert //assert
} }
func TestSendTestNotificationRoute(t *testing.T) { //TODO: this test should use a recorded request/response playback.
//setup //func TestSendTestNotificationRoute(t *testing.T) {
parentPath, _ := ioutil.TempDir("", "") // //setup
defer os.RemoveAll(parentPath) // parentPath, _ := ioutil.TempDir("", "")
mockCtrl := gomock.NewController(t) // defer os.RemoveAll(parentPath)
defer mockCtrl.Finish() // mockCtrl := gomock.NewController(t)
fakeConfig := mock_config.NewMockInterface(mockCtrl) // defer mockCtrl.Finish()
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db")) // fakeConfig := mock_config.NewMockInterface(mockCtrl)
fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath) // fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db"))
fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"}) // fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
ae := web.AppEngine{ // fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"})
Config: fakeConfig, // ae := web.AppEngine{
} // Config: fakeConfig,
router := ae.Setup(logrus.New()) // }
// router := ae.Setup(logrus.New())
//test //
wr := httptest.NewRecorder() // //test
req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}")) // wr := httptest.NewRecorder()
router.ServeHTTP(wr, req) // req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}"))
// router.ServeHTTP(wr, req)
//assert //
require.Equal(t, 200, wr.Code) // //assert
} // require.Equal(t, 200, wr.Code)
//}
func TestSendTestNotificationRoute_WebhookFailure(t *testing.T) { func TestSendTestNotificationRoute_WebhookFailure(t *testing.T) {
//setup //setup

Loading…
Cancel
Save