From 1ddddb6bc76001c2b4ea38908ac6e92b4235b74d Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Fri, 12 Feb 2021 13:18:30 -0800 Subject: [PATCH] Permit linting and testing without CGO support. Use CGO for testing and building in travis. Fixes #471 --- .travis.yml | 2 +- Makefile | 12 ++++++++++-- kms/pkcs11/other_test.go | 2 +- kms/pkcs11/softhsm2_test.go | 2 +- kms/pkcs11/yubihsm2_test.go | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa593abe..fcf73d2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: before_script: - make bootstrap script: - - make + - make travis - make artifacts after_success: - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" || echo "Codecov did diff --git a/Makefile b/Makefile index 282e26f2..4824d451 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,8 @@ OUTPUT_ROOT=output/ all: lint test build +travis: lintcgo testcgo build + .PHONY: all ######################################### @@ -119,9 +121,12 @@ generate: # Test ######################################### test: + $Q $(GOFLAGS) go test -short -coverprofile=coverage.out ./... + +testcgo: $Q go test -short -coverprofile=coverage.out ./... -.PHONY: test +.PHONY: test testcgo integrate: integration @@ -138,9 +143,12 @@ fmt: $Q gofmt -l -w $(SRC) lint: + $Q $(GOFLAGS) LOG_LEVEL=error golangci-lint run --timeout=30m + +lintcgo: $Q LOG_LEVEL=error golangci-lint run --timeout=30m -.PHONY: lint fmt +.PHONY: fmt lint lintcgo ######################################### # Install diff --git a/kms/pkcs11/other_test.go b/kms/pkcs11/other_test.go index a0d810f4..835587f7 100644 --- a/kms/pkcs11/other_test.go +++ b/kms/pkcs11/other_test.go @@ -1,4 +1,4 @@ -// +build !softhsm2,!yubihsm2,!opensc +// +build cgo,!softhsm2,!yubihsm2,!opensc package pkcs11 diff --git a/kms/pkcs11/softhsm2_test.go b/kms/pkcs11/softhsm2_test.go index 379d7a11..37aa667d 100644 --- a/kms/pkcs11/softhsm2_test.go +++ b/kms/pkcs11/softhsm2_test.go @@ -1,4 +1,4 @@ -// +build softhsm2 +// +build cgo,softhsm2 package pkcs11 diff --git a/kms/pkcs11/yubihsm2_test.go b/kms/pkcs11/yubihsm2_test.go index 54885070..6d02a420 100644 --- a/kms/pkcs11/yubihsm2_test.go +++ b/kms/pkcs11/yubihsm2_test.go @@ -1,4 +1,4 @@ -// +build yubihsm2 +// +build cgo,yubihsm2 package pkcs11