@@ -98,4 +98,174 @@ jobs:
9898 run :
9999 # python -m pytest ./${{ matrix.package-name }} --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html |
100100 # wrap pytest to avoid error when no tests in the package
101- sh -c 'python -m pytest ./${{ matrix.package-name }}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret'
101+ sh -c 'python -m pytest ./${{ matrix.package-name }}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret'
102+
103+ # Step 3: Check if GEOS integration is required based on changed files
104+ check_geos_integration_required :
105+ name : Check GEOS Integration Required
106+ runs-on : ubuntu-latest
107+ needs : [semantic_pull_request, build]
108+ if : github.event_name == 'pull_request'
109+ outputs :
110+ geos_integration_required : ${{ steps.check_changes.outputs.required }}
111+ skip_reason : ${{ steps.check_changes.outputs.skip_reason }}
112+ steps :
113+ - name : Checkout code
114+ uses : actions/checkout@v4
115+ with :
116+ fetch-depth : 0 # Fetch all history to compare with base branch
117+
118+ - name : Check if GEOS integration is required
119+ id : check_changes
120+ run : |
121+ echo "Analyzing changed files to determine if GEOS integration test is required..."
122+
123+ # Get list of changed files
124+ git fetch origin ${{ github.base_ref }}
125+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
126+
127+ echo "Changed files:"
128+ echo "$CHANGED_FILES"
129+ echo ""
130+
131+ # Define packages that are integrated into GEOS (from GEOS/scripts/setupPythonEnvironment.bash)
132+ GEOS_INTEGRATED_PACKAGES=(
133+ "geos-utils"
134+ "geos-mesh"
135+ "geos-xml-tools"
136+ "hdf5-wrapper"
137+ "pygeos-tools"
138+ "geos-ats"
139+ )
140+
141+ # Define patterns that DON'T require GEOS integration testing
142+ SKIP_PATTERNS=(
143+ "^docs/"
144+ "^\.github/workflows/doc-test\.yml$"
145+ "^\.github/workflows/typing-check\.yml$"
146+ "^README\.md$"
147+ "^\.readthedocs\.yml$"
148+ "^\.gitignore$"
149+ "^\.gitattributes$"
150+ "^\.style\.yapf$"
151+ "^\.ruff\.toml$"
152+ "^\.mypy\.ini$"
153+ # Packages not used in GEOS
154+ "^geos-geomechanics/"
155+ "^geos-posp/"
156+ "^geos-pv/"
157+ "^geos-timehistory/"
158+ "^geos-trame/"
159+ "^geos-xml-viewer/"
160+ )
161+
162+ # Check if label is present (overrides automatic detection)
163+ HAS_LABEL=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q "test-geos-integration" && echo "true" || echo "false")
164+
165+ if [[ "$HAS_LABEL" == "true" ]]; then
166+ echo "✓ Label 'test-geos-integration' found - GEOS integration test will run"
167+ echo "required=true" >> "$GITHUB_OUTPUT"
168+ echo "skip_reason=none" >> "$GITHUB_OUTPUT"
169+ exit 0
170+ fi
171+
172+ # Check if any changed file affects GEOS-integrated packages
173+ REQUIRES_GEOS_TEST=false
174+ AFFECTED_PACKAGES=""
175+
176+ for file in $CHANGED_FILES; do
177+ # Check if file matches any skip pattern
178+ SHOULD_SKIP=false
179+ for pattern in "${SKIP_PATTERNS[@]}"; do
180+ if echo "$file" | grep -qE "$pattern"; then
181+ SHOULD_SKIP=true
182+ break
183+ fi
184+ done
185+
186+ if [[ "$SHOULD_SKIP" == "false" ]]; then
187+ # Check if file is in a GEOS-integrated package
188+ for package in "${GEOS_INTEGRATED_PACKAGES[@]}"; do
189+ if echo "$file" | grep -qE "^${package}/"; then
190+ REQUIRES_GEOS_TEST=true
191+ if [[ ! "$AFFECTED_PACKAGES" =~ "$package" ]]; then
192+ AFFECTED_PACKAGES="$AFFECTED_PACKAGES $package"
193+ fi
194+ fi
195+ done
196+
197+ # Check for CI workflow changes that affect GEOS integration
198+ if echo "$file" | grep -qE "^\.github/workflows/(python-package\.yml|test_geos_integration\.yml)$"; then
199+ REQUIRES_GEOS_TEST=true
200+ AFFECTED_PACKAGES="$AFFECTED_PACKAGES [CI-workflows]"
201+ fi
202+
203+ # Check for root-level scripts that might affect integration
204+ if echo "$file" | grep -qE "^install_packages\.sh$"; then
205+ REQUIRES_GEOS_TEST=true
206+ AFFECTED_PACKAGES="$AFFECTED_PACKAGES [install-scripts]"
207+ fi
208+ fi
209+ done
210+
211+ if [[ "$REQUIRES_GEOS_TEST" == "true" ]]; then
212+ echo "✓ GEOS integration test REQUIRED"
213+ echo " Affected packages/components:$AFFECTED_PACKAGES"
214+ echo " These packages are integrated into GEOS and require testing"
215+ echo "required=true" >> "$GITHUB_OUTPUT"
216+ echo "skip_reason=none" >> "$GITHUB_OUTPUT"
217+ else
218+ echo "⊘ GEOS integration test NOT required"
219+ echo " All changes are in documentation, non-integrated packages, or config files"
220+ echo " To force GEOS integration testing, add the 'test-geos-integration' label"
221+ echo "required=false" >> "$GITHUB_OUTPUT"
222+ echo "skip_reason=no-geos-integrated-changes" >> "$GITHUB_OUTPUT"
223+ fi
224+
225+ # Step 4: Run GEOS integration tests (only if required or label present)
226+ geos_integration_test :
227+ name : GEOS Integration Test
228+ needs : [check_geos_integration_required]
229+ if : needs.check_geos_integration_required.outputs.geos_integration_required == 'true'
230+ uses : ./.github/workflows/test_geos_integration.yml
231+
232+ # Final validation - Summarize CI results
233+ final_validation :
234+ name : Final CI Validation
235+ runs-on : ubuntu-latest
236+ needs : [check_geos_integration_required, geos_integration_test]
237+ if : always() && github.event_name == 'pull_request'
238+ steps :
239+ - name : Validate CI completion
240+ run : |
241+ echo "Final CI Validation"
242+ echo "==================="
243+
244+ GEOS_REQUIRED="${{ needs.check_geos_integration_required.outputs.geos_integration_required }}"
245+ SKIP_REASON="${{ needs.check_geos_integration_required.outputs.skip_reason }}"
246+ GEOS_RESULT="${{ needs.geos_integration_test.result }}"
247+
248+ if [[ "$GEOS_REQUIRED" == "true" ]]; then
249+ echo "GEOS integration test was required and triggered"
250+ if [[ "$GEOS_RESULT" == "success" ]]; then
251+ echo "✓ GEOS integration test PASSED"
252+ echo "✓ All CI requirements satisfied - PR can be merged"
253+ else
254+ echo "✗ GEOS integration test FAILED or was skipped"
255+ echo "✗ CI FAILED - PR cannot be merged until GEOS integration passes"
256+ exit 1
257+ fi
258+ else
259+ echo "GEOS integration test was NOT required"
260+ echo "Reason: $SKIP_REASON"
261+ echo ""
262+ echo "Changed files do not affect GEOS-integrated packages:"
263+ echo " - geos-utils, geos-mesh, geos-xml-tools"
264+ echo " - hdf5-wrapper, pygeos-tools, geos-ats"
265+ echo ""
266+ echo "If you want to run GEOS integration tests anyway,"
267+ echo "add the 'test-geos-integration' label to this PR"
268+ echo ""
269+ echo "✓ CI requirements satisfied - PR can be merged"
270+ fi
271+
0 commit comments