Workflow python-test.yml #1
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: Python Tests with Elasticsearch | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| elasticsearch: | |
| image: docker.elastic.co/elasticsearch/elasticsearch:7.17.10 | |
| ports: | |
| - 9200:9200 | |
| options: >- | |
| --health-cmd "curl -s http://localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'" | |
| --health-interval 10s | |
| --health-timeout 120s | |
| --health-retries 10 | |
| env: | |
| discovery.type: single-node | |
| ES_JAVA_OPTS: "-Xms2g -Xmx2g" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Wait for Elasticsearch to be ready | |
| run: | | |
| until curl -s http://localhost:9200 >/dev/null; do | |
| echo "Waiting for Elasticsearch..." | |
| sleep 5 | |
| done | |
| - name: Run pytest tests | |
| env: | |
| ES_HOST: http://localhost:9200 | |
| run: | | |
| pytest tests/ |