Skip to content

Commit 79e6369

Browse files
Add test/check sanity to check if test-framework mock data is updated (#2131)
* add to the sanity check to ensure that the test-framework is updated * Ensure that all scripts has the same name format with - and not _ * create makefile target for the new check * improve doc gen and make file targets related to it.
1 parent dc4b521 commit 79e6369

File tree

10 files changed

+46
-231
lines changed

10 files changed

+46
-231
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ tidy: ## Update dependencies
5454
clean: ## Clean up the build artifacts
5555
$(Q)rm -rf build
5656

57-
cli-doc: ## Generate CLI Documentation
58-
./hack/doc/gen_cli_doc.sh
57+
gen-cli-doc: ## Generate CLI documentation
58+
./hack/generate/gen-cli-doc.sh
59+
60+
gen-test-framework: install ## Run generate commands to update test/test-framework
61+
./hack/generate/gen-test-framework.sh
62+
63+
generate: gen-cli-doc gen-test-framework ## Run all generate targets
64+
.PHONY: generate gen-cli-doc gen-test-framework
5965

6066
# Build/install/release the SDK.
6167
.PHONY: install release_builds release
@@ -112,7 +118,7 @@ test: test-unit ## Run the tests
112118
test-markdown test/markdown:
113119
./hack/ci/marker
114120

115-
test-sanity test/sanity: tidy
121+
test-sanity test/sanity: tidy build/operator-sdk
116122
./hack/tests/sanity-check.sh
117123

118124
test-unit test/unit: ## Run the unit tests

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ require (
1818
github.com/ghodss/yaml v1.0.1-0.20180820084758-c7ce16629ff4
1919
github.com/go-logr/logr v0.1.0
2020
github.com/go-logr/zapr v0.1.1
21-
github.com/go-openapi/spec v0.19.0
2221
github.com/gobuffalo/packr v1.30.1 // indirect
2322
github.com/gobwas/glob v0.2.3 // indirect
2423
github.com/huandu/xstrings v1.2.0 // indirect
File renamed without changes.

hack/doc/gen_cli_doc.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.

hack/generate/gen-cli-doc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
go run ./hack/generate/gen-cli-doc.go

hack/generate/gen-test-framework.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
#############################
4+
# Make sure that test/test-framework is updated according to the current source code
5+
#############################
6+
7+
set -ex
8+
9+
source hack/lib/test_lib.sh
10+
11+
# Define vars
12+
DOCKERFILE="build/Dockerfile"
13+
14+
# Go inside of the mock data test project
15+
cd test/test-framework
16+
17+
# Create the required files in the mock test/test-framework just to allow run from it the oprator-sdk commands
18+
echo > $DOCKERFILE
19+
go mod init test-framework
20+
21+
# Remove files that are required and created just to exec the commands.
22+
trap_add 'rm -rf $DOCKERFILE go.mod go.sum' EXIT
23+
24+
# Run gen commands
25+
../../build/operator-sdk generate k8s
26+
../../build/operator-sdk generate openapi
27+
28+
# TODO(camilamacedo86): remove this when the openapi gen be set to false and it no longer is generated
29+
# The following file is gen by openapi but it has not been committed in order to allow we clone and call the test locally in any path.
30+
trap_add 'rm pkg/apis/cache/v1alpha1/zz_generated.openapi.go' EXIT

hack/tests/sanity-check.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ go mod tidy
55
go vet ./...
66
go fmt ./...
77

8-
./hack/check_license.sh
9-
./hack/check_error_log_msg_format.sh
10-
./hack/doc/gen_cli_doc.sh
8+
./hack/check-license.sh
9+
./hack/check-error-log-msg-format.sh
10+
./hack/generate/gen-cli-doc.sh
11+
./hack/generate/gen-test-framework.sh
1112

1213
# Make sure repo is still in a clean state.
1314
git diff --exit-code

test/test-framework/pkg/apis/cache/v1alpha1/zz_generated.openapi.go

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)