Skip to content

chore: refactor presubmits so they are easier to run locally #410

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

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 5 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions dev/ci/presubmits/verify-goimports
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions dev/ci/presubmits/verify-gomod
Original file line number Diff line number Diff line change
@@ -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
Loading