Skip to content

Commit a06c865

Browse files
rhblindulgens
authored andcommitted
Create test workflow
Extracted from #189
1 parent c97b362 commit a06c865

3 files changed

Lines changed: 63 additions & 8 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Tests"
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
permissions: {}
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
test:
13+
name: "tox -v"
14+
runs-on: ubuntu-24.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
django-version: ["4.2"]
19+
python-version: ["3.8", "3.9", "3.10"]
20+
elastic-version: ["1.7", "2.4", "5.5", "7.13.1"]
21+
22+
services:
23+
elastic:
24+
# TODO: Revisit pinning strategy
25+
image: elasticsearch:${{ matrix.elastic-version }} # zizmor: ignore[unpinned-images]
26+
env:
27+
discovery.type: "single-node"
28+
options: >-
29+
--health-cmd "curl http://localhost:9200/_cluster/health"
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 10
33+
ports:
34+
- 9200:9200
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
39+
with:
40+
persist-credentials: false
41+
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Install system dependencies
48+
run: sudo apt install --no-install-recommends -y gdal-bin
49+
50+
- name: Run tests with Django ${{ matrix.django-version }} and Elasticsearch ${{ matrix.elastic-version }}
51+
# FIXME: Find a way to remove zizmor ignore
52+
run: | # zizmor: ignore[template-injection]
53+
python -m pip install --upgrade pip setuptools wheel
54+
pip install coverage pytz
55+
pip install django==${{ matrix.django-version }} elasticsearch==${{ matrix.elastic-version }}
56+
pip install --editable .
57+
coverage run tests/run_tests.py

tests/settings.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,9 @@
9191
},
9292
}
9393

94-
try:
95-
import elasticsearch
94+
import elasticsearch
9695

97-
if (2,) <= elasticsearch.VERSION <= (3,):
98-
HAYSTACK_CONNECTIONS["default"].update({
99-
"ENGINE": "haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine"
100-
})
101-
except ImportError:
102-
del HAYSTACK_CONNECTIONS["default"] # This will intentionally cause everything to break!
96+
if (2,) <= elasticsearch.VERSION <= (3,):
97+
HAYSTACK_CONNECTIONS["default"].update({
98+
"ENGINE": "haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine"
99+
})

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ envlist =
88
commands =
99
coverage run {toxinidir}/tests/run_tests.py
1010
deps =
11+
pytz
1112
python-dateutil
1213
geopy==2.0.0
1314
coverage

0 commit comments

Comments
 (0)