From 351c6e88d1133e140848b82882d3b0749360a960 Mon Sep 17 00:00:00 2001 From: Genevieve Luyt <11131143+genevieveluyt@users.noreply.github.com> Date: Tue, 25 May 2021 11:57:22 -0400 Subject: [PATCH 1/5] Use Github Actions --- .github/autolabeler.yml | 2 +- .github/workflows/ci.yml | 18 ++++++++++++++++++ .travis.yml | 22 ---------------------- Makefile | 8 ++------ README.md | 1 + test.sh | 2 +- 6 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml 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..5b970ae5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI +on: [push, pull-request] +jobs: + Test: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: "1.16.0" + - name: Install kubectl + run: 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/ + - name: Install kind + run: go get sigs.k8s.io/kind + - 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..a0a60042 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 @@ -50,10 +50,6 @@ clean: 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 +57,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..9fe8ab55 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![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 From 5e949a9b294c646fcca32f6b71ab3389707c4647 Mon Sep 17 00:00:00 2001 From: Daniele Santos Date: Tue, 25 May 2021 15:09:24 -0400 Subject: [PATCH 2/5] testing workflow --- .github/workflows/ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b970ae5..e4f0e07e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,20 @@ name: CI -on: [push, pull-request] +on: [push, pull_request] jobs: - Test: + test: + strategy: + matrix: + go-version: [1.16.x] runs-on: ubuntu-latest steps: - - name: Clone repo - uses: actions/checkout@v2 - name: Install Go uses: actions/setup-go@v2 with: - go-version: "1.16.0" + go-version: "1.16.x" + - name: Clone repo + uses: actions/checkout@v2 - name: Install kubectl - run: 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/ + run: sudo snap install kubectl --classic - name: Install kind run: go get sigs.k8s.io/kind - name: Run tests From 4f424bb3a2edce4f5ea982a14ee9032740a451f2 Mon Sep 17 00:00:00 2001 From: Daniele Santos Date: Tue, 25 May 2021 15:29:54 -0400 Subject: [PATCH 3/5] adds back go mod make commands --- .github/workflows/ci.yml | 4 +++- Makefile | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4f0e07e..51d1d3a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: - name: Install kubectl run: sudo snap install kubectl --classic - name: Install kind - run: go get sigs.k8s.io/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/Makefile b/Makefile index a0a60042..75002c65 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,10 @@ test-teardown: show-coverage: test go tool cover -html=coverage.txt +setup: + $(GOMOD) download + $(GOMOD) tidy + clean: $(GOCLEAN) rm -f $(BINARY_NAME) From 5bd7a4118296dbf15798472f310c936e8a62bd35 Mon Sep 17 00:00:00 2001 From: Daniele Santos Date: Tue, 25 May 2021 15:49:39 -0400 Subject: [PATCH 4/5] only trigger actions for pushes against the master branch --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51d1d3a4..8472ef43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,12 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: [master] jobs: test: - strategy: - matrix: - go-version: [1.16.x] runs-on: ubuntu-latest steps: - name: Install Go From 27e08e6d78660aeea5dda4607b8486c3d70cf54c Mon Sep 17 00:00:00 2001 From: Daniele Santos Date: Tue, 25 May 2021 16:03:12 -0400 Subject: [PATCH 5/5] removes travis ref from readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9fe8ab55..e305f821 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![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)