GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cli/Makefile at main · kosli-dev/cli Expand file tree/ Copy pathMakefileMore file actions 257 lines (205 loc) · 11.3 KB / Copy pathMakefileFile metadata and controls257 lines (205 loc) · 11.3 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 .PHONY: help build clean clean-cache deps fmt lint vet vet_all docker ldflags ensure_golangci-lint check_dirty add_test_tag build_release ensure_network ensure_gotestsum test_setup test_integration test_integration_full test_integration_single licenses upgrade-deps helm-lint helm-test helm-docs docs release suggest-version-ai .DEFAULT: help .DEFAULT_GOAL := help .DELETE_ON_ERROR: export CGO_ENABLED=0 export GO111MODULE=on LDFLAGS := -w -s BIN := kosli GO_VERSION := $(shell awk '/^go /{print $$2}' go.mod) VET_PLATFORMS ?= linux darwin windows GIT_COMMIT = $(shell git rev-parse HEAD) GIT_SHA = $(shell git rev-parse --short HEAD) GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") GOTESTSUM = $(shell which gotestsum || echo "~/go/bin/gotestsum") # Fake CI env vars so that tests don't emit "Repo information will not be reported" warnings. # These are only used when running tests locally (real CI already sets them). FAKE_CI_ENV = GITHUB_RUN_NUMBER=1 GITHUB_SERVER_URL=https://github.com GITHUB_REPOSITORY=kosli-dev/cli GITHUB_REPOSITORY_ID=123456 # VERSION is the version the binary reports. Unset, we fall back to the tag at # HEAD so a local `make build` in a checked-out release still reports it; passed # on the command line it wins outright, which is how CI stamps the version it # resolved for the build (#1133). Only a command-line assignment counts, so an # ambient VERSION cannot stamp a release: `origin` yields multi-word strings # ("command line", "environment override"), so filter-out, not filter. ifneq ($(filter-out command line override,$(origin VERSION)),) BINARY_VERSION = $(GIT_TAG) else BINARY_VERSION = $(VERSION) endif # Only set Version if we have one; otherwise the binary keeps its "dev" default ifneq ($(BINARY_VERSION),) LDFLAGS += -X github.com/kosli-dev/cli/internal/version.version=${BINARY_VERSION} endif # With a version, report it alone; without one, "dev" plus the short sha. VERSION_METADATA = $(GIT_SHA) ifneq ($(BINARY_VERSION),) VERSION_METADATA = endif LDFLAGS += -X github.com/kosli-dev/cli/internal/version.metadata=${VERSION_METADATA} LDFLAGS += -X github.com/kosli-dev/cli/internal/version.gitCommit=${GIT_COMMIT} LDFLAGS += -X github.com/kosli-dev/cli/internal/version.gitTreeState=${GIT_DIRTY} LDFLAGS += -extldflags "-static" help: ## Show this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \ /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-21s\033[0m %s\n", $$1, $$2 } \ /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST) ldflags: ## Print ldflags @echo $(LDFLAGS) fmt: ## Reformat package sources # Mirrors the gofmt rewrite rule in .golangci.yml so fmt can fix what lint rejects. # gofmt is used directly because golangci-lint is not available where `make build` runs (Dockerfile). @gofmt -l -w -r 'interface{} -> any' $$(go list -f '{{.Dir}}' ./...) ensure_golangci-lint: @if command -v brew >/dev/null 2>&1; then \ if brew ls --versions golangci-lint >/dev/null 2>&1; then \ HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade golangci-lint; \ else \ HOMEBREW_NO_AUTO_UPDATE=1 brew install golangci-lint; \ fi; \ elif command -v golangci-lint >/dev/null 2>&1; then \ echo "Homebrew not found; using the golangci-lint already on PATH."; \ else \ echo "golangci-lint not found, and Homebrew is unavailable to install it."; \ echo "Install a build that matches this repo's Go version with:"; \ echo " GOTOOLCHAIN=go$(GO_VERSION) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest"; \ exit 1; \ fi lint: deps vet ensure_golangci-lint ## Run linting @golangci-lint run --color always -v ./... vet: fmt ## Run Go vet @go vet ./... vet_all: ## Run Go vet for each of VET_PLATFORMS (default: linux darwin windows) @status=0; for goos in $(VET_PLATFORMS); do \ echo "go vet GOOS=$$goos"; \ GOOS=$$goos go vet ./... || status=1; \ done; exit $$status deps: ## Install depdendencies. Runs `go get` internally. @GOFLAGS="" go mod download @GOFLAGS="" go mod tidy build: deps vet ## Build the binary @go build -o $(BIN) -ldflags '$(LDFLAGS)' ./cmd/kosli/ check_dirty: @git diff-index --quiet HEAD -- || echo "Cannot test release with dirty git repo" @git diff-index --quiet HEAD -- add_test_tag: @git tag -d v0.0.99 2> /dev/null || true @git tag v0.0.99 build_release: check_dirty add_test_tag rm -rf dist/ goreleaser release --skip=publish,changelog --verbose @git tag -d v0.0.99 2> /dev/null || true clean: ## Clean build artefacts rm -rf $(BIN) dist/ clean-cache: ## Clean Golang mod cache go clean -modcache ensure_network: docker network inspect cli_net > /dev/null || docker network create --driver bridge cli_net ensure_gotestsum: @go install gotest.tools/gotestsum@latest clear_local_image_ref: rm /tmp/server-image.txt test_setup: ensure_gotestsum # cat and exit if error @test -f /tmp/server-image.txt || ./hack/get-server-image.sh /tmp/server-image.txt export KOSLI_SERVER_IMAGE=$$(cat /tmp/server-image.txt) && ./bin/reset-or-start-server.sh test_setup_restart_server: ensure_gotestsum # cat and exit if error @test -f /tmp/server-image.txt || ./hack/get-server-image.sh /tmp/server-image.txt export KOSLI_SERVER_IMAGE=$$(cat /tmp/server-image.txt) && ./bin/reset-or-start-server.sh force setup_test_to_use_local_image: @echo merkely-test > /tmp/server-image.txt @KOSLI_SERVER_IMAGE=merkely-test docker compose down -v @echo "Run make build in the server repo you want to use" @echo "Then run make test_integration" @echo "To look at the logs from local kosli server run: make follow_integration_test_server" setup_test_to_use_staging_server_image: @rm -f /tmp/server-image.txt @KOSLI_SERVER_IMAGE=placeholder docker compose down -v @echo "Now run make test_integration" @echo "To look at the logs from kosli server run: make follow_integration_test_server" test_integration: deps vet ensure_network test_setup ## Run tests except the too slow ones @[ -e ~/.kosli.yml ] && mv ~/.kosli.yml ~/.kosli-renamed.yml || true @export KOSLI_TESTS=true $(FAKE_CI_ENV) && $(GOTESTSUM) -- --short -p=8 -coverprofile=cover.out ./... @go tool cover -func=cover.out | grep total: @go tool cover -html=cover.out @[ -e ~/.kosli-renamed.yml ] && mv ~/.kosli-renamed.yml ~/.kosli.yml || true test_integration_full: deps vet ensure_network test_setup ## Run all tests @[ -e ~/.kosli.yml ] && mv ~/.kosli.yml ~/.kosli-renamed.yml || true @mkdir -p junit-test-results @export KOSLI_TESTS=true $(FAKE_CI_ENV) && $(GOTESTSUM) --junitfile junit-test-results/junit.xml -- -p=8 -coverprofile=cover.out ./... @go tool cover -func=cover.out @[ -e ~/.kosli-renamed.yml ] && mv ~/.kosli-renamed.yml ~/.kosli.yml || true test_integration_restart_server: test_setup_restart_server @[ -e ~/.kosli.yml ] && mv ~/.kosli.yml ~/.kosli-renamed.yml || true @export KOSLI_TESTS=true $(FAKE_CI_ENV) && $(GOTESTSUM) -- --short -p=8 -coverprofile=cover.out ./... @go tool cover -html=cover.out @[ -e ~/.kosli-renamed.yml ] && mv ~/.kosli-renamed.yml ~/.kosli.yml || true test_integration_single: test_setup @export KOSLI_TESTS=true $(FAKE_CI_ENV) && $(GOTESTSUM) -- -p=1 ./... -run "${TARGET}" test_contract_aws: ensure_gotestsum ## Run AWS contract tests against real AWS (requires AWS creds) @echo "Running AWS contract tests against real AWS..." @echo "Requires AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to be set" @$(GOTESTSUM) -- -v -p=1 -run "LambdaContract_RealAWS|S3Contract_RealAWS|AWSTestSuite/TestGetLambdaPackageData|AWSTestSuite/TestGetEcsTasksData|AWSTestSuite/TestGetS3Data" ./internal/aws/ test_contract_github: ensure_gotestsum ## Run GitHub contract tests against real GitHub API (requires KOSLI_GITHUB_TOKEN) @echo "Running GitHub contract tests against real GitHub API..." @echo "Requires KOSLI_GITHUB_TOKEN to be set" @$(GOTESTSUM) -- -v -p=1 -run "GitHubContract_RealGitHub" ./internal/github/ test_contract: test_contract_aws test_contract_github ## Run all contract tests against real external services logs_integration_test_server: @docker logs cli_kosli_server ${CONTAINER} 2>&1 follow_integration_test_server: @docker logs cli_kosli_server -f ${CONTAINER} 2>&1 enter_integration_test_server: @docker exec -it --workdir / cli_kosli_server bash # The image never reads git tags itself, so pass the tag at HEAD in. docker: ## Build CLI Docker image @docker build -t kosli-cli --build-arg VERSION="$(GIT_TAG)" . licenses: ## Update licenses @rm -rf licenses || true @go install github.com/google/go-licenses@latest @go-licenses save ./... --save_path="licenses/" || true $(eval DATA := $(shell go-licenses csv ./...)) @echo $(DATA) | tr " " "\n" > licenses/licenses.csv upgrade-deps: ## Update Go dependencies @go get -u ./... helm-lint: ## Lint Helm chart @cd charts/k8s-reporter && helm lint . \ --set reporterConfig.kosliOrg=placeholder \ --set 'reporterConfig.environments[0].name=placeholder' helm-test: ## Test Helm chart rendering (requires helm and yq) @./scripts/test-helm-chart.sh helm-docs: helm-lint ## Update Helm docs @cd charts/k8s-reporter && docker run --rm --volume "$(PWD):/helm-docs" jnorwood/helm-docs:latest --template-files README.md.gotmpl,_templates.gotmpl --output-file README.md docs: build ## Generate CLI reference docs (use CMD="attest snyk" for one command) @mkdir -p client_reference @./kosli docs --dir client_reference $(CMD) @echo "Docs written to client_reference/" # Suggest next semver and changelog using Claude. # Writes changelog to dist/release_notes.md, used as the annotated tag's body. # Requires: jq, curl, op (1Password CLI). API key from 1Password via op. # Usage: make suggest-version-ai [BASE_REF=v1.2.3] suggest-version-ai: ## Suggest next version using AI @command -v jq >/dev/null 2>&1 || (echo "Install jq (e.g. brew install jq)" && exit 1) @command -v curl >/dev/null 2>&1 || (echo "Install curl (e.g. brew install curl)" && exit 1) @bin/suggest-version-ai.sh $(BASE_REF) -o dist/release_notes.md # Release: without tag → suggest version + changelog, then interactive edit & confirm, then tag and push. # With tag → escape hatch: create annotated tag (body = dist/release_notes.md if present), push. No AI, no prompt. # Release notes are carried in the tag message so GitHub Actions can pass them to GoReleaser. release: ## Cut a new release and push next tag @current=$$(git branch --show-current 2>/dev/null || git rev-parse --abbrev-ref HEAD); \ if [ "$$current" != "main" ]; then echo "ERROR: release must be run from main branch (current: $$current)"; exit 1; fi; \ if [ -z "$(tag)" ]; then \ command -v jq >/dev/null 2>&1 || (echo "Install jq (e.g. brew install jq)" && exit 1); \ command -v curl >/dev/null 2>&1 || (echo "Install curl (e.g. brew install curl)" && exit 1); \ bin/suggest-version-ai.sh -o dist/release_notes.md; \ if [ ! -f dist/suggested_version ]; then \ echo "Suggestion failed or no previous tag. Use: make release tag=vX.Y.Z"; exit 1; \ fi; \ bin/release-interactive.sh; \ else \ git remote update; \ git status -uno | grep --silent "Your branch is up to date" || (echo "ERROR: your branch is NOT up to date with remote" && exit 1); \ ([ -f dist/release_notes.md ] && git tag -a $(tag) --cleanup=verbatim -F dist/release_notes.md) || git tag -a $(tag) -m"$(tag)"; \ git push origin $(tag); \ fi |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |