@@ -19,44 +19,102 @@ permissions:
1919 checks : write # Used to annotate code in the PR
2020
2121jobs :
22+ changes :
23+ name : categorize changes
24+ runs-on : ubuntu-latest
25+ outputs :
26+ non-docs : ${{ steps.detect.outputs.non-docs }}
27+ yaml : ${{ steps.detect.outputs.yaml }}
28+ steps :
29+ - name : Get base depth
30+ id : base-depth
31+ run : echo "base-depth=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_OUTPUT
32+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
33+ with :
34+ ref : ${{ github.event.pull_request.head.sha }}
35+ fetch-depth : ${{ steps.base-depth.outputs.base-depth }}
36+ - name : detect
37+ id : detect
38+ run : |
39+ git fetch origin ${{ github.base_ref }}
40+
41+ # Store git diff command for reuse
42+ GIT_DIFF_CMD="git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
43+
44+ # Disable pipefail to avoid SIGPIPE (exit 141) when commands like head/grep exit early
45+ # SIGPIPE occurs when git diff tries to write but the reading end of the pipe has closed
46+ set +o pipefail
47+
48+ # Show changed files for debugging (limit to first 50 for readability)
49+ echo "Changed files (first 50):"
50+ $GIT_DIFF_CMD | head -50
51+ FILE_COUNT=$($GIT_DIFF_CMD | wc -l)
52+ echo "Total files changed: $FILE_COUNT"
53+
54+ # If no files are changed at all, skip detection
55+ # Use git diff output directly to avoid bash variable size limits with large PRs
56+ if [[ $FILE_COUNT -gt 0 ]]; then
57+ # We only care about grep's exit status (did it find matches?), not the pipe status
58+ NON_DOCS=$($GIT_DIFF_CMD | grep -Ev '\.md$' > /dev/null && echo 'true' || echo 'false')
59+ YAML=$($GIT_DIFF_CMD | grep -E '\.ya?ml$' > /dev/null && echo 'true' || echo 'false')
60+ echo "non-docs=${NON_DOCS}" | tee -a $GITHUB_OUTPUT
61+ echo "yaml=${YAML}" | tee -a $GITHUB_OUTPUT
62+ fi
63+
64+ # Re-enable pipefail for subsequent commands
65+ set -o pipefail
66+
2267 build :
2368 name : build
69+ needs : [changes]
2470 runs-on : ubuntu-latest
71+ if : ${{ needs.changes.outputs.non-docs == 'true' }}
2572 steps :
26- - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
73+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2774 - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
2875 with :
2976 go-version-file : " go.mod"
77+ check-latest : true
78+ env :
79+ GOTOOLCHAIN : auto
3080 - name : build
3181 run : |
3282 go build -v ./...
3383 linting :
34- needs : [build ]
84+ needs : [changes ]
3585 name : lint
3686 runs-on : ubuntu-latest
3787 steps :
38- - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
88+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
89+ with :
90+ fetch-depth : 0
3991 - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
4092 with :
4193 go-version-file : " go.mod"
94+ check-latest : true
95+ env :
96+ GOTOOLCHAIN : auto
4297 - name : gofmt
98+ if : ${{ needs.changes.outputs.non-docs == 'true' }}
4399 run : |
44100 gofmt_out=$(gofmt -d $(find * -name '*.go' ! -path 'vendor/*' ! -path 'third_party/*'))
45101 if [[ -n "$gofmt_out" ]]; then
46102 failed=1
47103 fi
48104 echo "$gofmt_out"
49105 - name : golangci-lint
50- uses : golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9.1.0
106+ if : ${{ needs.changes.outputs.non-docs == 'true' }}
107+ uses : golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
51108 with :
52- version : v2.1.0
53- only-new-issues : true
54- args : --timeout=10m
109+ version : v2.7.2
110+ args : --new-from-merge-base=origin/${{ github.base_ref }} --timeout=10m
55111 - name : yamllint
112+ if : ${{ needs.changes.outputs.yaml == 'true' }}
56113 run : |
57114 apt update && apt install -y yamllint
58115 yamllint -c .yamllint $(find . -path ./vendor -prune -o -type f -regex ".*y[a]ml" -print | tr '\n' ' ')
59116 - name : check-license
117+ if : ${{ needs.changes.outputs.non-docs == 'true' }}
60118 run : |
61119 go install github.com/google/go-licenses@v1.0.0
62120 go-licenses check ./...
@@ -65,10 +123,13 @@ jobs:
65123 name : test
66124 runs-on : ubuntu-latest
67125 steps :
68- - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
126+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
69127 - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
70128 with :
71129 go-version-file : " go.mod"
130+ check-latest : true
131+ env :
132+ GOTOOLCHAIN : auto
72133 - name : build
73134 run : |
74135 make test-unit-verbose-and-race
@@ -77,10 +138,13 @@ jobs:
77138 name : Check generated code
78139 runs-on : ubuntu-latest
79140 steps :
80- - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
141+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
81142 - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
82143 with :
83144 go-version-file : " go.mod"
145+ check-latest : true
146+ env :
147+ GOTOOLCHAIN : auto
84148 - name : generated
85149 run : |
86150 ./hack/verify-codegen.sh
@@ -89,10 +153,13 @@ jobs:
89153 name : Multi-arch build
90154 runs-on : ubuntu-latest
91155 steps :
92- - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
156+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
93157 - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
94158 with :
95159 go-version-file : " go.mod"
160+ check-latest : true
161+ env :
162+ GOTOOLCHAIN : auto
96163 - uses : ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
97164 - name : ko-resolve
98165 run : |
@@ -104,8 +171,9 @@ jobs:
104171 github.com/tektoncd/operator/cmd/openshift/proxy-webhook: registry.access.redhat.com/ubi9/ubi-minimal
105172 EOF
106173
107- KO_DOCKER_REPO=example.com make TARGET=kubernetes resolve
108- KO_DOCKER_REPO=example.com make TARGET=openshift resolve
174+ # Use ko from setup-ko action to avoid Go version mismatch
175+ KO_BIN=$(which ko) KO_DOCKER_REPO=example.com make TARGET=kubernetes resolve
176+ KO_BIN=$(which ko) KO_DOCKER_REPO=example.com make TARGET=openshift resolve
109177 e2e-tests :
110178 needs : [build]
111179 uses : ./.github/workflows/e2e-matrix.yml
0 commit comments