Skip to content

ci: Add testing for the integration of geosPythonPackages in GEOS #550

ci: Add testing for the integration of geosPythonPackages in GEOS

ci: Add testing for the integration of geosPythonPackages in GEOS #550

Workflow file for this run

name: geosPythonPackages CI
on: pull_request
# Cancels in-progress workflows for a PR when updated
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Checks if PR title follows conventional semantics
semantic_pull_request:
permissions:
pull-requests: write # for amannn/action-semantic-pull-request to analyze PRs and
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
contents: read
runs-on: ubuntu-latest
steps:
- name: Check if the PR name has conventional semantics
if: github.event_name == 'pull_request'
uses: amannn/action-semantic-pull-request@v5.5.3
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
wip: true
# Configure that a scope doesn't need to be provided.
requireScope: false
- name: Skip the check on main branch
if: github.ref_name == 'main'
run: |
echo "This is not a Pull-Request, skipping"
# build:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# max-parallel: 3
# matrix:
# python-version: ["3.10", "3.11", "3.12"]
# package-name:
# - geos-ats
# - geos-geomechanics
# - geos-mesh
# - geos-posp
# - geos-timehistory
# - geos-trame
# - geos-utils
# - geos-xml-tools
# - geos-xml-viewer
# - hdf5-wrapper
# - pygeos-tools
# include:
# - package-name: geos-geomechanics
# dependencies: "geos-utils"
# - package-name: geos-mesh
# dependencies: "geos-utils geos-geomechanics"
# - package-name: geos-posp
# dependencies: "geos-utils geos-mesh geos-geomechanics"
# - package-name: pygeos-tools
# dependencies: "geos-utils geos-mesh"
# - package-name: geos-timehistory
# dependencies: "hdf5-wrapper"
# steps:
# - uses: actions/checkout@v4
# - uses: mpi4py/setup-mpi@v1
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'
# - name: Install package
# # working-directory: ./${{ matrix.package-name }}
# run: |
# python -m pip install --upgrade pip
# python -m pip install pytest yapf toml
# DEPS="${{ matrix.dependencies || '' }}"
# if [ -n "$DEPS" ]; then
# echo "Installing additional dependencies: $DEPS"
# for dep in $DEPS; do
# python -m pip install ./$dep
# done
# fi
# echo "Installing main package..."
# python -m pip install ./${{ matrix.package-name }}/[test]
# - name: Lint with yapf
# # working-directory: ./${{ matrix.package-name }}
# run: |
# yapf -r --diff ./${{ matrix.package-name }} --style .style.yapf
# - name: Test with pytest
# #working-directory: ./${{ matrix.package-name }}
# run:
# # python -m pytest ./${{ matrix.package-name }} --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html |
# # wrap pytest to avoid error when no tests in the package
# sh -c 'python -m pytest ./${{ matrix.package-name }}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret'
build:
runs-on: ubuntu-latest
steps:
- name: Skip build job for debugging
run: |
echo "DEBUGGING MODE: Skipping build job to speed up CI"
echo "This job normally tests all geosPythonPackages but is temporarily disabled"
echo "Remove this override once test_geos_integration debugging is complete"
echo "Build job marked as successful for debugging purposes"
# Step 3: Check if GEOS integration label is present - FAIL if present but GEOS integration doesn't run
check_geos_integration_required:
name: Check GEOS Integration Required
runs-on: ubuntu-latest
needs: [semantic_pull_request, build]
if: github.event_name == 'pull_request'
outputs:
geos_integration_required: ${{ steps.check_label.outputs.required }}
steps:
- name: Check for test-geos-integration label
id: check_label
run: |
echo "Checking for mandatory test-geos-integration label..."
# Check if the PR has the required label
HAS_LABEL=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q "test-geos-integration" && echo "true" || echo "false")
if [[ "$HAS_LABEL" == "true" ]]; then
echo "Label 'test-geos-integration' found"
echo "GEOS integration test will now run"
echo "required=true" >> "$GITHUB_OUTPUT"
else
echo "Label 'test-geos-integration' NOT found"
echo "This label is mandatory for ALL PRs"
echo "Please add the 'test-geos-integration' label to trigger GEOS integration tests"
echo "PR cannot be merged without this label and passing GEOS integration tests"
echo "required=false" >> "$GITHUB_OUTPUT"
exit 1
fi
# Step 4: Run GEOS integration tests (mandatory if label present)
geos_integration_test:
name: GEOS Integration Test
needs: [check_geos_integration_required]
if: needs.check_geos_integration_required.outputs.geos_integration_required == 'true'
uses: ./.github/workflows/test_geos_integration.yml
# Final validation - FAIL if GEOS integration was required but didn't pass
final_validation:
name: Final CI Validation
runs-on: ubuntu-latest
needs: [check_geos_integration_required, geos_integration_test]
if: always() && github.event_name == 'pull_request'
steps:
- name: Validate CI completion
run: |
echo "Final CI Validation"
echo "==================="
GEOS_REQUIRED="${{ needs.check_geos_integration_required.outputs.geos_integration_required }}"
GEOS_RESULT="${{ needs.geos_integration_test.result }}"
if [[ "$GEOS_REQUIRED" == "true" ]]; then
echo "GEOS integration test was triggered"
if [[ "$GEOS_RESULT" == "success" ]]; then
echo "GEOS integration test PASSED"
echo "All CI requirements satisfied - PR can be merged"
else
echo "GEOS integration test FAILED or was skipped"
echo "CI FAILED - PR cannot be merged until GEOS integration passes"
exit 1
fi
else
echo "GEOS integration test was NOT triggered"
echo "Label 'test-geos-integration' is MANDATORY for ALL PRs"
echo "Add the label to trigger GEOS integration tests"
echo "CI FAILED - PR cannot be merged without GEOS integration testing"
exit 1
fi