Skip to content

Commit fdbbf80

Browse files
fix: Invalid label checking in CI (#158)
* Fix labels identification to trigger CI workflows * Add env variables for label names
1 parent ce3b253 commit fdbbf80

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

.github/workflows/python-package.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ concurrency:
66
group: ${{ github.workflow }}-${{ github.ref }}
77
cancel-in-progress: true
88

9+
env:
10+
LABEL_TEST_GEOS_INTEGRATION: 'test-geos-integration'
11+
LABEL_FORCE_GEOS_INTEGRATION: 'force-geos-integration'
912

1013
jobs:
1114
# Checks if PR title follows conventional semantics
@@ -124,18 +127,17 @@ jobs:
124127
outputs:
125128
has_geos_integration_label: ${{ steps.set-label.outputs.has_label }}
126129
steps:
127-
- name: Check if PR has 'test-geos-integration' label
130+
- name: Check if PR has '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label
128131
id: set-label
129132
run: |
130133
echo "Checking for label..."
131134
LABEL_FOUND=false
132-
for label in "${{ toJson(github.event.pull_request.labels) }}"; do
133-
if [[ "$label" == *"test-geos-integration"* ]]; then
134-
LABEL_FOUND=true
135-
echo "Label ${label} found"
136-
break
137-
fi
138-
done
135+
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
136+
echo "PR Labels: $LABELS"
137+
if echo "$LABELS" | grep -q "${{ env.LABEL_TEST_GEOS_INTEGRATION }}"; then
138+
LABEL_FOUND=true
139+
echo "Label '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' found"
140+
fi
139141
echo "has_label=$LABEL_FOUND" >> $GITHUB_OUTPUT
140142
141143
check_force_integration_label:
@@ -144,18 +146,17 @@ jobs:
144146
outputs:
145147
has_geos_integration_force_label: ${{ steps.set-label.outputs.has_label }}
146148
steps:
147-
- name: Check if PR has 'force-geos-integration' label
149+
- name: Check if PR has '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' label
148150
id: set-label
149151
run: |
150152
echo "Checking for label..."
151153
LABEL_FOUND=false
152-
for label in "${{ toJson(github.event.pull_request.labels) }}"; do
153-
if [[ "$label" == *"force-geos-integration"* ]]; then
154-
LABEL_FOUND=true
155-
echo "Label ${label} found"
156-
break
157-
fi
158-
done
154+
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
155+
echo "PR Labels: $LABELS"
156+
if echo "$LABELS" | grep -q "${{ env.LABEL_FORCE_GEOS_INTEGRATION }}"; then
157+
LABEL_FOUND=true
158+
echo "Label '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' found"
159+
fi
159160
echo "has_label=$LABEL_FOUND" >> $GITHUB_OUTPUT
160161
161162
# Step 3: Check if GEOS integration is required based on changed files
@@ -264,7 +265,7 @@ jobs:
264265
else
265266
echo "⊘ GEOS integration test NOT required"
266267
echo " All changes are in documentation, non-integrated packages, or config files"
267-
echo " To force GEOS integration testing, add the 'test-geos-integration' label"
268+
echo " To force GEOS integration testing, add the '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label"
268269
echo "required=false" >> "$GITHUB_OUTPUT"
269270
echo "skip_reason=no-geos-integrated-changes" >> "$GITHUB_OUTPUT"
270271
fi
@@ -291,47 +292,47 @@ jobs:
291292
292293
echo "=== GEOS Integration Dispatch ==="
293294
echo "GEOS Required (by file changes): ${GEOS_REQUIRED}"
294-
echo "Has 'test-geos-integration' label: ${HAS_TEST_LABEL}"
295-
echo "Has 'force-geos-integration' label: ${HAS_FORCE_LABEL}"
295+
echo "Has '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label: ${HAS_TEST_LABEL}"
296+
echo "Has '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' label: ${HAS_FORCE_LABEL}"
296297
echo ""
297298
298299
# Case 1: Force label - always run tests
299300
if [[ "$HAS_FORCE_LABEL" == "true" ]]; then
300-
echo "✓ 'force-geos-integration' label present - forcing GEOS integration tests"
301+
echo "✓ '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' label present - forcing GEOS integration tests"
301302
echo "skipped=false" >> "$GITHUB_OUTPUT"
302303
exit 0
303304
fi
304305
305306
# Case 2: GEOS required AND test label present - run tests
306307
if [[ "$GEOS_REQUIRED" == "true" && "$HAS_TEST_LABEL" == "true" ]]; then
307-
echo "✓ GEOS integration required and 'test-geos-integration' label present"
308+
echo "✓ GEOS integration required and '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label present"
308309
echo " Will proceed with GEOS integration tests"
309310
echo "skipped=false" >> "$GITHUB_OUTPUT"
310311
exit 0
311312
fi
312313
313314
# Case 3: GEOS required BUT test label missing - ERROR
314315
if [[ "$GEOS_REQUIRED" == "true" && "$HAS_TEST_LABEL" == "false" ]]; then
315-
echo "✗ ERROR: GEOS integration is required but 'test-geos-integration' label is missing"
316+
echo "✗ ERROR: GEOS integration is required but '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label is missing"
316317
echo ""
317318
echo "Your PR modifies GEOS-integrated packages:"
318319
echo " - geos-utils, geos-mesh, geos-xml-tools"
319320
echo " - hdf5-wrapper, pygeos-tools, geos-ats"
320321
echo ""
321-
echo "Action required: Add the 'test-geos-integration' label to this PR"
322+
echo "Action required: Add the '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label to this PR"
322323
exit 1
323324
fi
324325
325326
# Case 4: GEOS NOT required BUT test label present - SKIP TESTS
326327
if [[ "$GEOS_REQUIRED" == "false" && "$HAS_TEST_LABEL" == "true" ]]; then
327-
echo "⊘ SKIPPED: 'test-geos-integration' label present but GEOS integration is not required"
328+
echo "⊘ SKIPPED: '${{ env.LABEL_TEST_GEOS_INTEGRATION }}' label present but GEOS integration is not required"
328329
echo ""
329330
echo "Your changes only affect:"
330331
echo " - Documentation"
331332
echo " - Non-integrated packages"
332333
echo " - Configuration files"
333334
echo ""
334-
echo "If you want to run GEOS integration tests anyway, use 'force-geos-integration' label to explicitly force testing"
335+
echo "If you want to run GEOS integration tests anyway, use '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' label to explicitly force testing"
335336
echo "skipped=true" >> "$GITHUB_OUTPUT"
336337
exit 0
337338
fi
@@ -353,7 +354,7 @@ jobs:
353354
geos_integration_test:
354355
name: GEOS Integration Test
355356
needs: [geos_ci_dispatch]
356-
if: ${{ needs.geos_ci_dispatch.outputs.is_GEOS_CI_skipped.skipped != 'true' }}
357+
if: ${{ needs.geos_ci_dispatch.outputs.is_GEOS_CI_skipped != 'true' }}
357358
uses: ./.github/workflows/test_geos_integration.yml
358359

359360
# Final validation - Summarize CI results
@@ -392,8 +393,7 @@ jobs:
392393
echo " - hdf5-wrapper, pygeos-tools, geos-ats"
393394
echo ""
394395
echo "If you want to run GEOS integration tests anyway,"
395-
echo "add the 'test-geos-integration' label to this PR"
396+
echo "add the '${{ env.LABEL_FORCE_GEOS_INTEGRATION }}' label to this PR"
396397
echo ""
397398
echo "✓ CI requirements satisfied - PR can be merged"
398399
fi
399-

0 commit comments

Comments
 (0)