diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b98bca1..57f4cd08 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,15 +19,9 @@ jobs: - uses: actions/checkout@v2 - - name: verify goimports - run: | - files=$(go run golang.org/x/tools/cmd/goimports -format-only -l .) - # Sadly goimports doesn't use exit codes - if [[ -n "${files}" ]]; then - echo "::error ::goimports should be run on these files:" - echo "${files}" - exit 1 - fi + - name: verify-goimports + run: dev/ci/presubmits/verify-goimports + verify-gomod: runs-on: ubuntu-latest @@ -40,17 +34,8 @@ jobs: - uses: actions/checkout@v2 - - run: dev/format-gomod - - - run: | - changes=$(git status --porcelain) - if [[ -n "${changes}" ]]; then - echo "::error Changes detected from dev/format-gomod:" - echo "::error (You may need to run go clean -cache -modcache)" - git diff | head -n60 - echo "${changes}" - exit 1 - fi + - name: verify-gomod + run: dev/ci/presubmits/verify-gomod kind-e2e: name: Test with a Kind cluster diff --git a/dev/ci/presubmits/verify-goimports b/dev/ci/presubmits/verify-goimports new file mode 100755 index 00000000..feca3f54 --- /dev/null +++ b/dev/ci/presubmits/verify-goimports @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2025 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# CI script to keep all files formatted with goimporrts + +set -o errexit +set -o nounset +set -o pipefail + +# cd to the repo root +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "${REPO_ROOT}" + +files=$(go run golang.org/x/tools/cmd/goimports -format-only -l .) +# Sadly goimports doesn't use exit codes +if [[ -n "${files}" ]]; then + echo "::error ::goimports should be run on these files:" + echo "${files}" + exit 1 +fi diff --git a/dev/ci/presubmits/verify-gomod b/dev/ci/presubmits/verify-gomod new file mode 100755 index 00000000..27b61b34 --- /dev/null +++ b/dev/ci/presubmits/verify-gomod @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright 2025 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# CI script to keep all our go.mod/go.sum updated + +set -o errexit +set -o nounset +set -o pipefail + +# cd to the repo root +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "${REPO_ROOT}" + +dev/format-gomod + +changes=$(git status --porcelain) +if [[ -n "${changes}" ]]; then + echo "::error Changes detected from dev/format-gomod:" + echo "::error (You may need to run go clean -cache -modcache)" + git diff | head -n60 + echo "${changes}" + exit 1 +fi