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