Skip to content

Commit

Permalink
Ginkgo v2 (#32)
Browse files Browse the repository at this point in the history
* upgrade ginkgo

* changelog, gitignore, makefile

* default test pacakge

* go mod tidy using go1.19

* add make clean

* remove extensions ref

* ginkgo dep

* get go-utils

* improve changelog, makefile

* set kube version in gha, update gitignore

* use image not version

* include kindest,node

* use release version

* fix test to account for newer kube version
  • Loading branch information
sam-heilbron authored Feb 8, 2023
1 parent 7dc95aa commit 21d2f67
Show file tree
Hide file tree
Showing 44 changed files with 863 additions and 814 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ on:
push:
branches:
- 'master'
- 'main'
pull_request:

env:
KUBE_VERSION: v1.24.7

jobs:
test:
name: Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand All @@ -30,9 +34,11 @@ jobs:
${{ runner.os }}-go
- uses: azure/setup-kubectl@v1
with:
version: 'v1.18.0'
version: ${{ env.KUBE_VERSION }}
- uses: engineerd/[email protected]
with:
image: "kindest/node:${{ env.KUBE_VERSION }}"
- name: Run tests
run: |
go install github.com/onsi/ginkgo/[email protected] && export PATH=$PATH:$(go env GOPATH)/bin/
ginkgo -r -p -failFast -randomizeSuites -randomizeAllSpecs -skipPackage=./installutils/kubeinstall,./debugutils/test
env:
TEST_PKG: ./... # Run all tests
run: make test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@
# ignore intermediate files that gomock sometimes generates
**/gomock_reflect*
id_rsa

_output

test-report.json
junit*.xml
*cov

*.test
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# https://www.gnu.org/software/make/manual/html_node/Special-Variables.html#Special-Variables
.DEFAULT_GOAL := help

#----------------------------------------------------------------------------------
# Help
#----------------------------------------------------------------------------------
# Our Makefile is quite large, and hard to reason through
# `make help` can be used to self-document targets
# To update a target to be self-documenting (and appear with the `help` command),
# place a comment after the target that is prefixed by `##`. For example:
# custom-target: ## comment that will appear in the documentation when running `make help`
#
# **NOTE TO DEVELOPERS**
# As you encounter make targets that are frequently used, please make them self-documenting
.PHONY: help
help: FIRST_COLUMN_WIDTH=35
help: ## Output the self-documenting make targets
@grep -hE '^[%a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-$(FIRST_COLUMN_WIDTH)s\033[0m %s\n", $$1, $$2}'

#----------------------------------------------------------------------------------
# Repo setup
#----------------------------------------------------------------------------------
ROOT_DIR := $(shell pwd)
OUTPUT_DIR := $(ROOT_DIR)/_output
DEPSGOBIN := $(OUTPUT_DIR)/.bin

export PATH:=$(DEPSGOBIN):$(PATH)
export GOBIN:=$(DEPSGOBIN)

#----------------------------------------------------------------------------------
# Clean
#----------------------------------------------------------------------------------

.PHONY: clean
clean: ## Clean any local assets
rm -rf $(OUTPUT_DIR)
find * -type f -name '*.test' -exec rm {} \;

#----------------------------------------------------------------------------------
# Tests
#----------------------------------------------------------------------------------

GINKGO_VERSION ?= 2.5.0 # match our go.mod
GINKGO_ENV ?= GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore ACK_GINKGO_DEPRECATIONS=$(GINKGO_VERSION)
GINKGO_FLAGS ?= -v -tags=purego -compilers=4 -fail-fast -race -randomize-suites -randomize-all -skip-package=./installutils/kubeinstall,./debugutils/test
GINKGO_REPORT_FLAGS ?= --json-report=test-report.json --junit-report=junit.xml -output-dir=$(OUTPUT_DIR)
GINKGO_COVERAGE_FLAGS ?= --cover --covermode=atomic --coverprofile=coverage.cov
TEST_PKG ?= ./... # Default to running all tests

# This is a way for a user executing `make test` to be able to provide flags which we do not include by default
# For example, you may want to run tests multiple times, or with various timeouts
GINKGO_USER_FLAGS ?=

.PHONY: install-test-tools
install-test-tools:
go install github.com/onsi/ginkgo/v2/ginkgo@v$(GINKGO_VERSION)

.PHONY: test
test: install-test-tools ## Run tests in the {TEST_PKG}
$(GINKGO_ENV) ginkgo \
$(GINKGO_FLAGS) $(GINKGO_REPORT_FLAGS) $(GINKGO_USER_FLAGS) \
$(TEST_PKG)

.PHONY: test-with-coverage
test-with-coverage: GINKGO_FLAGS += $(GINKGO_COVERAGE_FLAGS) ## Run tests in the {TEST_PKG} with coverage
test-with-coverage: test
go tool cover -html $(OUTPUT_DIR)/coverage.cov
2 changes: 1 addition & 1 deletion certutils/certutils_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package certutils_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion certutils/gen_cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package certutils_test
import (
"crypto/x509"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/solo-io/k8s-utils/certutils"
Expand Down
22 changes: 22 additions & 0 deletions changelog/v0.3.0/ginkgo-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
changelog:
- type: BREAKING_CHANGE
issueLink: https://github.com/solo-io/gloo/issues/7222
resolvesIssue: false
description: >
Upgrade Ginkgo from v1 to v2, using https://onsi.github.io/ginkgo/MIGRATING_TO_V2 as a helpful guide.
- type: DEPENDENCY_BUMP
dependencyOwner: onsi
dependencyRepo: gomega
dependencyTag: v1.24.0
- type: DEPENDENCY_BUMP
dependencyOwner: onsi
dependencyRepo: ginkgo/v2
dependencyTag: v2.5.0
- type: DEPENDENCY_BUMP
dependencyOwner: google.golang.org
dependencyRepo: protobuf
dependencyTag: v1.28.1
- type: DEPENDENCY_BUMP
dependencyOwner: solo-io
dependencyRepo: go-utils
dependencyTag: v0.24.0
2 changes: 1 addition & 1 deletion configutils/test/config_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion configutils/test/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/solo-io/go-utils/testutils"
"github.com/solo-io/k8s-utils/configutils"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
kube2 "github.com/solo-io/k8s-utils/testutils/kube"
kubeerr "k8s.io/apimachinery/pkg/api/errors"
Expand Down
2 changes: 1 addition & 1 deletion debugutils/debugutils_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/solo-io/k8s-utils/installutils/helmchart"
"github.com/solo-io/k8s-utils/installutils/kuberesource"
Expand Down
2 changes: 1 addition & 1 deletion debugutils/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rotisserie/eris"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion debugutils/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"path/filepath"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/afero"
)
Expand Down
54 changes: 28 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ require (
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/google/go-github/v32 v32.0.0
github.com/google/uuid v1.2.0
github.com/google/uuid v1.3.0
github.com/goph/emperror v0.17.1
github.com/hashicorp/consul/api v1.1.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.1
github.com/onsi/gomega v1.24.0
github.com/pkg/errors v0.9.1
github.com/rotisserie/eris v0.1.1
github.com/solo-io/go-utils v0.22.4
github.com/solo-io/go-utils v0.24.0
github.com/spf13/afero v1.6.0
go.uber.org/zap v1.19.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
google.golang.org/protobuf v1.28.0
golang.org/x/sync v0.1.0
google.golang.org/protobuf v1.28.1
helm.sh/helm/v3 v3.9.0
k8s.io/api v0.25.4
k8s.io/apiextensions-apiserver v0.25.4
Expand All @@ -33,7 +32,8 @@ require (
)

require (
cloud.google.com/go v0.99.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
Expand All @@ -42,7 +42,6 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
Expand All @@ -54,7 +53,6 @@ require (
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bugsnag/bugsnag-go v1.5.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
github.com/containerd/containerd v1.6.3 // indirect
Expand All @@ -68,7 +66,6 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/color v1.13.0 // indirect
Expand All @@ -84,7 +81,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down Expand Up @@ -127,7 +124,7 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.1 // indirect
Expand All @@ -150,23 +147,20 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
github.com/yvasiyarov/gorelic v0.0.6 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c // indirect
google.golang.org/grpc v1.51.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.25.4 // indirect
Expand All @@ -182,10 +176,18 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

replace (
require (
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect
github.com/bugsnag/bugsnag-go v1.5.0 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/onsi/ginkgo/v2 v2.5.0
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
github.com/yvasiyarov/gorelic v0.0.6 // indirect
)

// logrus did the rename of their repo which is why we have this
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.0.5
replace (
// logrus did the rename of their repo which is why we have this
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.0.5

// pin to the jwt-go fork to fix CVE.
// using the pseudo version of github.com/form3tech-oss/[email protected] instead of the version directly,
Expand Down
Loading

0 comments on commit 21d2f67

Please sign in to comment.