diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..6246514558 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + E2E_SETUP_KIND: yes + E2E_SETUP_KUBECTL: yes + SUDO: sudo + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Install CI + run: | + go get -v -t -d ./... + make install-tools + + - name: Lint + run: | + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0 + make lint + + - name: Validate generated manifests + run: | + make validate-manifests + + - name: Validate vendor is in sync with go modules + run: | + make validate-modules + + - name: Check that all metrics are documented + run: | + make doccheck + + - name: Unit tests + run: | + make test-unit + + - name: Benchmark tests + run: | + make test-benchmark-compare + + - name: Build + run: | + make build + + - name: End-to-end tests + run: | + REGISTRY="quay.io/coreos" make e2e diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 601d16339d..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -sudo: required -dist: xenial -language: go - -go: - - "1.14.x" - -services: - - docker - -git: - # Benchmark tests needs to access other branches, thereby we need to fetch all - # of the repository. - depth: false - -env: - global: - - E2E_SETUP_KIND=yes - - E2E_SETUP_KUBECTL=yes - - SUDO=sudo - -before_script: -- make install-tools - -before_install: -- sudo apt-get -qq -y install conntrack - -install: -- mkdir -p $HOME/gopath/src/k8s.io -- mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/kube-state-metrics -- cd $HOME/gopath/src/k8s.io/kube-state-metrics - -jobs: - include: - - stage: all - name: Lint - script: make lint - - name: Validate generated manifests - script: make validate-manifests - - name: Validate vendor is in sync with go modules - script: make validate-modules - - name: Check that all metrics are documented - script: make doccheck - - name: Unit tests - script: make test-unit - - name: Benchmark tests - script: make test-benchmark-compare - - name: Build - script: make build - - name: End to end tests - script: REGISTRY="quay.io/coreos" make e2e diff --git a/Makefile b/Makefile index 78f99db0c8..04921ba1ec 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,6 @@ Commit = $(shell git rev-parse --short HEAD) ALL_ARCH = amd64 arm arm64 ppc64le s390x PKG = k8s.io/kube-state-metrics/pkg GO_VERSION = 1.14.6 -FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH))) -BENCHCMP_BINARY := $(FIRST_GOPATH)/bin/benchcmp -GOLANGCI_VERSION := v1.29.0 -HAS_GOLANGCI := $(shell command -v golangci-lint) - IMAGE = $(REGISTRY)/kube-state-metrics MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) @@ -43,9 +38,6 @@ licensecheck: fi lint: shellcheck licensecheck -ifndef HAS_GOLANGCI - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin ${GOLANGCI_VERSION} -endif golangci-lint run doccheck: generate @@ -77,7 +69,8 @@ shellcheck: # Runs benchmark tests on the current git ref and the last release and compares # the two. -test-benchmark-compare: $(BENCHCMP_BINARY) +test-benchmark-compare: + @git fetch ./tests/compare_benchmarks.sh master ./tests/compare_benchmarks.sh ${LATEST_RELEASE_BRANCH} @@ -128,7 +121,7 @@ e2e: generate: build-local @echo ">> generating docs" @./scripts/generate-help-text.sh - @$(GOPATH)/bin/embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print` + embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print` validate-manifests: examples @git diff --exit-code diff --git a/README.md b/README.md index 9e33397df6..a63c5b0269 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Overview -[![Build Status](https://travis-ci.org/kubernetes/kube-state-metrics.svg?branch=master)](https://travis-ci.org/kubernetes/kube-state-metrics) [![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![GoDoc](https://godoc.org/github.com/kubernetes/kube-state-metrics?status.svg)](https://godoc.org/github.com/kubernetes/kube-state-metrics) +[![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![GoDoc](https://godoc.org/github.com/kubernetes/kube-state-metrics?status.svg)](https://godoc.org/github.com/kubernetes/kube-state-metrics) kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects. (See examples in diff --git a/tests/README.md b/tests/README.md index 5cb95a1d61..410daf7a78 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ This folder contains simple e2e tests. When launched, it spins up a kubernetes cluster using [kind](https://kind.sigs.k8s.io/), creates several kubernetes resources and launches a kube-state-metrics deployment. Then, it runs verification tests: check metrics' presence, lint metrics, check service health, etc. -The test suite is run automatically using Travis. +The test suite is run automatically using Github Actions. ## Running locally