mirror of
https://github.com/go-sigma/sigma.git
synced 2026-10-28 13:34:34 +08:00
Run the self-hosted rs3 service instead of Minio in test.yml and swap the local helper script, Makefile helm values, and AGENTS.md notes accordingly. Fix the E2E workflow (refs #426): it only triggered on the `main` branch, which does not exist in this repository, so the job never ran. Trigger it on `dev` for both push and pull_request like test.yml, build the image via the consolidated `make docker-build`, bump the checkout/setup-go actions, drop the hosted-toolcache cleanup, and refresh the E2E tooling to k6 v2.3.0 and skopeo v1.24.1. Repair the image startup path as well: start nginx with an explicit /etc/nginx/nginx.conf and a /dev/stderr error log so the non-root user does not touch the compiled-in log path, create /etc/sigma with mode 0755 before copying config.yaml (COPY --chmod made the directory non-traversable), and disable redis in the shipped default config since cache, locker and work queue are inmemory.
152 lines
6.1 KiB
Makefile
152 lines
6.1 KiB
Makefile
BINARY_NAME = sigma
|
|
CLI_BINARY_NAME = $(BINARY_NAME)-cli
|
|
VERSION ?= $(shell git describe --tags --always)
|
|
SERVICE_PORT ?= 3000
|
|
DOCKER_REGISTRY ?= ghcr.io/go-sigma
|
|
|
|
APPNAME ?= sigma
|
|
NAMESPACE ?= sigma
|
|
KUBECONFIG ?= ~/.kube/config
|
|
REPOSITORY ?= ghcr.io/go-sigma/sigma
|
|
TAG ?= nightly-alpine
|
|
MIGRATION_NAME ?=
|
|
RANDOM_PASSWORD := $(shell openssl rand -base64 6 | tr -d '/+' | tr '[:upper:]' '[:lower:]' | head -c 8)
|
|
|
|
SHELL := /bin/bash
|
|
|
|
GREEN := $(shell tput -Txterm setaf 2)
|
|
YELLOW := $(shell tput -Txterm setaf 3)
|
|
WHITE := $(shell tput -Txterm setaf 7)
|
|
CYAN := $(shell tput -Txterm setaf 6)
|
|
RESET := $(shell tput -Txterm sgr0)
|
|
|
|
GOLDFLAGS += -X github.com/go-sigma/sigma/pkg/version.Version=$(shell git describe --tags --always)
|
|
GOLDFLAGS += -X github.com/go-sigma/sigma/pkg/version.BuildDate=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
GOLDFLAGS += -X github.com/go-sigma/sigma/pkg/version.GitHash=$(shell git rev-parse --short HEAD)
|
|
GOFLAGS = -ldflags '-s -w $(GOLDFLAGS)' -trimpath
|
|
|
|
GOOS ?= $(shell go env GOOS)
|
|
DOCKER_GOOS ?= $(if $(filter darwin,$(GOOS)),linux,$(GOOS))
|
|
GOARCH ?= $(shell go env GOARCH)
|
|
CC ?=
|
|
CXX ?=
|
|
|
|
DOCKER_PLATFORMS ?= $(DOCKER_GOOS)/$(GOARCH)
|
|
USE_MIRROR ?= false
|
|
|
|
.PHONY: all
|
|
all: build
|
|
|
|
## Build:
|
|
.PHONY: build
|
|
build: ## Build sigma and put the output binary in ./bin
|
|
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=1 GO111MODULE=on CC="$(CC)" CXX="$(CXX)" go build $(GOFLAGS) -tags "netgo,timetzdata,exclude_graphdriver_btrfs,containers_image_openpgp" -o bin/$(BINARY_NAME) -v .
|
|
|
|
.PHONY: build-cli
|
|
build-cli: ## Build sigma CLI and put the output binary in ./bin
|
|
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build $(GOFLAGS) -o bin/$(CLI_BINARY_NAME) -v ./cmd/cli
|
|
|
|
.PHONY: clean
|
|
clean: ## Remove build output files
|
|
$(RM) ./bin/sigma ./bin/sigma-cli
|
|
|
|
.PHONY: vendor
|
|
vendor: ## Tidy Go module dependencies
|
|
@go mod tidy
|
|
|
|
## Lint:
|
|
.PHONY: lint
|
|
lint: lint-go lint-dockerfile ## Run all available linters
|
|
|
|
.PHONY: lint-dockerfile
|
|
lint-dockerfile: ## Lint Dockerfiles
|
|
@hadolint --ignore DL3006 $(shell find build -name "Dockerfile*")
|
|
|
|
.PHONY: lint-go
|
|
lint-go: ## Run golangci-lint
|
|
@golangci-lint run --timeout=10m --build-tags "netgo,timetzdata,exclude_graphdriver_btrfs,containers_image_openpgp"
|
|
|
|
## Docker:
|
|
.PHONY: docker-build
|
|
docker-build: ## Build sigma Docker images
|
|
docker buildx build --file ./build/Dockerfile --target sigma-server \
|
|
--platform $(DOCKER_PLATFORMS) \
|
|
--build-arg USE_MIRROR=$(USE_MIRROR) \
|
|
--progress plain --provenance false --sbom false --load -t $(REPOSITORY):$(TAG) .
|
|
docker buildx build --file ./build/Dockerfile --target sigma-builder \
|
|
--platform $(DOCKER_PLATFORMS) \
|
|
--build-arg USE_MIRROR=$(USE_MIRROR) \
|
|
--progress plain --provenance false --sbom false --load -t $(REPOSITORY)-builder:$(TAG) .
|
|
|
|
## Misc:
|
|
.PHONY: migration-create
|
|
migration-create: ## Create a new migration file
|
|
@migrate create -dir ./pkg/dal/migrations/mysql -seq -digits 4 -ext sql $(MIGRATION_NAME)
|
|
|
|
.PHONY: sql-format
|
|
sql-format: ## Format SQL migrations and GC fixtures
|
|
@find ${PWD}/pkg/dal/migrations/mysql -type f -iname "*.sql" | xargs -n1 sql-formatter -l mysql --fix
|
|
@find ${PWD}/pkg/dal/migrations/sqlite3 -type f -iname "*.sql" | xargs -n1 sql-formatter -l sqlite --fix
|
|
@find ${PWD}/pkg/dal/migrations/turso -type f -iname "*.sql" | xargs -n1 sql-formatter -l sqlite --fix
|
|
@find ${PWD}/pkg/dal/migrations/postgresql -type f -iname "*.sql" | xargs -n1 sql-formatter -l postgresql --fix
|
|
@find ${PWD}/pkg/background/daemon/gc/testdata -type f -name "*.mysql.sql" | xargs -n1 sql-formatter -l mysql --fix
|
|
@find ${PWD}/pkg/background/daemon/gc/testdata -type f \( -name "*.sqlite3.sql" -o -name "*.turso.sql" \) | xargs -n1 sql-formatter -l sqlite --fix
|
|
@find ${PWD}/pkg/background/daemon/gc/testdata -type f -name "*.postgresql.sql" | xargs -n1 sql-formatter -l postgresql --fix
|
|
|
|
.PHONY: changelog
|
|
changelog: ## Generate changelog
|
|
# brew install git-cliff
|
|
@git-cliff --config cliff.toml --tag $(VERSION) --output CHANGELOG.md
|
|
|
|
.PHONY: gormgen
|
|
gormgen: ## Generate GORM models from the database schema
|
|
@go run ./pkg/dal/cmd/gen.go
|
|
|
|
.PHONY: swagen
|
|
swagen: ## Generate Swagger documentation from code comments
|
|
@go tool swag fmt
|
|
@go tool swag init --output tools/skill/sigma-api-operator --outputTypes yaml
|
|
|
|
.PHONY: addlicense
|
|
addlicense: ## Add license headers to source files
|
|
@find pkg -type f -name "*.go" | grep -v "pkg/handlers/apidocs/docs.go" | xargs go tool addlicense -l apache -y 2026 -c "sigma"
|
|
@find cmd -type f -name "*.go" | xargs go tool addlicense -l apache -y 2026 -c "sigma"
|
|
@go tool addlicense -l apache -y 2026 -c "sigma" main.go
|
|
@go tool addlicense -l apache -y 2026 -c "sigma" web/web.go
|
|
@find web/src -type f -name "*.tsx" | xargs go tool addlicense -l apache -y 2026 -c "sigma"
|
|
@find web/src -type f -name "*.ts" | xargs go tool addlicense -l apache -y 2026 -c "sigma"
|
|
@find web/src -type f -name "*.css" | xargs go tool addlicense -l apache -y 2026 -c "sigma"
|
|
|
|
## Kube:
|
|
.PHONY: kube_install
|
|
kube_install: ## Install sigma on Kubernetes using Helm
|
|
@if [ -z $(KUBECONFIG) ]; then \
|
|
KUBECONFIG=$$HOME/.kube/config; \
|
|
fi;
|
|
@helm upgrade --install $(APPNAME) ./deploy/sigma --create-namespace --namespace $(NAMESPACE) \
|
|
--set image.repository=$(REPOSITORY) \
|
|
--set image.tag=$(TAG) \
|
|
--set mysql.auth.rootPassword=$(RANDOM_PASSWORD) \
|
|
--set mysql.auth.password=$(RANDOM_PASSWORD) \
|
|
--set redis.auth.password=$(RANDOM_PASSWORD) \
|
|
--set rs3.s3.sk=$(RANDOM_PASSWORD) \
|
|
--kubeconfig $(KUBECONFIG)
|
|
|
|
.PHONY: kube_uninstall
|
|
kube_uninstall: ## Uninstall sigma from Kubernetes using Helm
|
|
@KUBECONFIG=$(KUBECONFIG)
|
|
@helm uninstall $(APPNAME) -n$(NAMESPACE)
|
|
|
|
## Help:
|
|
.PHONY: help
|
|
help: ## Show this help
|
|
@echo ''
|
|
@echo 'Usage:'
|
|
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
|
|
@echo ''
|
|
@echo 'Targets:'
|
|
@awk 'BEGIN {FS = ":.*?## "} { \
|
|
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-30s${GREEN}%s${RESET}\n", $$1, $$2} \
|
|
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
|
|
}' $(MAKEFILE_LIST)
|