From 55412d27e5e777e1b05445435f715855d348c99a Mon Sep 17 00:00:00 2001 From: Keith James Date: Fri, 3 Jan 2025 17:26:48 +0000 Subject: [PATCH] Remove use of CGO when building Refactor the Makefile to be standard with other applications --- .github/workflows/create-release.yml | 2 +- .github/workflows/run-tests.yml | 5 ----- Makefile | 23 +++++++++++++++-------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 620beb4..4fa0929 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -41,7 +41,7 @@ jobs: with: name: ${{ env.RELEASE_VERSION }} prerelease: ${{ !(github.sha == env.MASTER_SHA) }} - artifacts: "build/*.tar.bz2,build/*.tar.bz2.sha256" + artifacts: "./build/*.tar.bz2,./build/*.tar.bz2.sha256" removeArtifacts: true artifactErrorsFailBuild: true generateReleaseNotes: true diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 12e1a06..b01ad4d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -120,11 +120,6 @@ jobs: baton-do --version - - name: "Install test runner" - run: | - go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo - go get github.com/onsi/gomega/... - - name: "Run tests" run: | make test diff --git a/Makefile b/Makefile index ac3bdde..cfe8b67 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ VERSION := $(shell git describe --always --tags --dirty) ldflags := "-X github.com/wtsi-npg/valet/valet.Version=${VERSION}" build_args := -a -v -ldflags ${ldflags} + build_path = "build/valet-${VERSION}" -CGO_ENABLED := 1 -GOARCH := amd64 -GOOS := linux +export CGO_ENABLED := 0 + +export GOARCH := $(shell go env GOARCH) ifeq ($(GITHUB_ACTIONS),true) DOCKER_REGISTRY?=ghcr.io @@ -32,9 +33,12 @@ git_commit=$(shell git log --pretty=format:'%H' -n 1) all: build -build: +build: build-linux + +build-linux: export GOOS = linux +build-linux: mkdir -p ${build_path} - go build ${build_args} -o ${build_path}/valet-${GOARCH} ./main.go + go build ${build_args} -o ${build_path}/valet-${GOOS}-${GOARCH} ./main.go install: go install ${build_args} @@ -44,10 +48,13 @@ lint: check: test -test: - ginkgo -r --race +test-install: + go install github.com/onsi/ginkgo/v2/ginkgo + +test: test-install + CGO_ENABLED=1 ginkgo -r --race -coverage: +coverage: test-install ginkgo -r --cover -coverprofile=coverage.out dist: build