Skip to content

Commit 8b3447f

Browse files
committed
Split CI into Jenkins and GitHub Actions
1 parent b187c7a commit 8b3447f

File tree

5 files changed

+67
-21
lines changed

5 files changed

+67
-21
lines changed

.ci/run-repository.sh

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ docker run \
3737
--env "ELASTICSEARCH_HOST=${ELASTICSEARCH_URL}" \
3838
--env "TEST_SUITE=${TEST_SUITE}" \
3939
--env "PYTHON_CONNECTION_CLASS=${PYTHON_CONNECTION_CLASS}" \
40+
--env "TEST_TYPE=server" \
4041
--name elasticsearch-py \
4142
--rm \
4243
--volume `pwd`:/code/elasticsearch-py \

.github/workflows/ci.yml

+22
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,25 @@ jobs:
5353
python3.7 -m pip install tox
5454
- name: Build the docs
5555
run: tox -e docs
56+
57+
test-linux:
58+
runs-on: ubuntu-latest
59+
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
64+
65+
steps:
66+
- name: Checkout Repository
67+
uses: actions/checkout@v1
68+
- name: Set Up Python - ${{ matrix.python-version }}
69+
uses: actions/setup-python@v1
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
- name: Install Dependencies
73+
run: |
74+
python -m pip install -r dev-requirements.txt
75+
- name: Run Tests
76+
run: |
77+
python setup.py test

test_elasticsearch/run_tests.py

+28-5
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ def fetch_es_repo():
6464
def run_all(argv=None):
6565
atexit.register(lambda: sys.stderr.write("Shutting down....\n"))
6666

67-
# fetch yaml tests
68-
fetch_es_repo()
67+
# fetch yaml tests anywhere that's not GitHub Actions
68+
if "GITHUB_ACTION" not in environ:
69+
fetch_es_repo()
6970

7071
# always insert coverage when running tests
7172
if argv is None:
@@ -81,10 +82,32 @@ def run_all(argv=None):
8182
"-vv",
8283
]
8384

85+
ignores = []
86+
# Python 3.6+ is required for async
8487
if sys.version_info < (3, 6):
85-
argv.append("--ignore=test_elasticsearch/test_async/")
86-
87-
argv.append(abspath(dirname(__file__)),)
88+
ignores.append("test_elasticsearch/test_async/")
89+
90+
# GitHub Actions, run non-server tests
91+
if "GITHUB_ACTION" in environ:
92+
ignores.extend(
93+
[
94+
"test_elasticsearch/test_server/",
95+
"test_elasticsearch/test_async/test_server/",
96+
]
97+
)
98+
if ignores:
99+
argv.extend(["--ignore=%s" % ignore for ignore in ignores])
100+
101+
# Jenkins, only run server tests
102+
if environ.get("TEST_TYPE") == "server":
103+
test_dir = abspath(dirname(__file__))
104+
argv.append(join(test_dir, "test_server"))
105+
if sys.version_info >= (3, 6):
106+
argv.append(join(test_dir, "test_async/test_server"))
107+
108+
# Not in CI, run all tests specified.
109+
else:
110+
argv.append(abspath(dirname(__file__)))
88111

89112
exit_code = 0
90113
try:

test_elasticsearch/test_async/test_server/test_rest_api_spec.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ def async_runner(async_client):
200200
return AsyncYamlRunner(async_client)
201201

202202

203-
@pytest.mark.parametrize("test_spec", YAML_TEST_SPECS)
204-
async def test_rest_api_spec(test_spec, async_runner):
205-
if not RUN_ASYNC_REST_API_TESTS:
206-
pytest.skip("Skipped running async REST API tests")
207-
if test_spec.get("skip", False):
208-
pytest.skip("Manually skipped in 'SKIP_TESTS'")
209-
async_runner.use_spec(test_spec)
210-
await async_runner.run()
203+
if RUN_ASYNC_REST_API_TESTS:
204+
205+
@pytest.mark.parametrize("test_spec", YAML_TEST_SPECS)
206+
async def test_rest_api_spec(test_spec, async_runner):
207+
if test_spec.get("skip", False):
208+
pytest.skip("Manually skipped in 'SKIP_TESTS'")
209+
async_runner.use_spec(test_spec)
210+
await async_runner.run()

test_elasticsearch/test_server/test_rest_api_spec.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,11 @@ def sync_runner(sync_client):
423423
return YamlRunner(sync_client)
424424

425425

426-
@pytest.mark.parametrize("test_spec", YAML_TEST_SPECS)
427-
def test_rest_api_spec(test_spec, sync_runner):
428-
if RUN_ASYNC_REST_API_TESTS:
429-
pytest.skip("Skipped running sync REST API tests")
430-
if test_spec.get("skip", False):
431-
pytest.skip("Manually skipped in 'SKIP_TESTS'")
432-
sync_runner.use_spec(test_spec)
433-
sync_runner.run()
426+
if not RUN_ASYNC_REST_API_TESTS:
427+
428+
@pytest.mark.parametrize("test_spec", YAML_TEST_SPECS)
429+
def test_rest_api_spec(test_spec, sync_runner):
430+
if test_spec.get("skip", False):
431+
pytest.skip("Manually skipped in 'SKIP_TESTS'")
432+
sync_runner.use_spec(test_spec)
433+
sync_runner.run()

0 commit comments

Comments
 (0)