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 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 $?