@@ -13,6 +13,7 @@ concurrency:
1313env :
1414 CARGO_TERM_COLOR : always
1515 RUST_BACKTRACE : 1
16+ SHELLCHECK_EXCLUDES : " "
1617 REGISTRY : ghcr.io
1718 IMAGE_NAME : ${{ github.repository }}
1819
2425 docker : ${{ steps.detect.outputs.docker }}
2526 helm : ${{ steps.detect.outputs.helm }}
2627 api_docs : ${{ steps.detect.outputs.api_docs }}
28+ rust_core : ${{ steps.detect.outputs.rust_core }}
29+ deps : ${{ steps.detect.outputs.deps }}
30+ examples : ${{ steps.detect.outputs.examples }}
2731 steps :
2832 - uses : actions/checkout@v4
2933 - name : Detect Docker-impacting changes
5155 echo "Changed files:"
5256 echo "$CHANGED_FILES"
5357
54- if echo "$CHANGED_FILES" | grep -Eq '^(Dockerfile|\.dockerignore|Cargo\.toml|Cargo\.lock|src/|config/|Makefile)'; then
58+ DOCKER_PATTERN='^(Dockerfile|\.dockerignore|Cargo\.toml|Cargo\.lock|src/|config/|Makefile)'
59+ if echo "$CHANGED_FILES" | grep -Eq "$DOCKER_PATTERN"; then
5560 echo "docker=true" >> "$GITHUB_OUTPUT"
5661 else
5762 echo "docker=false" >> "$GITHUB_OUTPUT"
@@ -63,12 +68,31 @@ jobs:
6368 echo "helm=false" >> "$GITHUB_OUTPUT"
6469 fi
6570
66- if echo "$CHANGED_FILES" | grep -Eq '^(docs/|scripts/generate-api-docs\.py|config/crd/|src/crd/|src/rest_api/|Makefile)'; then
71+ API_DOCS_PATTERN='^(docs/|scripts/generate-api-docs\.py|config/crd/|src/crd/|src/rest_api/|Makefile)'
72+ if echo "$CHANGED_FILES" | grep -Eq "$API_DOCS_PATTERN"; then
6773 echo "api_docs=true" >> "$GITHUB_OUTPUT"
6874 else
6975 echo "api_docs=false" >> "$GITHUB_OUTPUT"
7076 fi
7177
78+ if echo "$CHANGED_FILES" | grep -Eq '^(src/|Cargo\.toml|Cargo\.lock|Makefile|build\.rs)'; then
79+ echo "rust_core=true" >> "$GITHUB_OUTPUT"
80+ else
81+ echo "rust_core=false" >> "$GITHUB_OUTPUT"
82+ fi
83+
84+ if echo "$CHANGED_FILES" | grep -Eq '^(Cargo\.toml|Cargo\.lock)'; then
85+ echo "deps=true" >> "$GITHUB_OUTPUT"
86+ else
87+ echo "deps=false" >> "$GITHUB_OUTPUT"
88+ fi
89+
90+ if echo "$CHANGED_FILES" | grep -Eq '^(examples/|config/crd/|config/samples/)'; then
91+ echo "examples=true" >> "$GITHUB_OUTPUT"
92+ else
93+ echo "examples=false" >> "$GITHUB_OUTPUT"
94+ fi
95+
7296 version-consistency :
7397 name : Version Consistency Check
7498 if : github.event_name != 'pull_request'
@@ -102,12 +126,14 @@ jobs:
102126 echo "stellar-operator version output: $BIN_VERSION"
103127
104128 [[ "$CARGO_VERSION" == "$EXPECTED_VERSION" ]] || {
105- echo "::error::Cargo.toml version ($CARGO_VERSION) does not match expected release version ($EXPECTED_VERSION)"
129+ echo "::error::Cargo.toml version ($CARGO_VERSION) does not match expected release version"
130+ echo "::error::Expected: $EXPECTED_VERSION"
106131 exit 1
107132 }
108133
109134 [[ "$BIN_VERSION" == "$EXPECTED_VERSION" ]] || {
110- echo "::error::stellar-operator version output ($BIN_VERSION) does not match expected release version ($EXPECTED_VERSION)"
135+ echo "::error::stellar-operator version output ($BIN_VERSION) does not match expected release version"
136+ echo "::error::Expected: $EXPECTED_VERSION"
111137 exit 1
112138 }
113139
@@ -168,7 +194,9 @@ jobs:
168194
169195 examples-smoke-test :
170196 name : Examples Smoke Test
197+ if : needs.changes.outputs.examples == 'true'
171198 runs-on : ubuntu-latest
199+ needs : [changes]
172200 steps :
173201 - uses : actions/checkout@v4
174202
@@ -199,7 +227,9 @@ jobs:
199227
200228 security-audit :
201229 name : Security Audit
230+ if : needs.changes.outputs.deps == 'true'
202231 runs-on : ubuntu-latest
232+ needs : [changes]
203233 steps :
204234 - uses : actions/checkout@v4
205235
@@ -217,6 +247,7 @@ jobs:
217247 lint :
218248 name : Lint & Format
219249 runs-on : ubuntu-latest
250+ needs : [changes]
220251 steps :
221252 - uses : actions/checkout@v4
222253
@@ -238,17 +269,24 @@ jobs:
238269
239270 - name : Run shellcheck
240271 run : |
241- mapfile -t shell_files < <(find . -type f -name "*.sh")
272+ mapfile -t shell_files < <(find scripts -type f -name "*.sh")
242273 if [ "${#shell_files[@]}" -eq 0 ]; then
243- echo "No shell scripts found"
274+ echo "No shell scripts found in scripts/ "
244275 exit 0
245276 fi
246- shellcheck -S error "${shell_files[@]}"
277+ shellcheck_cmd=(shellcheck -S error)
278+ if [ -n "${SHELLCHECK_EXCLUDES}" ]; then
279+ shellcheck_cmd+=(-e "${SHELLCHECK_EXCLUDES}")
280+ echo "Running shellcheck with excludes: ${SHELLCHECK_EXCLUDES}"
281+ fi
282+ "${shellcheck_cmd[@]}" "${shell_files[@]}"
247283
248284 - name : Check formatting
285+ if : needs.changes.outputs.rust_core == 'true'
249286 run : make fmt-check
250287
251288 - name : Run clippy
289+ if : needs.changes.outputs.rust_core == 'true'
252290 run : make lint
253291
254292 test :
0 commit comments