Skip to content

Commit 5987669

Browse files
authored
Fix when native binary exists (#43)
* fix: download binary when native binary exist #37 * fix: pre-commit run --all-files * fix: let specific version pass test * docs: remove 12.0.1 out of readme * update workflow and pass Codecov
1 parent b7d9c66 commit 5987669

File tree

7 files changed

+44
-29
lines changed

7 files changed

+44
-29
lines changed

.github/workflows/python-test.yml

+30-16
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
name: Test
55

66
on:
7-
push:
8-
# branches: [ "main" ]
9-
paths:
10-
- '**.py'
11-
- '.github/workflows/python-test.yml'
127
pull_request:
138
branches: [ "main" ]
149
workflow_dispatch:
@@ -29,8 +24,8 @@ jobs:
2924
run: |
3025
python3 -m pip install --upgrade pip
3126
python3 -m pip install . -r requirements-dev.txt
32-
33-
- run: pre-commit run
27+
- name: Run pre-commit
28+
run: pre-commit run --all-files
3429

3530
- name: Collect coverage
3631
run: |
@@ -81,26 +76,45 @@ jobs:
8176
- name: Install clang-tools
8277
run: clang-tools --install ${{ matrix.version }}
8378

84-
- name: show path of binaries
79+
- name: Show path of binaries
8580
shell: bash
8681
run: |
87-
which clang-format-${{ matrix.version }}
88-
which clang-tidy-${{ matrix.version }}
82+
if [ "${{ matrix.version }}" = "15" -a "${{ matrix.os }}" = "windows-latest" ]; then
83+
which clang-format
84+
which clang-tidy
85+
elif [ "${{ matrix.version }}" = "12.0.1" -a "${{ matrix.os }}" = "ubuntu-latest" ]; then
86+
which clang-format-12
87+
which clang-tidy-12
88+
else
89+
which clang-format-${{ matrix.version }}
90+
which clang-tidy-${{ matrix.version }}
91+
fi
8992
9093
- name: Check clang-tools on Windows
9194
if: matrix.os == 'windows-latest'
95+
shell: bash
9296
run: |
93-
clang-format-${{ matrix.version }}.exe --version
94-
clang-tidy-${{ matrix.version }}.exe --version
97+
if [ "${{ matrix.version }}" = "15" ]; then
98+
clang-format.exe --version
99+
clang-tidy.exe --version
100+
else
101+
clang-format-${{ matrix.version }}.exe --version
102+
clang-tidy-${{ matrix.version }}.exe --version
103+
fi
95104
96105
- name: Check clang-tools on Unix
97106
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
98107
run: |
99-
clang-format-${{ matrix.version }} --version
100-
if [ "${{ matrix.version }}" = "14" -o "${{ matrix.version }}" = "15" ]; then
101-
echo "skip version ${{ matrix.version }} because Segmentation fault on ubuntu."
108+
if [ "${{ matrix.version }}" = "12.0.1" -a "${{ matrix.os }}" = "ubuntu-latest" ]; then
109+
clang-format-12 --version
110+
clang-tidy-12 --version
102111
else
103-
clang-tidy-${{ matrix.version }} --version
112+
clang-format-${{ matrix.version }} --version
113+
if [ "${{ matrix.version }}" = "14" -o "${{ matrix.version }}" = "15" ]; then
114+
echo "skip version ${{ matrix.version }} because Segmentation fault on ubuntu."
115+
else
116+
clang-tidy-${{ matrix.version }} --version
117+
fi
104118
fi
105119
106120
docs:

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ tests/__pycache__/
1313
.eggs
1414
.mypy_cache/
1515
*env
16-
docs/cli_args.rst
16+
docs/cli_args.rst

README.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ Supported versions
124124
clang-format
125125
************
126126
.. csv-table::
127-
:header: "Version", "15", "14", "13", "12.0.1", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3.9"
127+
:header: "Version", "15", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3.9"
128128
:stub-columns: 1
129129

130-
Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
131-
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
132-
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
130+
Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
131+
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
132+
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
133133

134134
clang-tidy
135135
**********
136136
.. csv-table::
137-
:header: "Version", "15", "14", "13", "12.0.1", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3.9"
137+
:header: "Version", "15", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3.9"
138138
:stub-columns: 1
139139

140-
Linux,❌,❌,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
141-
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
142-
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
140+
Linux,❌,❌,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
141+
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
142+
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
143143

144144
Know issues:
145145

clang_tools/install.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def is_installed(tool_name: str, version: str) -> Optional[Path]:
5454
return None # failed to locate the binary
5555
path = Path(path).resolve()
5656
print("at", str(path))
57+
ver_num = ver_num.groups(0)[0].decode(encoding="utf-8").split(".") # pragma: no cover
5758
if (
58-
ver_num is None
59-
or ver_num.groups(0)[0].decode(encoding="utf-8").split(".") != version_tuple
59+
ver_num is None or ver_num[0] != ver_major
6060
):
6161
return None # version is unknown or not the desired major release
6262
return path

clang_tools/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .install import install_clang_tools, uninstall_clang_tools
1010
from . import RESET_COLOR, YELLOW
1111

12+
1213
def get_parser() -> argparse.ArgumentParser:
1314
"""Get and parser to interpret CLI args."""
1415
parser = argparse.ArgumentParser()

clang_tools/util.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from http.client import HTTPResponse
1414

1515

16-
1716
def check_install_os() -> str:
1817
"""Identify this Operating System.
1918

tests/test_install.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ def test_install_tools(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, version:
6464
fd.name for fd in tmp_path.iterdir()
6565
]
6666

67+
6768
def test_path_warning(capsys: pytest.CaptureFixture):
6869
"""Explicitly fail to download a set of tools to test the prompts that
69-
70+
7071
1. warns users about using a dir not in env var PATH.
7172
2. indicates a failure to download a tool
7273
"""

0 commit comments

Comments
 (0)