File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Trailing
2
+
3
+ # Trigger the workflow on pull requests and direct pushes to any branch
4
+ on :
5
+ push :
6
+ paths :
7
+ - ' **/*.md'
8
+ pull_request :
9
+ paths :
10
+ - ' **/*.md'
11
+
12
+ jobs :
13
+ lint :
14
+ name : " Check Trailing"
15
+ runs-on : ubuntu-latest
16
+ # Pull requests from the same repository won't trigger this checks as they were already triggered by the push
17
+ if : (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
18
+ steps :
19
+ - name : Clone the code
20
+ uses : actions/checkout@v4
21
+ - name : Run check
22
+ run : make test-spaces
Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ install: build ## Build and install the binary with the current source code. Use
66
66
.PHONY : generate
67
67
generate : generate-testdata generate-docs # # Update/generate all mock data. You should run this commands to update the mock data after your changes.
68
68
go mod tidy
69
+ remove-spaces
70
+
71
+ .PHONY : remove-spaces
72
+ remove-spaces :
73
+ @echo " Removing trailing spaces"
74
+ @find . -type f -name " *.md" -exec sed -i ' ' ' s/[[:space:]]*$$//' {} +
69
75
70
76
.PHONY : generate-testdata
71
77
generate-testdata : # # Update/generate the testdata in $GOPATH/src/sigs.k8s.io/kubebuilder
@@ -160,3 +166,7 @@ test-book: ## Run the cronjob tutorial's unit tests to make sure we don't break
160
166
.PHONY : test-license
161
167
test-license : # # Run the license check
162
168
./test/check-license.sh
169
+
170
+ .PHONY : test-spaces
171
+ test-spaces : # # Run the trailing spaces check
172
+ ./test/check_spaces.sh
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Copyright 2024 The Kubernetes Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ function validate_docs_trailing_spaces {
18
+ if find . -type f -name " *.md" -exec grep -Hn ' [[:space:]]$' {} +; then
19
+ echo " Trailing spaces were found in docs files"
20
+ exit 1
21
+ fi
22
+
23
+ }
24
+
25
+ validate_docs_trailing_spaces
You can’t perform that action at this time.
0 commit comments