2023-08-14 13:49:17 +00:00
|
|
|
DOCS_BASE_URL:=/
|
2023-08-14 13:44:23 +00:00
|
|
|
HUGO_VERSION:=0.117.0
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
## Tool Binaries
|
|
|
|
GO_RUN := go run -modfile ./tools/go.mod
|
|
|
|
GO_TEST = $(GO_RUN) gotest.tools/gotestsum --format pkgname
|
|
|
|
GOLANCI_LINT = $(GO_RUN) github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
|
|
|
|
##@ General
|
|
|
|
|
|
|
|
# The help target prints out all targets with their descriptions organized
|
|
|
|
# beneath their categories. The categories are represented by '##@' and the
|
|
|
|
# target descriptions by '##'. The awk commands is responsible for reading the
|
|
|
|
# entire set of makefiles included in this invocation, looking for lines of the
|
|
|
|
# file as xyz: ## something, and then pretty-format the target and help. Then,
|
|
|
|
# if there's a line with ##@ something, that gets pretty-printed as a category.
|
|
|
|
# More info on the usage of ANSI control characters for terminal formatting:
|
|
|
|
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
|
|
|
|
# More info on the awk command:
|
|
|
|
# http://linuxcommand.org/lc3_adv_awk.php
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help: ## Display this help.
|
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
##@ Building
|
|
|
|
|
|
|
|
build_prod: frontend_prod ## Build release binary locally
|
2023-08-14 13:44:23 +00:00
|
|
|
go build \
|
|
|
|
-trimpath \
|
|
|
|
-mod=readonly \
|
|
|
|
-ldflags "-X main.version=$(shell git describe --tags --always || echo dev)"
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
publish: frontend_prod ## Run build tooling to produce all binaries
|
2023-12-15 12:48:49 +00:00
|
|
|
bash ./ci/build.sh
|
2021-04-03 12:11:47 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
##@ Development
|
|
|
|
|
|
|
|
lint: ## Run Linter against code
|
|
|
|
$(GOLANCI_LINT) run ./...
|
|
|
|
|
|
|
|
short_test: ## Run tests not depending on network
|
|
|
|
$(GO_TEST) --hide-summary skipped -- ./... -cover -short
|
2024-04-03 22:15:26 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
test: ## Run all tests
|
|
|
|
$(GO_TEST) --hide-summary skipped -- ./... -cover
|
2021-04-03 12:11:47 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
##@ Editor frontend
|
2021-09-22 13:36:45 +00:00
|
|
|
|
2023-07-14 14:15:58 +00:00
|
|
|
frontend_prod: export NODE_ENV=production
|
2024-09-26 11:07:19 +00:00
|
|
|
frontend_prod: frontend ## Build frontend in production mode
|
2023-07-14 14:15:58 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
frontend: node_modules ## Build frontend
|
2021-12-06 16:25:19 +00:00
|
|
|
node ci/build.mjs
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
frontend_lint: node_modules ## Lint frontend files
|
2021-12-06 16:25:19 +00:00
|
|
|
./node_modules/.bin/eslint \
|
|
|
|
--ext .js,.vue \
|
|
|
|
--fix \
|
|
|
|
src
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
node_modules: ## Install node modules
|
2024-04-13 11:31:41 +00:00
|
|
|
npm ci --include dev
|
2021-09-22 13:36:45 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
##@ Tooling
|
2023-04-07 22:41:00 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
update-chrome-major: ## Patch latest Chrome major version into linkcheck
|
2024-09-05 09:22:26 +00:00
|
|
|
sed -i -E \
|
|
|
|
's/chromeMajor = [0-9]+/chromeMajor = $(shell curl -sSf https://lv.luzifer.io/v1/catalog/google-chrome/stable/version | cut -d '.' -f 1)/' \
|
|
|
|
internal/linkcheck/useragent.go
|
2023-06-12 21:35:54 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
gh-workflow: ## Regenerate CI workflow
|
2024-04-03 22:15:26 +00:00
|
|
|
bash ci/create-workflow.sh
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
##@ Vulnerability scanning
|
2023-06-12 21:35:54 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
trivy: ## Run Trivy against the code
|
2023-06-12 21:35:54 +00:00
|
|
|
trivy fs . \
|
|
|
|
--dependency-tree \
|
|
|
|
--exit-code 1 \
|
|
|
|
--format table \
|
|
|
|
--ignore-unfixed \
|
|
|
|
--quiet \
|
2024-02-18 12:47:29 +00:00
|
|
|
--scanners misconfig,license,secret,vuln \
|
2023-06-12 21:35:54 +00:00
|
|
|
--severity HIGH,CRITICAL \
|
2024-09-26 11:07:19 +00:00
|
|
|
--skip-dirs docs,tools
|
2023-08-14 13:44:23 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
##@ Documentation
|
2023-08-14 13:44:23 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
docs: actor_docs eventclient_docs template_docs ## Generate all documentation
|
2023-08-25 21:37:37 +00:00
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
actor_docs: ## Generate actor documentation
|
2023-08-14 13:44:23 +00:00
|
|
|
go run . --storage-conn-string $(shell mktemp).db actor-docs >docs/content/configuration/actors.md
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
template_docs: ## Generate template function documentation
|
2023-08-25 21:37:37 +00:00
|
|
|
go run . --storage-conn-string $(shell mktemp).db tpl-docs >docs/content/configuration/templating.md
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
eventclient_docs: ## Generate eventclient documentation
|
2023-08-14 13:44:23 +00:00
|
|
|
echo -e "---\ntitle: EventClient\nweight: 10000\n---\n" >docs/content/overlays/eventclient.md
|
|
|
|
docker run --rm -i -v $(CURDIR):$(CURDIR) -w $(CURDIR) node:18-alpine sh -ec 'npx --yes jsdoc-to-markdown --files ./internal/apimodules/overlays/default/eventclient.js' >>docs/content/overlays/eventclient.md
|
|
|
|
|
2024-09-26 11:07:19 +00:00
|
|
|
render_docs: hugo_$(HUGO_VERSION) ## Render documentation site
|
2023-08-14 13:49:17 +00:00
|
|
|
./hugo_$(HUGO_VERSION) \
|
|
|
|
--baseURL "$(DOCS_BASE_URL)" \
|
|
|
|
--cleanDestinationDir \
|
|
|
|
--gc \
|
|
|
|
--source docs
|
2023-08-14 13:44:23 +00:00
|
|
|
|
|
|
|
hugo_$(HUGO_VERSION):
|
|
|
|
curl -sSfL https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_extended_$(HUGO_VERSION)_linux-amd64.tar.gz | tar -xz hugo
|
|
|
|
mv hugo $@
|