@@ -122,8 +122,37 @@ jobs:
122
122
exit 1
123
123
fi
124
124
125
+ check-docs-changes :
126
+ runs-on : ubuntu-latest
127
+ outputs :
128
+ docs-only : ${{ steps.check.outputs.docs-only }}
129
+ steps :
130
+ - name : Checkout code
131
+ uses : actions/checkout@v4
132
+
133
+ - name : Fetch all refs
134
+ run : git fetch --prune --unshallow
135
+
136
+ - name : Check if the changes are only in docs/*, mkdocs.yml, or .github/workflows/docs.yml
137
+ id : check
138
+ run : |
139
+ set -o xtrace
140
+ # List all files modified in the commit or PR
141
+ changed_files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
142
+ # changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
143
+
144
+ # Check if any of the changed files are not in docs/*, mkdocs.yml, or .github/workflows/docs.yml
145
+ if echo "$changed_files" | grep -vqE '^(docs/|mkdocs.yml|.github/workflows/docs.yml)'; then
146
+ echo "docs-only=false" >> "$GITHUB_OUTPUT"
147
+ else
148
+ echo "Only documentation changes found."
149
+ echo "docs-only=true" >> "$GITHUB_OUTPUT"
150
+ fi
151
+
125
152
setup-workflow :
126
153
runs-on : ubuntu-latest
154
+ needs :
155
+ - check-docs-changes
127
156
outputs :
128
157
execute-knowledge-labeled : ${{ steps.configure-tests-on-labels.outputs.execute_knowledge_labeled }}
129
158
execute-spl2-labeled : ${{ steps.configure-tests-on-labels.outputs.execute_spl2_labeled }}
@@ -169,7 +198,9 @@ jobs:
169
198
case "${{ github.event_name }}" in
170
199
"pull_request")
171
200
labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[] | .name')
172
- if ${{ github.base_ref == 'main' }} && ${{ contains(github.event.pull_request.labels.*.name, 'use_labels') }}; then
201
+ if ${{ needs.check-docs-changes.outputs.docs-only == 'true' }}; then
202
+ echo -e "\033[1;33m⚠️ Skipping tests as there are only documentation related changes ⚠️\033[0m"
203
+ elif ${{ github.base_ref == 'main' }} && ${{ contains(github.event.pull_request.labels.*.name, 'use_labels') }}; then
173
204
for test_type in "${TESTSET[@]}"; do
174
205
if [[ "$labels" =~ $test_type ]]; then
175
206
EXECUTE_LABELED["$test_type"]="true"
@@ -381,6 +412,8 @@ jobs:
381
412
382
413
test-inventory :
383
414
runs-on : ubuntu-latest
415
+ needs :
416
+ - check-docs-changes
384
417
# Map a step output to a job output
385
418
outputs :
386
419
spl2 : ${{ steps.testset.outputs.spl2 }}
@@ -396,8 +429,8 @@ jobs:
396
429
- id : testset
397
430
name : Check available test types
398
431
run : |
399
- find tests -type d -maxdepth 1 -mindepth 1 | sed 's|^tests/||g' | while read -r TESTSET; do echo "$TESTSET=true" >> "$GITHUB_OUTPUT"; echo "$TESTSET::true"; done
400
- find package/default/data -type d -name "spl2" -maxdepth 1 -mindepth 1 | sed 's|^package/default/data/||g' | while read -r TESTSET; do echo "$TESTSET=true" >> "$GITHUB_OUTPUT"; echo "$TESTSET::true"; done
432
+ find tests -type d -maxdepth 1 -mindepth 1 | sed 's|^tests/||g' | while read -r TESTSET; do echo "$TESTSET=${{ needs.check-docs-changes.outputs.docs-only == 'false' && ' true' || 'false' }} " >> "$GITHUB_OUTPUT"; echo "$TESTSET::${{ needs.check-docs-changes.outputs.docs-only == 'false' && ' true' || 'false' }} "; done
433
+ find package/default/data -type d -name "spl2" -maxdepth 1 -mindepth 1 | sed 's|^package/default/data/||g' | while read -r TESTSET; do echo "$TESTSET=${{ needs.check-docs-changes.outputs.docs-only == 'false' && ' true' || 'false' }} " >> "$GITHUB_OUTPUT"; echo "$TESTSET::${{ needs.check-docs-changes.outputs.docs-only == 'false' && ' true' || 'false' }} "; done
401
434
402
435
run-unit-tests :
403
436
name : test-unit-python3-${{ matrix.python-version }}
@@ -540,6 +573,7 @@ jobs:
540
573
build :
541
574
runs-on : ubuntu-22.04
542
575
needs :
576
+ - check-docs-changes
543
577
- validate-custom-version
544
578
- setup-workflow
545
579
- test-inventory
@@ -550,7 +584,7 @@ jobs:
550
584
- semgrep
551
585
- run-unit-tests
552
586
- fossa-scan
553
- if : ${{ !cancelled() && (needs.run-unit-tests.result == 'success' || needs.run-unit-tests.result == 'skipped') && (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped') }}
587
+ if : ${{ !cancelled() && (needs.run-unit-tests.result == 'success' || needs.run-unit-tests.result == 'skipped') && (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped') && (needs.check-docs-changes.outputs.docs-only == 'false') }}
554
588
outputs :
555
589
buildname : ${{ steps.buildupload.outputs.name }}
556
590
permissions :
@@ -728,6 +762,7 @@ jobs:
728
762
build-3_9 :
729
763
runs-on : ubuntu-latest
730
764
needs :
765
+ - check-docs-changes
731
766
- validate-custom-version
732
767
- setup-workflow
733
768
- test-inventory
@@ -741,7 +776,8 @@ jobs:
741
776
if : |
742
777
always() &&
743
778
(needs.run-unit-tests-3_9.result == 'success' || needs.run-unit-tests-3_9.result == 'skipped') &&
744
- (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped')
779
+ (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped') &&
780
+ (needs.check-docs-changes.outputs.docs-only == 'false')
745
781
permissions :
746
782
contents : write
747
783
packages : read
@@ -2903,6 +2939,7 @@ jobs:
2903
2939
outputs :
2904
2940
run-publish : ${{ steps.check.outputs.run-publish }}
2905
2941
needs :
2942
+ - check-docs-changes
2906
2943
- validate-custom-version
2907
2944
- meta
2908
2945
- compliance-copyrights
@@ -2928,7 +2965,7 @@ jobs:
2928
2965
shell : bash
2929
2966
run : |
2930
2967
RUN_PUBLISH=$(echo "$NEEDS" | jq ".[] | select( ( .result != \"skipped\" ) and .result != \"success\" ) | length == 0")
2931
- if [[ "$RUN_PUBLISH" != *'false'* ]]
2968
+ if [[ "$RUN_PUBLISH" != *'false'* ]] && [[ "${{ needs.check-docs-changes.outputs.docs-only }}" == 'false' ]]
2932
2969
then
2933
2970
echo "run-publish=true" >> "$GITHUB_OUTPUT"
2934
2971
echo "Publish conditions are met."
0 commit comments