4
0
Эх сурвалжийг харах

Merge branch 'main' of ssh://github.com/OliveTin/OliveTin

jamesread 1 жил өмнө
parent
commit
d0eb132b95

+ 1 - 1
.githooks/commit-msg

@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 import sys
 

+ 9 - 1
CONTRIBUTING.adoc

@@ -22,13 +22,21 @@ the general direction and roadmap of this project without asking.
 
 The preferred way to communicate is probably via Discord or GitHub issues.
 
-=== Dev environment setup and clean build - Fedora
+=== Dev environment setup and clean build
 
 ```
+# Step1: setup compile env
+# - Fedora
 dnf install git go protobuf-compiler make -y
+# - Windows with chocolatey
+choco install git go protoc make python nodejs-lts -y
+
+# Step2: clone and setup repo
 git clone https://github.com/OliveTin/OliveTin.git
 cd OliveTin
+make githooks
 
+# Step3: compile binary for current dev env (OS, ARCH)
 # `make grpc` will also run `make go-tools`, which installs "buf". This binary
 # will be put in your GOPATH/bin/, which should be on your path. buf is used to
 # generate the protobuf / grpc stubs.

+ 31 - 11
Makefile

@@ -1,13 +1,26 @@
-compile: daemon-compile-x64-lin
+define delete-files
+	python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)"
+endef
+
+compile: daemon-compile-currentenv
+
+daemon-compile-currentenv:
+	go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin
 
 daemon-compile-armhf:
-	GOARCH=arm GOARM=6 go build -o OliveTin.armhf github.com/OliveTin/OliveTin/cmd/OliveTin
+	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:
-	GOOS=linux go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin
+	go env -w GOOS=linux
+	go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin
+	go env -u GOOS
 
 daemon-compile-x64-win:
-	GOOS=windows GOARCH=amd64 go build -o OliveTin.exe github.com/OliveTin/OliveTin/cmd/OliveTin
+	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
 
@@ -27,7 +40,7 @@ it:
 	cd integration-tests && make
 
 githooks:
-	cp -v .githooks/* .git/hooks/
+	git config --local core.hooksPath .githooks
 
 go-tools:
 	go install "github.com/bufbuild/buf/cmd/buf"
@@ -68,16 +81,23 @@ devcontainer: compile podman-image podman-container
 
 webui-codestyle:
 	cd webui.dev && npm install
-	cd webui.dev && ./node_modules/.bin/eslint main.js js/*
-	cd webui.dev && ./node_modules/.bin/stylelint style.css
+	cd webui.dev && npx eslint main.js js/*
+	cd webui.dev && npx stylelint style.css
 
 webui-dist:
-	rm -rf webui webui.dev/dist
+	$(call delete-files,webui)
+	$(call delete-files,webui.dev/dist)
 	cd webui.dev && npm install
-	cd webui.dev && parcel build --public-url "." && mv dist ../webui
-	cp webui.dev/*.png webui/
+	cd webui.dev && npx parcel build --public-url "."
+	python -c "import shutil;shutil.move('webui.dev/dist', 'webui')"
+	python -c "import shutil;import glob;[shutil.copy(f, 'webui') for f in glob.glob('webui.dev/*.png')]"
 
 clean:
-	rm -rf dist OliveTin OliveTin.armhf OliveTin.exe reports gen
+	$(call delete-files,dist)
+	$(call delete-files,OliveTin)
+	$(call delete-files,OliveTin.armhf)
+	$(call delete-files,OliveTin.exe)
+	$(call delete-files,reports)
+	$(call delete-files,gen)
 
 .PHONY: grpc

+ 7 - 0
internal/config/config_helpers_test.go

@@ -44,3 +44,10 @@ func TestFindAcl(t *testing.T) {
 	assert.NotNil(t, c.FindAcl("Testing ACL"), "Find a ACL that should exist")
 	assert.Nil(t, c.FindAcl("Chocolate Cake"), "Find a ACL that does not exist")
 }
+
+func TestSetDir(t *testing.T) {
+	c := DefaultConfig()
+	c.SetDir("test")
+
+	assert.Equal(t, "test", c.GetDir(), "SetDir")
+}