#!/usr/bin/make -f

export DH_GOLANG_INSTALL_EXTRA := \
	$(wildcard attestation/sbom/boms/*/*.json) \
	$(wildcard attestation/sbom/boms/*/*.xml)

export DH_GOLANG_EXCLUDES := \
	signer/kms/azure \
	signer/kms/hashivault

%:
	dh $@ --builddirectory=_build --buildsystem=golang

ifneq ($(filter pkg.golang-github-in-toto-go-witness.no-archivista,$(DEB_BUILD_PROFILES)),)
export DH_GOLANG_EXCLUDES += archivista
execute_before_dh_auto_build:
	rm -fv $(CURDIR)/_build/src/github.com/in-toto/go-witness/source/archivista.go
endif

# Tools 'schemagen' and 'check-certs' does not seem useful for users.
override_dh_auto_install:
	dh_auto_install -- --no-binaries

# fails on buildds but works in debci/salsa:
# Post "https://timestamp.sigstore.dev/api/v1/timestamp": dial tcp: lookup timestamp.sigstore.dev on [::1]:53: read udp [::1]:48233->[::1]:53: read: connection refused
# fails on amd64 but works on i386:
# === RUN   TestGetCertNonRetryableErrors/authentication_error_-_no_retry
# 2026/03/13 08:18:02 failed to serve: grpc: the server has been stopped
# === RUN   TestFetchToken
# 2026/03/13 09:02:11 failed to serve: grpc: the server has been stopped
# === RUN   TestGetCertRetryLogic/token_without_required_claims
# 2026/03/13 09:48:17 failed to serve: grpc: the server has been stopped
# FAIL	github.com/in-toto/go-witness/signer/fulcio	11.608s
XFLAKY := TestTSP|TestGetCertNonRetryableErrors|TestFetchToken|TestGetCertRetryLogic

override_dh_auto_test:
	dh_auto_test $(DH_BUILD_OPTS) -- -skip="$(XFLAKY)"
	-dh_auto_test $(DH_BUILD_OPTS) -- -run="$(XFLAKY)"
