Skip to content

Commit 8959618

Browse files
authored
Make test fails due to keeping github.com autogenerated folder in root (zalando#1713)
1 parent def9e1d commit 8959618

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

.github/workflows/run_e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
- name: Compile
2121
run: make linux
2222
- name: Run unit tests
23-
run: go test ./...
23+
run: make test
2424
- name: Run end-2-end tests
2525
run: make e2e

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@ test:
103103
hack/verify-codegen.sh
104104
GO111MODULE=on go test ./...
105105

106+
codegen:
107+
hack/update-codegen.sh
108+
106109
e2e: docker # build operator image to be tested
107110
cd e2e; make e2etest

hack/update-codegen.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7+
GENERATED_PACKAGE_ROOT="github.com"
8+
OPERATOR_PACKAGE_ROOT="${GENERATED_PACKAGE_ROOT}/zalando/postgres-operator"
79
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
8-
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ${GOPATH}/src/k8s.io/code-generator)}
10+
TARGET_CODE_DIR=${1-${SCRIPT_ROOT}/pkg}
11+
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo "${GOPATH}"/src/k8s.io/code-generator)}
12+
13+
cleanup() {
14+
rm -rf "${GENERATED_PACKAGE_ROOT}"
15+
}
16+
trap "cleanup" EXIT SIGINT
917

1018
bash "${CODEGEN_PKG}/generate-groups.sh" all \
11-
github.com/zalando/postgres-operator/pkg/generated github.com/zalando/postgres-operator/pkg/apis \
19+
"${OPERATOR_PACKAGE_ROOT}/pkg/generated" "${OPERATOR_PACKAGE_ROOT}/pkg/apis" \
1220
"acid.zalan.do:v1" \
1321
--go-header-file "${SCRIPT_ROOT}"/hack/custom-boilerplate.go.txt
22+
23+
cp -r "${OPERATOR_PACKAGE_ROOT}"/pkg/* "${TARGET_CODE_DIR}"
24+
25+
cleanup

hack/verify-codegen.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ cleanup
1919
mkdir -p "${TMP_DIFFROOT}"
2020
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
2121

22-
"${SCRIPT_ROOT}/hack/update-codegen.sh"
22+
"${SCRIPT_ROOT}/hack/update-codegen.sh" "${TMP_DIFFROOT}"
2323
echo "diffing ${DIFFROOT} against freshly generated codegen"
2424
ret=0
2525
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
26-
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
2726
if [[ $ret -eq 0 ]]
2827
then
2928
echo "${DIFFROOT} up to date."
3029
else
31-
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
30+
echo "${DIFFROOT} is out of date. Please run 'make codegen'"
3231
exit 1
3332
fi

pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)