try again #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: sfeos | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - features/** | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| services: | ||
| elasticsearch_8_svc: | ||
| image: docker.elastic.co/elasticsearch/elasticsearch:8.19.5 | ||
| env: | ||
| cluster.name: stac-cluster | ||
| node.name: es01 | ||
| network.host: 0.0.0.0 | ||
| transport.host: 0.0.0.0 | ||
| discovery.type: single-node | ||
| http.port: 9200 | ||
| xpack.license.self_generated.type: basic | ||
| xpack.security.enabled: false | ||
| xpack.security.transport.ssl.enabled: false | ||
| ES_JAVA_OPTS: -Xms512m -Xmx1g | ||
| action.destructive_requires_name: false | ||
| ports: | ||
| - 9200:9200 | ||
| opensearch_2_12: | ||
| image: opensearchproject/opensearch:2.12.0 | ||
| env: | ||
| cluster.name: stac-cluster | ||
| node.name: os01 | ||
| network.host: 0.0.0.0 | ||
| transport.host: 0.0.0.0 | ||
| discovery.type: single-node | ||
| http.port: 9202 | ||
| http.cors.enabled: true | ||
| plugins.security.disabled: 'false' | ||
| OPENSEARCH_INITIAL_ADMIN_PASSWORD: 'admin' | ||
| DISABLE_SECURITY_DEMO_CONFIG: 'true' | ||
| plugins.security.ssl.http.enabled: 'false' | ||
| plugins.security.ssl.transport.enabled: 'false' | ||
| plugins.security.authcz.admin_dn: | ||
| - "" | ||
| plugins.security.nodes_dn: | ||
| - "" | ||
| OPENSEARCH_JAVA_OPTS: >- | ||
| -Xms512m | ||
| -Xmx512m | ||
| -Dopensearch.transport.cname_in_publish_address=true | ||
| -Dopensearch.cgroups.hierarchy.override=/ | ||
| -Djava.security.manager=allow | ||
| action.destructive_requires_name: 'false' | ||
| bootstrap.memory_lock: 'false' | ||
| ports: | ||
| - 9202:9202 | ||
| options: >- | ||
| --health-cmd="curl -f http://localhost:9202/_cluster/health || exit 1" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=10 | ||
| --ulimit nofile=65536:65536 | ||
| --ulimit memlock=-1:-1 | ||
| strategy: | ||
| matrix: | ||
| python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"] | ||
| backend: [ "elasticsearch8", "opensearch"] | ||
| name: Python ${{ matrix.python-version }} testing with ${{ matrix.backend }} | ||
| steps: | ||
| - name: Check out repository code | ||
| uses: actions/checkout@v5 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| **/setup.py | ||
| - name: Lint code | ||
| if: ${{ matrix.python-version == 3.11 }} | ||
| run: | | ||
| python -m pip install pre-commit | ||
| pre-commit run --all-files | ||
| - name: Install pipenv | ||
| run: | | ||
| python -m pip install --upgrade pipenv wheel | ||
| - name: Install core library stac-fastapi | ||
| run: | | ||
| pip install ./stac_fastapi/core | ||
| - name: Install helpers library stac-fastapi | ||
| run: | | ||
| pip install ./stac_fastapi/sfeos_helpers | ||
| - name: Install elasticsearch stac-fastapi | ||
| run: | | ||
| pip install ./stac_fastapi/elasticsearch[dev,server] | ||
| - name: Install opensearch stac-fastapi | ||
| run: | | ||
| pip install ./stac_fastapi/opensearch[dev,server] | ||
| - name: Install pytest-timeout | ||
| run: | | ||
| pip install pytest-timeout | ||
| - name: Wait for Search Service to be ready | ||
| run: | | ||
| set -e | ||
| host="localhost" | ||
| port="${{ matrix.backend == 'elasticsearch8' && '9200' || '9202' }}" | ||
| url="http://$host:$port/_cluster/health" | ||
| echo "Waiting for ${{ matrix.backend }} at $url" | ||
| # Add initial delay | ||
| echo "Waiting 10s for service to start..." | ||
| sleep 10 | ||
| for i in $(seq 1 10); do # 10 retries * 5s = 50s max wait | ||
| if curl -sS --fail --show-error --max-time 5 "$url" 2>/dev/null | grep -E '"status":"(yellow|green)"' >/dev/null; then | ||
| echo "${{ matrix.backend }} is ready" | ||
| curl -sS "http://$host:$port" || true | ||
| exit 0 | ||
| fi | ||
| echo "${{ matrix.backend }} not ready yet ($((i*5))s/50s) - waiting 5s" | ||
| sleep 5 | ||
| done | ||
| echo "${{ matrix.backend }} failed to become ready within timeout" | ||
| curl -sS -v "http://$host:$port/_cluster/health" || true | ||
| echo "Container logs:" | ||
| docker ps -a | ||
| docker logs $(docker ps -q --filter "ancestor=${{ matrix.backend == 'elasticsearch8' && 'docker.elastic.co/elasticsearch/elasticsearch:8.19.5' || 'opensearchproject/opensearch:2.12.0' }}" | head -1) || true | ||
| exit 1 | ||
| - name: Debug OpenSearch/Elasticsearch status | ||
| if: always() | ||
| run: | | ||
| echo "=== System Information ===" | ||
| echo "Hostname: $(hostname)" | ||
| echo "IP Addresses: $(hostname -I || true)" | ||
| echo "Docker version: $(docker --version || true)" | ||
| echo "Docker info:" | ||
| docker info || true | ||
| echo "\n=== Container Status ===" | ||
| docker ps -a || true | ||
| echo "\n=== Network Information ===" | ||
| docker network inspect bridge || true | ||
| echo "\n=== OpenSearch Container Logs ===" | ||
| OPENSEARCH_ID=$(docker ps -a --filter "ancestor=opensearchproject/opensearch:2.12.0" -q | head -1 || true) | ||
| if [ -n "$OPENSEARCH_ID" ]; then | ||
| echo "Container logs for $OPENSEARCH_ID:" | ||
| docker logs --tail 500 $OPENSEARCH_ID || true | ||
| echo "\nContainer inspect:" | ||
| docker inspect $OPENSEARCH_ID || true | ||
| echo "\nContainer environment:" | ||
| docker exec $OPENSEARCH_ID env || true | ||
| else | ||
| echo "No OpenSearch container found" | ||
| fi | ||
| echo "\n=== Elasticsearch Container Logs ===" | ||
| ES_ID=$(docker ps -a --filter "ancestor=docker.elastic.co/elasticsearch/elasticsearch:8.19.5" -q | head -1 || true) | ||
| if [ -n "$ES_ID" ]; then | ||
| echo "Container logs for $ES_ID:" | ||
| docker logs --tail 500 $ES_ID || true | ||
| else | ||
| echo "No Elasticsearch container found" | ||
| fi | ||
| echo "\n=== Port Check ===" | ||
| echo "Port 9200 (Elasticsearch): $(nc -zv localhost 9200 2>&1 || true)" | ||
| echo "Port 9202 (OpenSearch): $(nc -zv localhost 9202 2>&1 || true)" | ||
| echo "\n=== Disk Space ===" | ||
| df -h || true | ||
| echo "\n=== Memory Info ===" | ||
| free -h || true | ||
| env: | ||
| ES_PORT: ${{ matrix.backend == 'elasticsearch8' && '9200' || '9202' }} | ||
| - name: Run test suite | ||
| run: | | ||
| pipenv run pytest -svvv --timeout=300 | ||
| env: | ||
| ENVIRONMENT: testing | ||
| ES_PORT: ${{ matrix.backend == 'elasticsearch8' && '9200' || '9202' }} | ||
| ES_HOST: 172.17.0.1 | ||
| ES_USE_SSL: false | ||
| DATABASE_REFRESH: true | ||
| ES_VERIFY_CERTS: false | ||
| BACKEND: ${{ matrix.backend == 'elasticsearch8' && 'elasticsearch' || 'opensearch' }} | ||
| OPENSEARCH_USER: admin | ||
| OPENSEARCH_PASSWORD: admin | ||
| OPENSEARCH_USE_SSL: 'false' | ||