-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add internal task builder * Add MacOS, Linux and Windows task files * Update Taskfile.yml with new tasks * Use new tasks in build workflow * Update prod build flags and fix VERSION handling in internal build task * Add a task for generating MS required directories * Improve MS build in build workflow to build as production only on releases * Replace `summary` with `desc` and add some missing desc for tasks * Fix build error due to internal include working dir
- Loading branch information
1 parent
22d0d44
commit 531d35e
Showing
6 changed files
with
188 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,59 @@ | ||
version: '3' | ||
version: "3" | ||
|
||
vars: | ||
APP_NAME: "massastation" | ||
BIN_DIR: "./build/{{.APP_NAME}}" | ||
|
||
includes: | ||
darwin: tasks/Taskfile_darwin.yml | ||
linux: tasks/Taskfile_linux.yml | ||
windows: tasks/Taskfile_windows.yml | ||
internal: | ||
taskfile: tasks/Taskfile_internal.yml | ||
internal: true | ||
|
||
tasks: | ||
install: | ||
desc: Installs build dependencies | ||
cmds: | ||
- echo "Installing dependencies" | ||
- cmd: go install github.com/go-swagger/go-swagger/cmd/swagger@latest | ||
- cmd: go install golang.org/x/tools/cmd/stringer@latest | ||
- cmd: go install go.uber.org/mock/[email protected] | ||
|
||
install-dev: | ||
desc: Installs development dependencies (fmt, lint, etc.) | ||
cmds: | ||
- cmd: go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
- cmd: go install github.com/daixiang0/gci@latest | ||
- cmd: go install mvdan.cc/gofumpt@latest | ||
- task: install-dev-win | ||
|
||
install-dev-win: | ||
desc: Installs Windows development dependencies | ||
platforms: [windows] | ||
cmds: | ||
- cmd: mkdir -p build/massastation | ||
- cmd: curl -o build/massastation/mar-tools-win64.zip https://archive.torproject.org/tor-package-archive/torbrowser/12.5.1/mar-tools-win64.zip | ||
|
||
generate: go generate ./... | ||
generate: | ||
cmds: | ||
- task: generate-dirs | ||
- cmd: go generate ./... | ||
|
||
test: | ||
test: | ||
cmds: | ||
- cmd: go test -v -timeout 60s ./... | ||
|
||
test-2e2: | ||
cmds: | ||
- cmd: scripts/test-e2e.sh | ||
|
||
test-coverage: | ||
test-coverage: | ||
cmds: | ||
- cmd: go test -timeout 60s ./... -coverprofile=coverage.coverprofile | ||
|
||
fmt: | ||
desc: Formats all files | ||
cmds: | ||
- cmd: go mod tidy | ||
- cmd: gofumpt -l -w . | ||
|
@@ -44,52 +62,55 @@ tasks: | |
- cmd: golangci-lint run --fix | ||
|
||
fmt-web: | ||
desc: Formats web files | ||
dir: web/massastation | ||
cmds: | ||
- cmd: npm run fmt | ||
|
||
build: | ||
cmds: | ||
- task: build-linux | ||
- task: build-macos | ||
- task: build-windows | ||
|
||
build-linux: | ||
platforms: [linux] | ||
cmds: | ||
- cmd: mkdir -p build/massastation | ||
- cmd: go build -o build/massastation/massastation cmd/massastation/main.go | ||
- cmd: sudo setcap CAP_NET_BIND_SERVICE=+eip build/massastation/massastation | ||
|
||
build-macos: | ||
platforms: [darwin] | ||
cmds: | ||
- cmd: mkdir -p build/massastation | ||
- cmd: go build -o build/massastation/massastation cmd/massastation/main.go | ||
|
||
build-windows: | ||
platforms: [windows] | ||
cmds: | ||
- cmd: mkdir -p build/massastation | ||
- cmd: mkdir -p build/massastation/logs | ||
- cmd: mkdir -p build/massastation/certs | ||
- cmd: go build -o build/massastation/massastation.exe cmd/massastation/main.go | ||
|
||
run: | ||
desc: Runs MassaStation in DEBUG mode | ||
cmds: | ||
- cmd: "{{.BIN_DIR}}/{{.APP_NAME}}{{.BIN_EXT}}" | ||
vars: | ||
BIN_EXT: '{{if eq .OS "windows"}}.exe{{end}}' | ||
env: | ||
LOG_LEVEL: DEBUG | ||
|
||
build: | ||
desc: Builds MassaStation | ||
cmds: | ||
- cmd: ./build/massastation/massastation | ||
platforms: [linux, darwin] | ||
- cmd: ./build/massastation/massastation.exe | ||
platforms: [windows] | ||
- task: linux:int-build | ||
- task: darwin:int-build | ||
- task: windows:int-build | ||
|
||
build-run: | ||
desc: Builds and runs MassaStation | ||
cmds: | ||
- task: build | ||
- task: run | ||
|
||
package: | ||
desc: Packages MassaStation using fyne | ||
platforms: [linux, darwin] | ||
cmds: | ||
- cmd: fyne package -name MassaStation -icon ./int/systray/embedded/logo.png -appID net.massalabs.massastation -exe massastation | ||
|
||
generate-dirs: | ||
desc: Generates required directories for MassaStation | ||
cmds: | ||
- cmd: "{{.SUDO}} mkdir -p {{.CONFIG_DIR}}" | ||
- cmd: "{{.SUDO}} mkdir -p {{.CONFIG_DIR}}/logs" | ||
- cmd: "{{.SUDO}} mkdir -p {{.CONFIG_DIR}}/plugins" | ||
status: | ||
- test -d "{{.CONFIG_DIR}}" | ||
- test -d "{{.CONFIG_DIR}}/logs" | ||
- test -d "{{.CONFIG_DIR}}/plugins" | ||
vars: | ||
CONFIG_DIR: '{{if eq OS "windows"}}{{.BIN_DIR}}{{else}}/usr/local/share/massastation{{end}}' | ||
SUDO: '{{if ne OS "windows"}}sudo{{end}}' | ||
|
||
all: | ||
desc: Runs install, generate, build-run | ||
cmds: | ||
- task: install | ||
- task: generate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: "3" | ||
|
||
includes: | ||
internal: | ||
taskfile: ./Taskfile_internal.yml | ||
internal: true | ||
dir: .. | ||
|
||
tasks: | ||
int-build: | ||
desc: Internal build task for macOS | ||
platforms: [darwin] | ||
internal: true | ||
cmds: | ||
- cmd: echo BUILDING FOR macOS $GOARCH | ||
- task: build | ||
|
||
build: | ||
desc: Builds MassaStation for macOS | ||
cmds: | ||
- task: internal:build | ||
vars: | ||
OS: darwin | ||
ARCH: '{{.ARCH | default ""}}' | ||
|
||
build-prod: | ||
desc: Builds MassaStation for macOS (production) | ||
cmds: | ||
- task: internal:build-prod | ||
vars: | ||
OS: darwin | ||
ARCH: '{{.ARCH | default ""}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: "3" | ||
|
||
tasks: | ||
build: | ||
desc: Internal build task | ||
internal: true | ||
cmds: | ||
- cmd: echo Building MassaStation for {{.OS | default OS}}/{{.ARCH | default ARCH}} | ||
- cmd: go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}{{.BIN_EXT}} ./cmd/massastation/main.go | ||
vars: | ||
# We need this check for nil and empty string because a simple check for empty string doesn't work as expected | ||
VERSION_FLAG: '{{if ne .VERSION nil}}{{if ne .VERSION ""}}-X github.com/massalabs/station/int/config.Version={{.VERSION}}{{end}}{{end}}' | ||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production {{end}}-ldflags="{{.VERSION_FLAG}}{{if eq .PRODUCTION "true"}} -w -s{{end}}"' | ||
BIN_EXT: '{{if eq .OS "windows"}}.exe{{end}}' | ||
env: | ||
GOOS: "{{.OS | default OS}}" | ||
GOARCH: "{{.ARCH | default ARCH}}" | ||
PRODUCTION: '{{.PRODUCTION | default "false"}}' | ||
VERSION: "{{.VERSION | default nil}}" | ||
|
||
build-prod: | ||
desc: Builds MassaStation (production) | ||
preconditions: | ||
- sh: test -n "{{.VERSION}}" | ||
msg: "VERSION is required" | ||
cmds: | ||
- task: build | ||
vars: | ||
OS: "{{.OS | default OS}}" | ||
ARCH: "{{.ARCH | default ARCH}}" | ||
PRODUCTION: true | ||
VERSION: '{{.VERSION | default ""}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "3" | ||
|
||
includes: | ||
internal: | ||
taskfile: ./Taskfile_internal.yml | ||
internal: true | ||
dir: .. | ||
|
||
tasks: | ||
int-build: | ||
desc: Internal build task for Linux | ||
platforms: [linux] | ||
internal: true | ||
cmds: | ||
- task: build | ||
|
||
build: | ||
desc: Builds MassaStation for Linux | ||
cmds: | ||
- task: internal:build | ||
vars: | ||
OS: linux | ||
- cmd: sudo setcap CAP_NET_BIND_SERVICE=+eip {{.BIN_DIR}}/{{.APP_NAME}} || true | ||
|
||
build-prod: | ||
desc: Builds MassaStation for Linux (production) | ||
cmds: | ||
- task: internal:build-prod | ||
vars: | ||
OS: linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: "3" | ||
|
||
includes: | ||
internal: | ||
taskfile: ./Taskfile_internal.yml | ||
internal: true | ||
dir: .. | ||
|
||
tasks: | ||
int-build: | ||
desc: Internal build task for Windows | ||
platforms: [windows] | ||
internal: true | ||
cmds: | ||
- task: build | ||
|
||
build: | ||
desc: Builds MassaStation for Windows | ||
cmds: | ||
- task: internal:build | ||
vars: | ||
OS: windows | ||
|
||
build-prod: | ||
desc: Builds MassaStation for Windows (production) | ||
cmds: | ||
- task: internal:build-prod | ||
vars: | ||
OS: windows |