Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI failures for Go 1.17 and verifying invalid examples #830

Merged
merged 5 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions hack/boilerplate/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ def get_regexs():
# get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year as a regex like: "(2014|2015|2016|2017|2018)";
# company holder names can be anything
regexs["date"] = re.compile(get_dates())
# strip // +build \n\n build constraints
# strip the following build constraints/tags:
# //go:build
# // +build \n\n
regexs["go_build_constraints"] = re.compile(
r"^(// \+build.*\n)+\n", re.MULTILINE)
r"^(//(go:build| \+build).*\n)+\n", re.MULTILINE)
# strip #!.* from scripts
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
# Search for generated files
Expand Down
7 changes: 6 additions & 1 deletion hack/verify-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ do
ret=1
fi
else
bash "$t" || ret=1
if bash "$t"; then
echo -e "${color_green}SUCCESS: $t ${color_norm}"
else
echo -e "${color_red}Test FAILED: $t ${color_norm}"
ret=1
fi
fi
done

Expand Down
49 changes: 36 additions & 13 deletions hack/verify-examples-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,47 @@ res=0
KIND_CREATE_ATTEMPTED=true
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?

for VERSION in v1alpha1 v1alpha2
do
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
##### Test v1alpha1 CRD apply
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/"${VERSION}" || res=$?
# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$?

# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
done
sleep 3
youngnick marked this conversation as resolved.
Show resolved Hide resolved

# None of these examples should be successfully configured
kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2
# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?


##### Test v1alpha2 CRD apply and that invalid examples are invalid.
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || res=$?

# Install invalid gateway-api resources.
# None of these examples should be successfully configured
# This is very hacky, sorry.
# Firstly, apply the examples, remembering that errors are on stdout
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f hack/invalid-examples 2>&1 | \
# First, we grep out the expected responses.
# After this, if everything is as expoected, the output should be empty.
youngnick marked this conversation as resolved.
Show resolved Hide resolved
grep -v 'is invalid' | \
grep -v 'missing required field' | \
# Then, we grep for anything else.
# If anything else is found, this will return 0
# which is *not* what we want.
grep -e '.' && \
res=2 || \
echo Examples failed as expected
# Clean up and exit
cleanup || res=$?
exit $res