GOLANGCI_LINT_VERSION=v1.48.0 LINTER=./bin/golangci-lint LINTER_VERSION_FILE=./bin/.golangci-lint-version-$(GOLANGCI_LINT_VERSION) TEST_BINARY=./go-server-sdk.test ALLOCATIONS_LOG=./build/allocations.out OUTPUT_DIR=./build ALL_SOURCES := $(shell find * -type f -name "*.go") COVERAGE_PROFILE_RAW=./build/coverage_raw.out COVERAGE_PROFILE_RAW_HTML=./build/coverage_raw.html COVERAGE_PROFILE_FILTERED=./build/coverage.out COVERAGE_PROFILE_FILTERED_HTML=./build/coverage.html COVERAGE_ENFORCER_FLAGS=-package github.com/launchdarkly/go-server-sdk/v6 \ -skipfiles '(internal/sharedtest/$(COVERAGE_ENFORCER_SKIP_FILES_EXTRA))' \ -skipcode "// COVERAGE" \ -packagestats -filestats -showcode .PHONY: build clean test test-coverage benchmarks benchmark-allocs lint build: go build ./... clean: go clean test: go test -run=not-a-real-test ./... # just ensures that the tests compile go test -v -race ./... @# The proxy tests must be run separately because Go caches the global proxy environment variables. We use @# build tags to isolate these tests from the main test run so that if you do "go test ./..." you won't @# get unexpected errors. for tag in proxytest1 proxytest2; do go test -race -v -tags=$$tag ./proxytest; done test-coverage: $(COVERAGE_PROFILE_RAW) go run github.com/launchdarkly-labs/go-coverage-enforcer@latest $(COVERAGE_ENFORCER_FLAGS) -outprofile $(COVERAGE_PROFILE_FILTERED) $(COVERAGE_PROFILE_RAW) go tool cover -html $(COVERAGE_PROFILE_FILTERED) -o $(COVERAGE_PROFILE_FILTERED_HTML) go tool cover -html $(COVERAGE_PROFILE_RAW) -o $(COVERAGE_PROFILE_RAW_HTML) $(COVERAGE_PROFILE_RAW): $(ALL_SOURCES) @mkdir -p ./build go test -coverprofile $(COVERAGE_PROFILE_RAW) -coverpkg=./... ./... >/dev/null # note that -coverpkg=./... is necessary so it aggregates coverage to include inter-package references benchmarks: @mkdir -p ./build go test -benchmem '-run=^$$' -bench . ./... | tee build/benchmarks.out @if grep $(ALLOCATIONS_LOG) $(LINTER_VERSION_FILE): rm -f $(LINTER) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION) touch $(LINTER_VERSION_FILE) lint: $(LINTER_VERSION_FILE) $(LINTER) run ./... TEMP_TEST_OUTPUT=/tmp/sse-contract-test-service.log # TEST_HARNESS_PARAMS can be set to add -skip parameters for any contract tests that cannot yet pass TEST_HARNESS_PARAMS= build-contract-tests: @cd testservice && go mod tidy && go build start-contract-test-service: build-contract-tests @./testservice/testservice start-contract-test-service-bg: @echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)" @make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 & run-contract-tests: @curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v2/downloader/run.sh \ | VERSION=v2 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end $(TEST_HARNESS_PARAMS)" sh contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests .PHONY: build-contract-tests start-contract-test-service start-contract-test-service-bg run-contract-tests contract-tests