Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Set default behavior to automatically normalize line endings
* text=auto eol=lf
*.txtar text eol=lf
*.sh text eol=lf
93 changes: 47 additions & 46 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
# More info on config here: https://github.com/golangci/golangci-lint#config-file
run:
deadline: 10s
issues-exit-code: 1
tests: true

# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
version: "2"
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
govet:
shadow: true
golint:
min-confidence: 0
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2

text:
path: stdout
print-linter-name: true
print-issued-lines: true
linters:
disable-all: true
default: none
enable:
- revive
- govet
- errcheck
- unused
- ineffassign
- typecheck
- dupl
- errcheck
- goconst
- gosec
- goimports
- gosimple
- govet
- ineffassign
- revive
- staticcheck
- unused

issues:
exclude-use-default: false
exclude-dirs:
- bin
- vendor
- var
- tmp
exclude-files:
- \.pb\.go$
- \.pb\.goclay\.go$
exclude:
# # _ instead of err checks
# - G104
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv|.*Rollback). is not checked
settings:
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv|.*Rollback). is not checked
paths:
- \.pb\.go$
- \.pb\.goclay\.go$
- bin
- vendor
- var
- tmp
- third_party$
- builtin$
- examples$
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- \.pb\.go$
- \.pb\.goclay\.go$
- bin
- vendor
- var
- tmp
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project_name: launchr
before:
hooks:
- go mod download
- go test ./...
- go test -short ./...
builds:
- main: ./cmd/launchr
env:
Expand Down
167 changes: 150 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,186 @@ LOCAL_BIN:=$(CURDIR)/bin

# Linter config.
GOLANGCI_BIN:=$(LOCAL_BIN)/golangci-lint
GOLANGCI_TAG:=1.64.5
GOLANGCI_TAG:=2.3.0

GOTESTFMT_BIN:=$(GOBIN)/gotestfmt

# Color definitions
RED=\033[0;31m
GREEN=\033[0;32m
YELLOW=\033[0;33m
BLUE=\033[0;34m
MAGENTA=\033[0;35m
CYAN=\033[0;36m
WHITE=\033[0;37m
BOLD=\033[1m
RESET=\033[0m

# Disable colors on Windows.
ifeq ($(OS),Windows_NT)
RED=
GREEN=
YELLOW=
BLUE=
MAGENTA=
CYAN=
WHITE=
BOLD=
RESET=
endif

# Print functions
define print_header
@echo "$(BOLD)$(CYAN)╔═════════════════════════════════════════════════════════════╗$(RESET)"
@echo "$(BOLD)$(CYAN)║ LAUNCHR ║$(RESET)"
@echo "$(BOLD)$(CYAN)╚═════════════════════════════════════════════════════════════╝$(RESET)"
endef

define print_success
@echo "$(BOLD)$(GREEN)✅ $(1)$(RESET)"
@echo
endef

define print_info
@echo "$(BOLD)$(BLUE)📋 $(1)$(RESET)"
@echo
endef

define print_warning
@echo "$(BOLD)$(YELLOW)⚠️ $(1)$(RESET)"
@echo
endef

define print_error
@echo "$(BOLD)$(RED)❌ $(1)$(RESET)"
@echo
endef

define print_step
@echo "$(BOLD)$(MAGENTA)🔧 $(1)$(RESET)"
endef

.PHONY: all
all: deps test build
all: banner deps test-short build
$(call print_success,"🎉 All tasks completed successfully!")

.PHONY: banner
banner:
$(call print_header)
@echo "$(BOLD)$(WHITE)📦 Version: $(APP_VERSION)$(RESET)"
@echo "$(BOLD)$(WHITE)🌿 Branch: $(GIT_BRANCH)$(RESET)"
@echo "$(BOLD)$(WHITE)🔗 Hash: $(GIT_HASH)$(RESET)"
@echo

# Install go dependencies
.PHONY: deps
deps:
$(info Installing go dependencies...)
go mod download
$(call print_step,"Installing go dependencies...")
@go mod download
$(call print_success,"Dependencies installed successfully!")

# Run all tests
.PHONY: test
test:
$(info Running tests...)
go test ./...
test: .install-gotestfmt
$(call print_step,"Running all tests...")
@go test -json -v ./... | $(GOTESTFMT_BIN) -hide all && \
echo "$(BOLD)$(GREEN)🧪 ✅ All tests passed$(RESET)" || \
echo "$(BOLD)$(RED)🧪 ❌ Some tests failed$(RESET)"
@echo

# Run short tests
.PHONY: test-short
test-short: .install-gotestfmt
$(call print_step,"Running short tests...")
@go test -json -short -v ./... | $(GOTESTFMT_BIN) -hide all && \
echo "$(BOLD)$(GREEN)🧪 ✅ All short tests passed$(RESET)" || \
echo "$(BOLD)$(RED)🧪 ❌ Some short tests failed$(RESET)"
@echo

# Build launchr
.PHONY: build
build:
$(info Building launchr...)
$(call print_step,"Building launchr...")
# Application related information available on build time.
$(eval LDFLAGS:=-X '$(GOPKG).name=launchr' -X '$(GOPKG).version=$(APP_VERSION)' $(LDFLAGS_EXTRA))
$(eval BIN?=$(LOCAL_BIN)/launchr)
go generate ./...
$(BUILD_ENVPARMS) go build -ldflags "$(LDFLAGS)" $(BUILD_OPTS) -o $(BIN) ./cmd/launchr
@go generate ./...
@$(BUILD_ENVPARMS) go build -ldflags "$(LDFLAGS)" $(BUILD_OPTS) -o $(BIN) ./cmd/launchr
$(call print_success,"🔨 Build completed: $(BIN)")

# Install launchr
.PHONY: install
install: all
install:
$(info Installing launchr to GOPATH...)
cp $(LOCAL_BIN)/launchr $(GOBIN)/launchr
$(call print_step,"Installing launchr to GOPATH...")
@cp $(LOCAL_BIN)/launchr $(GOBIN)/launchr
$(call print_success,"🚀 launchr installed to $(GOBIN)/launchr")

# Install and run linters
.PHONY: lint
lint: .install-lint .lint
lint: .install-lint .lint-fix

# Install golangci-lint binary
.PHONY: .install-lint
.install-lint:
ifeq ($(wildcard $(GOLANGCI_BIN)),)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCAL_BIN) v$(GOLANGCI_TAG)
$(call print_step,"Installing golangci-lint v$(GOLANGCI_TAG)...")
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCAL_BIN) v$(GOLANGCI_TAG)
$(call print_success,"golangci-lint installed!")
endif

# Install gotestfmt binary
.PHONY: .install-gotestfmt
.install-gotestfmt:
ifeq ($(wildcard $(GOTESTFMT_BIN)),)
$(call print_step,"Installing gotestfmt...")
@go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
$(call print_success,"gotestfmt installed!")
endif

# Runs linters
.PHONY: .lint-fix
.lint-fix:
$(call print_step,"Running linters with auto-fix...")
@$(GOLANGCI_BIN) run --fix ./... && \
echo "$(BOLD)$(GREEN)🔍 ✅ All linting checks passed$(RESET)" || \
echo "$(BOLD)$(YELLOW)🔍 ⚠️ Some linting issues found - please review$(RESET)"
@echo

.PHONY: .lint
.lint:
$(info Running lint...)
$(GOLANGCI_BIN) run --fix ./...
$(call print_step,"Running linters...")
@$(GOLANGCI_BIN) run && \
echo "$(BOLD)$(GREEN)🔍 ✅ All linting checks passed$(RESET)" || \
echo "$(BOLD)$(YELLOW)🔍 ⚠️ Some linting issues found - please review$(RESET)"
@echo

# Clean build artifacts
.PHONY: clean
clean:
$(call print_step,"Cleaning build artifacts...")
@rm -rf $(LOCAL_BIN)
$(call print_success,"🧹 Cleanup completed!")

# Show help
.PHONY: help
help:
$(call print_header)
@echo "$(BOLD)$(WHITE)Available targets:$(RESET)"
@echo ""
@echo " $(BOLD)$(GREEN)all$(RESET) 🎯 Run deps, test, and build"
@echo " $(BOLD)$(GREEN)deps$(RESET) 📦 Install go dependencies"
@echo " $(BOLD)$(GREEN)test$(RESET) 🧪 Run all tests"
@echo " $(BOLD)$(GREEN)test-short$(RESET) ⚡ Run short tests only"
@echo " $(BOLD)$(GREEN)build$(RESET) 🔨 Build launchr binary"
@echo " $(BOLD)$(GREEN)install$(RESET) 🚀 Install launchr to GOPATH"
@echo " $(BOLD)$(GREEN)lint$(RESET) 🔍 Run linters with auto-fix"
@echo " $(BOLD)$(GREEN)clean$(RESET) 🧹 Clean build artifacts"
@echo " $(BOLD)$(GREEN)help$(RESET) ❓ Show this help message"
@echo ""
@echo "$(BOLD)$(CYAN)Environment variables:$(RESET)"
@echo " $(BOLD)$(YELLOW)DEBUG=1$(RESET) Enable debug build"
@echo " $(BOLD)$(YELLOW)BIN=path$(RESET) Custom binary output path"
@echo ""

# Default target shows help
.DEFAULT_GOAL := help
File renamed without changes.
2 changes: 1 addition & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (app *appImpl) gen() error {
// Set absolute paths.
config.WorkDir = launchr.MustAbs(config.WorkDir)
config.BuildDir = launchr.MustAbs(config.BuildDir)
// Change working directory to the selected.
// Change the working directory to the selected.
err = os.Chdir(config.WorkDir)
if err != nil {
return err
Expand Down
Loading