From 6b591f71460a717c1653796cc6a6a2392de2219e Mon Sep 17 00:00:00 2001 From: Regen Date: Sat, 16 Nov 2019 02:14:44 +0900 Subject: [PATCH 1/3] Setup CI --- .github/workflows/tests.yml | 35 +++++++++++++++++++++++++++++++++++ tox.ini | 6 ++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..8fa8535 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: Tests + +on: [push] + +jobs: + build: + env: + CMAKE_VERSION: 3.14.7 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] + python: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v1 + - name: Cache .tox + uses: actions/cache@v1 + with: + path: .tox + key: ${{ runner.OS }}-tox-${{ hashFiles('poetry.lock') }} + restore-keys: | + ${{ runner.OS }}-tox- + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + curl -sSL https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz | tar xz + python -m pip install --upgrade setuptools pip wheel + python -m pip install poetry tox-gh-actions + - name: Test with tox + run: | + export PATH=$GITHUB_WORKSPACE/cmake-$CMAKE_VERSION-Linux-x86_64/bin:$PATH + tox diff --git a/tox.ini b/tox.ini index f1b990c..7c68660 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,12 @@ isolated_build = True skipsdist = True envlist = py36, py37, py38, lint +[gh-actions] +python = + 3.6: py36 + 3.7: py37, lint + 3.8: py38 + [testenv] whitelist_externals = poetry skip_install = true From d08448340ebec5cd35d9e76f0c83d4c081a53cbf Mon Sep 17 00:00:00 2001 From: Regen Date: Sat, 16 Nov 2019 02:32:28 +0900 Subject: [PATCH 2/3] Fix errors --- src/cmake_language_server/api.py | 6 ++++-- tests/conftest.py | 16 +++++++--------- tests/test_api.py | 10 ++++++---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/cmake_language_server/api.py b/src/cmake_language_server/api.py index 5ee8876..0c9ed7c 100644 --- a/src/cmake_language_server/api.py +++ b/src/cmake_language_server/api.py @@ -50,7 +50,8 @@ class API(object): proc = subprocess.run([self._cmake, self._build], universal_newlines=True, - capture_output=True) + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) self.query_json.unlink() self.query_json.parent.rmdir() if proc.returncode != 0: @@ -133,7 +134,8 @@ endforeach() p = subprocess.run([self._cmake, '-P', tmplist], cwd=cmake_files['paths']['source'], universal_newlines=True, - capture_output=True) + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) if p.returncode != 0: return diff --git a/tests/conftest.py b/tests/conftest.py index b042aad..598524d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,18 +1,16 @@ -import logging - import pytest @pytest.fixture() def cmake_build(shared_datadir): - from subprocess import run + from subprocess import run, PIPE source = shared_datadir / 'cmake' build = source / 'build' build.mkdir() - p = run(['cmake', '-S', source, '-B', build], - check=True, - capture_output=True, - universal_newlines=True) - logging.debug(p.stdout) - logging.debug(p.stderr) + run(['cmake', source], + check=True, + cwd=build, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True) yield build diff --git a/tests/test_api.py b/tests/test_api.py index e46d684..44dadf1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -43,8 +43,9 @@ def test_parse_commands(cmake_build): api.parse_doc() p = subprocess.run(['cmake', '--help-command-list'], - capture_output=True, - universal_newlines=True) + universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) commands = p.stdout.strip().split('\n') for command in commands: @@ -59,8 +60,9 @@ def test_parse_variables(cmake_build): api.parse_doc() p = subprocess.run(['cmake', '--help-variable-list'], - capture_output=True, - universal_newlines=True) + universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) variables = p.stdout.strip().split('\n') for variable in variables: From d09656b2b80a5e56604073fe60f3267f4f9961fe Mon Sep 17 00:00:00 2001 From: Regen Date: Sat, 16 Nov 2019 03:30:23 +0900 Subject: [PATCH 3/3] Add CI status --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f7f2340..bdd1ae6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # cmake-language-server +[![GitHub Actions (Tests)](https://github.com/regen100/cmake-language-server/workflows/Tests/badge.svg)](https://github.com/regen100/cmake-language-server/actions) CMake LSP Implementation.