summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurenai <[email protected]>2021-10-19 11:37:35 +0800
committerKurenai <[email protected]>2021-10-19 11:47:44 +0800
commit56f71cc23567002c1cba030df73827c96c1b8bbd (patch)
treeffe822a36c27667c1d0d4212ea48afd153424add
parent890ff58b34e8b0b2cf2f537981a1da180c3f8ca6 (diff)
Add workflow build config
-rw-r--r--.github/workflows/build.yml37
-rw-r--r--Makefile33
2 files changed, 70 insertions, 0 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..a2a001d
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,37 @@
+name: Build
+on:
+ push:
+ branches:
+ - workflow-demo
+ workflow_dispatch:
+ pull_request:
+
+jobs:
+
+ lint:
+ name: Lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v1
+ with:
+ go-version: 1.12
+
+ - name: Check out code
+ uses: actions/checkout@v1
+
+ - name: Lint Go Code
+ run: |
+ export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
+ go get -u golang.org/x/lint/golint
+ make lint
+
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ needs: [lint]
+ steps:
+ - name: Set up Go
+ uses: actions/setup-go@v1
+ with:
+ go-version: 1.12
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..68c90d7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,33 @@
+PROJECT_NAME := "MkvAutoSubset"
+PKG := "$(PROJECT_NAME)"
+PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
+GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
+
+.PHONY: all dep lint vet test test-coverage build clean
+
+all: build
+
+dep: ## Get the dependencies
+ @go mod download
+
+lint: ## Lint Golang files
+ @golint -set_exit_status ${PKG_LIST}
+
+vet: ## Run go vet
+ @go vet ${PKG_LIST}
+
+test: ## Run unittests
+ @go test -short ${PKG_LIST}
+
+test-coverage: ## Run tests with coverage
+ @go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}
+ @cat cover.out >> coverage.txt
+
+build: dep ## Build the binary file
+ @go build -i -o build/main $(PKG)
+
+clean: ## Remove previous build
+ @rm -f ./build
+
+help: ## Display this help screen
+ @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' \ No newline at end of file