Skip to content

wait

wait #21

Workflow file for this run

name: sfeos

Check failure on line 1 in .github/workflows/cicd.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/cicd.yml

Invalid workflow file

(Line: 102, Col: 14): Unexpected symbol: 'OPENSEARCH_HOST:-localhost'. Located at position 5 within expression: env.OPENSEARCH_HOST:-localhost
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: true
plugins.security.ssl.http.enabled: true
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
action.destructive_requires_name: false
ports:
- 9202:9202
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 OpenSearch to be ready
run: |
set -e
host="${{ env.OPENSEARCH_HOST:-localhost }}"
port="${{ env.OPENSEARCH_PORT:-9202 }}"
url="http://$host:$port/_cluster/health"
echo "Waiting for OpenSearch at $url"
for i in $(seq 1 60); do
if curl -sS "$url" | grep -E '"status":"(yellow|green)"' >/dev/null 2>&1; then
echo "OpenSearch is ready"
curl -sS "http://$host:$port" || true
break
fi
echo "OpenSearch not ready yet ($i/60) — sleeping 5s"
sleep 5
done
# Final check: fail the job if still not ready
if ! curl -sS "$url" | grep -E '"status":"(yellow|green)"' >/dev/null 2>&1; then
echo "OpenSearch failed to become ready within timeout"
curl -sS "http://$host:$port" || true
exit 1
fi
- name: Debug OpenSearch/Elasticsearch status
run: |
echo "Root response:"
curl -sS -D - http://localhost:$ES_PORT/ || true
echo; echo "Cluster health:"
curl -sS http://localhost:$ES_PORT/_cluster/health || true
echo; echo "List opensearch/elasticsearch containers:"
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Names}}" || true
echo; echo "Container logs (first match):"
cid=$(docker ps -q --filter "ancestor=opensearchproject/opensearch" | head -n1 || true)
if [ -n "$cid" ]; then docker logs --tail 200 $cid || true; else echo "no opensearch container found"; fi
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' }}