diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml index b4351fd6..c1b92a61 100644 --- a/.github/autolabeler.yml +++ b/.github/autolabeler.yml @@ -1,6 +1,6 @@ core: ["/cmd"] legal: ["LICENSE*", "CODE_OF_CONDUCT*"] -config: [".github","build","travis.yml","Makefile","/configs"] +config: [".github","build","Makefile","/configs"] go-modules: ["go.*"] readme: ["README*"] datafiles: ["/fixtures"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8472ef43 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: [master] +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "1.16.x" + - name: Clone repo + uses: actions/checkout@v2 + - name: Install kubectl + run: sudo snap install kubectl --classic + - name: Install kind + run: GO111MODULE=on go get sigs.k8s.io/kind + - name: Go mod download and go tidy + run: make setup + - name: Run tests + run: make test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 884ee784..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: go - -go: - - "1.16.x" - -services: - - docker - -before_script: - # Download and install kubectl - - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ - - # Download and install Kind - - GO111MODULE=on go get sigs.k8s.io/kind - # It's possible to download and install Kind using curl, similar as for kubectl - # This is useful in cases when Go toolchain isn't available or you prefer running stable version - # Binaries for Kind are available on GitHub Releases: https://github.com/kubernetes-sigs/kind/releases - # - curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/0.0.1/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/ - -script: - - make setup - - make test diff --git a/Makefile b/Makefile index ae7c72cc..75002c65 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ ifneq ($(GOVERSION_MIN), $(GOVERSION_CHECK)) $(error Detected Go version $(GOVERSION) < required version $(GOVERSION_MIN)) endif -all: setup test build +all: test build build: $(GOBUILD) -o $(BINARY_NAME) -v -ldflags=all="$(LDFLAGS)" cmd/main.go @@ -45,15 +45,15 @@ test-teardown: show-coverage: test go tool cover -html=coverage.txt +setup: + $(GOMOD) download + $(GOMOD) tidy + clean: $(GOCLEAN) rm -f $(BINARY_NAME) rm -f $(BINARY_UNIX) -setup: - $(GOMOD) download - $(GOMOD) tidy - # Cross Compilation build-linux: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v @@ -61,4 +61,4 @@ build-linux: docker-build: docker run --rm -it -v "$(GOPATH)":/go -w /go/src/github.com/Shopify/kubeaudit golang:1.12 go build -o "$(BINARY_UNIX)" -v -.PHONY: all build install plugin test test-setup test-teardown show-coverage clean setup build-linux docker-build +.PHONY: all build install plugin test test-setup test-teardown show-coverage clean build-linux docker-build diff --git a/README.md b/README.md index bd860b2e..e305f821 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://api.travis-ci.org/Shopify/kubeaudit.svg?branch=master)](https://travis-ci.org/Shopify/kubeaudit/) +[![Build Status](https://github.com/Shopify/kubeaudit/actions/workflows/ci.yml/badge.svg)](https://github.com/Shopify/kubeaudit/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/Shopify/kubeaudit)](https://goreportcard.com/report/github.com/Shopify/kubeaudit) [![GoDoc](https://godoc.org/github.com/Shopify/kubeaudit?status.png)](https://godoc.org/github.com/Shopify/kubeaudit) diff --git a/test.sh b/test.sh index b8a6e094..f125cd81 100755 --- a/test.sh +++ b/test.sh @@ -17,7 +17,7 @@ fi touch coverage.txt -for d in $(go list ./... | grep -v vendor); do +for d in $(go list ./...); do go test -race -coverprofile=profile.out -covermode=atomic $d if [ -f profile.out ]; then cat profile.out >> coverage.txt