From 83b2517c7e3e3c7372771af3eaf6743beb2c4bc9 Mon Sep 17 00:00:00 2001 From: becitsthere Date: Tue, 9 May 2023 09:44:55 -0700 Subject: [PATCH 1/2] NVHSAS-6217: Build binary with build container --- Makefile | 14 ++++++++++++-- make_bin.sh | 8 ++++++++ unitest.sh | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 make_bin.sh create mode 100755 unitest.sh diff --git a/Makefile b/Makefile index 8b4c78bc..70b8c06d 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,12 @@ -deployment: - env GOOS=linux GOARCH=amd64 go build . \ No newline at end of file +.PHONY: + +BASE_IMAGE_TAG = latest +BUILD_IMAGE_TAG = v1 + +all: + env GOOS=linux GOARCH=amd64 go build -ldflags='-s -w' -buildvcs=false . + +binary: + @echo "Making $@ ..." + @docker pull neuvector/build_fleet:${BUILD_IMAGE_TAG} + @docker run --rm -ia STDOUT --name build --net=none -v $(CURDIR):/go/src/github.com/neuvector/sigstore-interface -w /go/src/github.com/neuvector/sigstore-interface --entrypoint ./make_bin.sh neuvector/build_fleet:${BUILD_IMAGE_TAG} diff --git a/make_bin.sh b/make_bin.sh new file mode 100755 index 00000000..2133b65e --- /dev/null +++ b/make_bin.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This script is invoked by build container + +./unitest.sh || exit $? + +echo "==> Making binary" +make || exit $? diff --git a/unitest.sh b/unitest.sh new file mode 100755 index 00000000..4a4508b0 --- /dev/null +++ b/unitest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +go test ./... || exit $? From ab4258cc8f7a7ef4e79504c2c13075af2daf49e9 Mon Sep 17 00:00:00 2001 From: becitsthere Date: Tue, 9 May 2023 10:05:01 -0700 Subject: [PATCH 2/2] NVHSAS-6217: Add unitest actiion --- .github/workflows/unitest.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/unitest.yaml diff --git a/.github/workflows/unitest.yaml b/.github/workflows/unitest.yaml new file mode 100644 index 00000000..03bf420f --- /dev/null +++ b/.github/workflows/unitest.yaml @@ -0,0 +1,16 @@ +name: Run unitest on push and pull request + +on: + push: + pull_request: + +jobs: + unitest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.20.3' + - run: | + ./unitest.sh