Skip to content

Commit a64a958

Browse files
committed
Moved from Travis to github actions; Workaround for pygls throwing RuntimeErrors during tests
1 parent 5ce8afd commit a64a958

File tree

2 files changed

+61
-17
lines changed

2 files changed

+61
-17
lines changed

.github/workflows/unit_tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Unit tests
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
Python36:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: Setup Python 3.6
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: 3.6
15+
- name: Get Docker image
16+
run: docker pull suoto/hdl_checker_test:latest
17+
- name: Run tests
18+
run: |
19+
./run_tests.sh -e py36-linux -- -v
20+
Python37:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v1
24+
- name: Setup Python 3.7
25+
uses: actions/setup-python@v1
26+
with:
27+
python-version: 3.7
28+
- name: Get Docker image
29+
run: docker pull suoto/hdl_checker_test:latest
30+
- name: Run tests
31+
run: |
32+
./run_tests.sh -e py37-linux -- -v
33+
Python38:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v1
37+
- name: Setup Python 3.8
38+
uses: actions/setup-python@v1
39+
with:
40+
python-version: 3.8
41+
- name: Get Docker image
42+
run: docker pull suoto/hdl_checker_test:latest
43+
- name: Run tests
44+
run: |
45+
./run_tests.sh -e py38-linux -- -v
46+
47+
Pypi:
48+
runs-on: ubuntu-latest
49+
needs: [Python36, Python37, Python38]
50+
steps:
51+
- name: Publish package
52+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
53+
uses: pypa/gh-action-pypi-publish@master
54+
with:
55+
user: __token__
56+
password: ${{ secrets.pypi_password }}

hdl_checker/tests/test_lsp.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import logging
2323
import os
2424
import os.path as p
25-
import time
2625
from threading import Thread
2726
from typing import Any, List, Optional, Union
2827

@@ -191,23 +190,12 @@ def tearDown(self): # pylint:disable=inconsistent-return-statements
191190
LSP_REQUEST_TIMEOUT
192191
)
193192
self.client.lsp.notify(features.EXIT)
194-
195-
for i in range(100):
196-
if not self.server_thread.is_alive():
197-
return
198-
_logger.debug(
199-
"[%d] server alive: %s, client alive: %s",
200-
i,
201-
self.server_thread.is_alive(),
202-
self.client_thread.is_alive(),
203-
)
204-
time.sleep(0.1)
205-
206-
self.fail("Timeout waiting for server thread to complete")
207-
self.client.shutdown()
208-
209193
self.assertIsNone(shutdown_response)
210-
194+
# pygls server has cleanup routines run when the interpreter is
195+
# exiting, at which point the client will be long gone. This results in
196+
# RuntimeError: cannot schedule new futures after shutdown. To work
197+
# around this, we're accessing its itnernal event to force it to exit
198+
self.client._stop_event.set()
211199
self.server_thread.join()
212200
self.client_thread.join()
213201

0 commit comments

Comments
 (0)