diff --git a/.github/workflows/check-codegen.yml b/.github/workflows/check-codegen.yml index feeeeab19..61f857ea6 100644 --- a/.github/workflows/check-codegen.yml +++ b/.github/workflows/check-codegen.yml @@ -14,6 +14,11 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' + - name: Download k8s.io/code-generator + run: | + CODE_GEN_VERSION=$(go list -m -f '{{.Version}}' k8s.io/code-generator) + go get k8s.io/code-generator@$CODE_GEN_VERSION + echo "CODE_GEN_DIR=$(go list -m -f '{{.Dir}}' k8s.io/code-generator)" >> $GITHUB_ENV - name: Run make generate run: make generate - name: Compare the expected and actual generated/* directories diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93b84db55..1112c1917 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,4 +16,10 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - - run: make test + - name: Download k8s.io/code-generator + run: | + CODE_GEN_VERSION=$(go list -m -f '{{.Version}}' k8s.io/code-generator) + go get k8s.io/code-generator@$CODE_GEN_VERSION + echo "CODE_GEN_DIR=$(go list -m -f '{{.Dir}}' k8s.io/code-generator)" >> $GITHUB_ENV + - name: Run make test + run: make test diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 52e7622a1..b058d5aa5 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -7,15 +7,15 @@ set -o pipefail SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" PROJECT_ROOT="$SCRIPT_DIR/.." +CODE_GEN_DIR="${CODE_GEN_DIR:-$(go list -m -f '{{.Dir}}' k8s.io/code-generator)}" +source "${CODE_GEN_DIR}/kube_codegen.sh" + export TERM="xterm-256color" bold="$(tput bold)" blue="$(tput setaf 4)" normal="$(tput sgr0)" -CODE_GEN_DIR=$(go list -m -f '{{.Dir}}' k8s.io/code-generator) -source "${CODE_GEN_DIR}/kube_codegen.sh" - function qualify-gvs() { APIS_PKG="$1" GROUPS_WITH_VERSIONS="$2"