refactor: Project directories (#541)
This commit is contained in:
parent
b4c886d5d3
commit
ff31abe66c
|
|
@ -1,6 +1,9 @@
|
||||||
name: Buf CI
|
name: Buf CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
paths:
|
||||||
|
- 'proto/**'
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened, labeled, unlabeled]
|
types: [opened, synchronize, reopened, labeled, unlabeled]
|
||||||
delete:
|
delete:
|
||||||
|
|
@ -16,13 +19,16 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'service/go.mod'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: grpc
|
- name: grpc
|
||||||
run: make -w grpc
|
run: make -w grpc
|
||||||
|
|
||||||
- uses: bufbuild/buf-action@v1
|
- name: make service
|
||||||
|
run: make -w service
|
||||||
|
|
||||||
|
- uses: bufbuild/buf-action@v1.1.0
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.BUF_TOKEN }}
|
token: ${{ secrets.BUF_TOKEN }}
|
||||||
# Change setup_only to true if you only want to set up the Action and not execute other commands.
|
# Change setup_only to true if you only want to set up the Action and not execute other commands.
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'service/go.mod'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Print go version
|
- name: Print go version
|
||||||
|
|
@ -40,14 +40,14 @@ jobs:
|
||||||
- name: grpc
|
- name: grpc
|
||||||
run: make -w grpc
|
run: make -w grpc
|
||||||
|
|
||||||
- name: make daemon
|
- name: make service
|
||||||
run: make -w daemon-compile-x64-lin
|
run: make -w service
|
||||||
|
|
||||||
- name: make webui
|
- name: make webui
|
||||||
run: make -w webui-dist
|
run: make -w webui-dist
|
||||||
|
|
||||||
- name: unit tests
|
- name: unit tests
|
||||||
run: make -w daemon-unittests
|
run: make -w service-unittests
|
||||||
|
|
||||||
- name: integration tests
|
- name: integration tests
|
||||||
run: cd integration-tests && make -w
|
run: cd integration-tests && make -w
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'service/go.mod'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Print go version
|
- name: Print go version
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'service/go.mod'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: grpc
|
- name: grpc
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'service/go.mod'
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Print go version
|
- name: Print go version
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
**/*.swp
|
**/*.swp
|
||||||
**/*.swo
|
**/*.swo
|
||||||
gen/
|
service/gen/
|
||||||
/OliveTin
|
service/OliveTin
|
||||||
/OliveTin.armhf
|
service/OliveTin.armhf
|
||||||
/OliveTin.exe
|
service/OliveTin.exe
|
||||||
reports
|
service/reports
|
||||||
releases/
|
releases/
|
||||||
dist/
|
dist/
|
||||||
installation-id.txt
|
installation-id.txt
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ project_name: OliveTin
|
||||||
version: 2
|
version: 2
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- go mod download
|
- make service-prep
|
||||||
- go generate ./...
|
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
binary: OliveTin
|
||||||
|
main: main.go
|
||||||
|
dir: service
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- windows
|
- windows
|
||||||
|
|
@ -25,8 +27,6 @@ builds:
|
||||||
- 6
|
- 6
|
||||||
- 7
|
- 7
|
||||||
|
|
||||||
main: cmd/OliveTin/main.go
|
|
||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: arm # Mac does not work on [32bit] arm
|
goarch: arm # Mac does not work on [32bit] arm
|
||||||
|
|
|
||||||
52
Makefile
52
Makefile
|
|
@ -2,52 +2,22 @@ define delete-files
|
||||||
python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)"
|
python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)"
|
||||||
endef
|
endef
|
||||||
|
|
||||||
compile: daemon-compile-currentenv
|
service:
|
||||||
|
$(MAKE) -wC service
|
||||||
|
|
||||||
daemon-compile-currentenv:
|
service-prep:
|
||||||
go build github.com/OliveTin/OliveTin/cmd/OliveTin
|
$(MAKE) -wC service prep
|
||||||
|
|
||||||
daemon-compile-armhf:
|
|
||||||
go env -w GOARCH=arm GOARM=6
|
|
||||||
go build -o OliveTin.armhf github.com/OliveTin/OliveTin/cmd/OliveTin
|
|
||||||
go env -u GOARCH GOARM
|
|
||||||
|
|
||||||
daemon-compile-x64-lin:
|
|
||||||
go env -w GOOS=linux
|
|
||||||
go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin
|
|
||||||
go env -u GOOS
|
|
||||||
|
|
||||||
daemon-compile-x64-win:
|
|
||||||
go env -w GOOS=windows GOARCH=amd64
|
|
||||||
go build -o OliveTin.exe github.com/OliveTin/OliveTin/cmd/OliveTin
|
|
||||||
go env -u GOOS GOARCH
|
|
||||||
|
|
||||||
daemon-compile: daemon-compile-armhf daemon-compile-x64-lin daemon-compile-x64-win
|
|
||||||
|
|
||||||
daemon-codestyle:
|
|
||||||
go fmt ./...
|
|
||||||
go vet ./...
|
|
||||||
gocyclo -over 4 cmd internal
|
|
||||||
gocritic check ./...
|
|
||||||
|
|
||||||
daemon-unittests:
|
|
||||||
$(call delete-files,reports)
|
|
||||||
mkdir reports
|
|
||||||
go test ./... -coverprofile reports/unittests.out
|
|
||||||
go tool cover -html=reports/unittests.out -o reports/unittests.html
|
|
||||||
|
|
||||||
|
service-unittests:
|
||||||
|
$(MAKE) -wC service unittests
|
||||||
|
|
||||||
it:
|
it:
|
||||||
cd integration-tests && make
|
$(MAKE) -wC integration-tests
|
||||||
|
|
||||||
go-tools:
|
go-tools:
|
||||||
go install "github.com/bufbuild/buf/cmd/buf"
|
$(MAKE) -wC service go-tools
|
||||||
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
|
||||||
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
proto: grpc
|
||||||
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
|
|
||||||
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
|
|
||||||
go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
|
|
||||||
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
|
|
||||||
|
|
||||||
grpc: go-tools
|
grpc: go-tools
|
||||||
$(MAKE) -wC proto
|
$(MAKE) -wC proto
|
||||||
|
|
@ -98,4 +68,4 @@ clean:
|
||||||
$(call delete-files,reports)
|
$(call delete-files,reports)
|
||||||
$(call delete-files,gen)
|
$(call delete-files,gen)
|
||||||
|
|
||||||
.PHONY: grpc
|
.PHONY: grpc proto service
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//go:generate make grpc
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
@ -35,10 +35,10 @@ class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
|
||||||
async start (cfg) {
|
async start (cfg) {
|
||||||
let stdout = ""
|
let stdout = ""
|
||||||
let stderr = ""
|
let stderr = ""
|
||||||
|
|
||||||
console.log(" OliveTin starting local process...")
|
console.log(" OliveTin starting local process...")
|
||||||
|
|
||||||
this.ot = spawn('./../OliveTin', ['-configdir', 'configs/' + cfg + '/'])
|
this.ot = spawn('./../service/OliveTin', ['-configdir', 'configs/' + cfg + '/'])
|
||||||
|
|
||||||
let logStdout = false
|
let logStdout = false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
version: v1
|
version: v1
|
||||||
plugins:
|
plugins:
|
||||||
- name: go
|
- name: go
|
||||||
out: ../gen/grpc/
|
out: ../service/gen/grpc/
|
||||||
opt: paths=source_relative
|
opt: paths=source_relative
|
||||||
|
|
||||||
- name: go-grpc
|
- name: go-grpc
|
||||||
out: ../gen/grpc/
|
out: ../service/gen/grpc/
|
||||||
opt: paths=source_relative,require_unimplemented_servers=false
|
opt: paths=source_relative,require_unimplemented_servers=false
|
||||||
|
|
||||||
- name: grpc-gateway
|
- name: grpc-gateway
|
||||||
out: ../gen/grpc/
|
out: ../service/gen/grpc/
|
||||||
opt: paths=source_relative
|
opt: paths=source_relative
|
||||||
|
|
||||||
# - name: swagger
|
# - name: swagger
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# Generated by buf. DO NOT EDIT.
|
# Generated by buf. DO NOT EDIT.
|
||||||
version: v2
|
version: v1
|
||||||
deps:
|
deps:
|
||||||
- name: buf.build/googleapis/googleapis
|
- remote: buf.build
|
||||||
|
owner: googleapis
|
||||||
|
repository: googleapis
|
||||||
commit: 751cbe31638d43a9bfb6162cd2352e67
|
commit: 751cbe31638d43a9bfb6162cd2352e67
|
||||||
digest: b5:51ba5c31f244fd74420f0e66d13f2b5dd6024dcfe1a29dc45bd8f6e61c1444c828b9add9e7dd25a4513ebbee8097a970e0712a2e2cd955c2d60cf8905204f51a
|
digest: shake256:87f55470d9d124e2d1dedfe0231221f4ed7efbc55bc5268917c678e2d9b9c41573a7f9a557f6d8539044524d9fc5ca8fbb7db05eb81379d168285d76b57eb8a4
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version: v2
|
version: v1
|
||||||
deps:
|
deps:
|
||||||
- buf.build/googleapis/googleapis
|
- buf.build/googleapis/googleapis
|
||||||
lint:
|
lint:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ tmp_dir = "tmp"
|
||||||
[build]
|
[build]
|
||||||
args_bin = []
|
args_bin = []
|
||||||
bin = "./OliveTin"
|
bin = "./OliveTin"
|
||||||
cmd = "go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin"
|
cmd = "go build -o OliveTin"
|
||||||
delay = 1
|
delay = 1
|
||||||
exclude_dir = ["assets", "tmp", "vendor", "testdata", "webui.dev", "webui"]
|
exclude_dir = ["assets", "tmp", "vendor", "testdata", "webui.dev", "webui"]
|
||||||
exclude_file = []
|
exclude_file = []
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
define delete-files
|
||||||
|
python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)"
|
||||||
|
endef
|
||||||
|
|
||||||
|
compile-currentenv:
|
||||||
|
go build
|
||||||
|
|
||||||
|
prep:
|
||||||
|
go mod download
|
||||||
|
go generate ./...
|
||||||
|
|
||||||
|
compile-armhf:
|
||||||
|
go env -w GOARCH=arm GOARM=6
|
||||||
|
go build -o OliveTin.armhf
|
||||||
|
go env -u GOARCH GOARM
|
||||||
|
|
||||||
|
compile-x64-lin:
|
||||||
|
go env -w GOOS=linux
|
||||||
|
go build -o OliveTin
|
||||||
|
go env -u GOOS
|
||||||
|
|
||||||
|
compile-x64-win:
|
||||||
|
go env -w GOOS=windows GOARCH=amd64
|
||||||
|
go build -o OliveTin.exe
|
||||||
|
go env -u GOOS GOARCH
|
||||||
|
|
||||||
|
compile: compile-armhf compile-x64-lin compile-x64-win
|
||||||
|
|
||||||
|
codestyle:
|
||||||
|
go fmt ./...
|
||||||
|
go vet ./...
|
||||||
|
gocyclo -over 4 internal
|
||||||
|
gocritic check ./...
|
||||||
|
|
||||||
|
unittests:
|
||||||
|
$(call delete-files,reports)
|
||||||
|
mkdir reports
|
||||||
|
go test ./... -coverprofile reports/unittests.out
|
||||||
|
go tool cover -html=reports/unittests.out -o reports/unittests.html
|
||||||
|
|
||||||
|
go-tools:
|
||||||
|
go install "github.com/bufbuild/buf/cmd/buf"
|
||||||
|
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
||||||
|
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
||||||
|
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
|
||||||
|
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
|
||||||
|
go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
|
||||||
|
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
//go:generate make -wC ../
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
@ -14,5 +14,5 @@ func TestGetWebuiDir(t *testing.T) {
|
||||||
|
|
||||||
dir := findWebuiDir()
|
dir := findWebuiDir()
|
||||||
|
|
||||||
assert.Equal(t, "./webui", dir, "Finding the webui dir")
|
assert.Equal(t, "../webui/", dir, "Finding the webui dir")
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +108,7 @@ func initViperConfig(configDir string) {
|
||||||
viper.SetConfigName("config.yaml")
|
viper.SetConfigName("config.yaml")
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.AddConfigPath(configDir)
|
viper.AddConfigPath(configDir)
|
||||||
|
viper.AddConfigPath("../")
|
||||||
viper.AddConfigPath("/config") // For containers.
|
viper.AddConfigPath("/config") // For containers.
|
||||||
viper.AddConfigPath("/etc/OliveTin/")
|
viper.AddConfigPath("/etc/OliveTin/")
|
||||||
|
|
||||||
Loading…
Reference in New Issue