Skip to content

Commit 77c07d8

Browse files
committed
fix: unify file type detection, normalize paths, fix tokenizer profiles
1 parent bab840c commit 77c07d8

File tree

15 files changed

+206
-185
lines changed

15 files changed

+206
-185
lines changed

.github/workflows/cd.yml

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: treemapper CD
33

44
permissions: {}
55

6+
concurrency:
7+
group: release
8+
cancel-in-progress: false
9+
610
'on':
711
workflow_dispatch:
812
inputs:
@@ -28,12 +32,12 @@ jobs:
2832
commit_sha: ${{ steps.commit_version.outputs.commit_sha }}
2933
steps:
3034
- name: Checkout Code
31-
uses: actions/checkout@v6
35+
uses: actions/checkout@v4
3236
with:
3337
fetch-depth: 0 # Need full history for git bundle
3438

3539
- name: Set up Python
36-
uses: actions/setup-python@v6
40+
uses: actions/setup-python@v5
3741
with:
3842
python-version: '3.11'
3943

@@ -46,14 +50,33 @@ jobs:
4650
exit 1
4751
fi
4852
49-
- name: Validate version format
53+
- name: Validate version format (PEP 440)
5054
run: |
5155
VERSION="${{ github.event.inputs.version }}"
52-
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
53-
echo "Error: Invalid version format '$VERSION'. Expected semver like 1.0.0 or 1.0.0-rc1"
56+
# PEP 440: X.Y.Z with optional pre-release (a1, b1, rc1) or dev/post suffix
57+
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?(\.dev[0-9]+)?(\.post[0-9]+)?$ ]]; then
58+
echo "Error: Invalid version format '$VERSION'."
59+
echo "Expected PEP 440 format: 1.0.0, 1.0.0a1, 1.0.0b1, 1.0.0rc1, 1.0.0.dev1, 1.0.0.post1"
60+
exit 1
61+
fi
62+
echo "Version format valid (PEP 440): $VERSION"
63+
64+
- name: Check version is not already set
65+
env:
66+
VERSION: ${{ github.event.inputs.version }}
67+
run: |
68+
CURRENT=$(python -c "
69+
import re
70+
content = open('src/treemapper/version.py').read()
71+
m = re.search(r'__version__\s*=\s*[\"'\'']([^\"'\'']+)[\"'\'']', content)
72+
print(m.group(1) if m else '')
73+
")
74+
if [ "$CURRENT" = "$VERSION" ]; then
75+
echo "Error: version.py already contains version $VERSION"
76+
echo "Nothing to release - version is already set."
5477
exit 1
5578
fi
56-
echo "Version format valid: $VERSION"
79+
echo "Current version: $CURRENT -> New version: $VERSION"
5780
5881
- name: Set version in version.py
5982
env:
@@ -112,7 +135,7 @@ jobs:
112135
git bundle create repo.bundle --all
113136
114137
- name: Upload bundle as artifact
115-
uses: actions/upload-artifact@v6
138+
uses: actions/upload-artifact@v4
116139
with:
117140
name: git-repo-bundle
118141
path: repo.bundle
@@ -143,7 +166,7 @@ jobs:
143166
runs-on: ${{ matrix.os }}
144167
steps:
145168
- name: Download git bundle
146-
uses: actions/download-artifact@v7
169+
uses: actions/download-artifact@v4
147170
with:
148171
name: git-repo-bundle
149172

@@ -164,18 +187,11 @@ jobs:
164187
ls -la src/treemapper/ || echo "ERROR: src/treemapper not found!"
165188
166189
- name: Set up Python
167-
uses: actions/setup-python@v6
190+
uses: actions/setup-python@v5
168191
with:
169192
python-version: ${{ matrix.python-version }}
170-
171-
- name: Cache pip Dependencies
172-
uses: actions/cache@v5
173-
with:
174-
path: ~/.cache/pip
175-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
176-
restore-keys: |
177-
${{ runner.os }}-pip-${{ matrix.python-version }}-
178-
${{ runner.os }}-pip-
193+
cache: 'pip'
194+
cache-dependency-path: './repo/pyproject.toml'
179195

180196
- name: Install Dependencies (including PyInstaller)
181197
shell: bash
@@ -194,8 +210,9 @@ jobs:
194210
shell: bash
195211
working-directory: ./repo
196212
run: |
197-
# Ensure PyInstaller can find the modules
198-
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
213+
# Ensure PyInstaller can find the modules (use correct path separator for OS)
214+
SEP=$(python -c "import os; print(os.pathsep)")
215+
export PYTHONPATH="${PWD}/src${SEP}${PYTHONPATH:-}"
199216
echo "PYTHONPATH: $PYTHONPATH"
200217
201218
# Run PyInstaller with explicit paths
@@ -234,7 +251,7 @@ jobs:
234251
fi
235252
236253
- name: Upload artifact
237-
uses: actions/upload-artifact@v6
254+
uses: actions/upload-artifact@v4
238255
with:
239256
name: ${{ matrix.asset_name }}-binary
240257
path: ./repo/dist/treemapper-*
@@ -252,7 +269,7 @@ jobs:
252269
id-token: write
253270
steps:
254271
- name: Download git bundle
255-
uses: actions/download-artifact@v7
272+
uses: actions/download-artifact@v4
256273
with:
257274
name: git-repo-bundle
258275

@@ -273,7 +290,7 @@ jobs:
273290
ls -la src/treemapper/ || echo "ERROR: src/treemapper not found!"
274291
275292
- name: Set up Python
276-
uses: actions/setup-python@v6
293+
uses: actions/setup-python@v5
277294
with:
278295
python-version: '3.11'
279296

@@ -319,7 +336,7 @@ jobs:
319336
contents: write
320337
steps:
321338
- name: Download git bundle
322-
uses: actions/download-artifact@v7
339+
uses: actions/download-artifact@v4
323340
with:
324341
name: git-repo-bundle
325342

@@ -337,16 +354,28 @@ jobs:
337354
# Set up remote to point to the actual GitHub repository
338355
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
339356
340-
# Verify remote is set up correctly
341-
git remote -v
342-
343357
- name: Push commit and tag to main
344358
working-directory: ./repo
345359
run: |
346360
git config user.name "github-actions[bot]"
347361
# 41898282 is GitHub's bot user ID for github-actions[bot]
348362
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
349363
364+
# Fetch latest state of remote main
365+
git fetch origin main
366+
367+
# Check that remote main hasn't moved since we started the release
368+
# Our commit should be based on the current remote main HEAD
369+
REMOTE_MAIN=$(git rev-parse origin/main)
370+
OUR_PARENT=$(git rev-parse HEAD^)
371+
if [ "$REMOTE_MAIN" != "$OUR_PARENT" ]; then
372+
echo "Error: Remote main has changed since release started."
373+
echo "Expected parent: $OUR_PARENT"
374+
echo "Remote main: $REMOTE_MAIN"
375+
echo "Please re-run the release workflow."
376+
exit 1
377+
fi
378+
350379
# Push the version bump commit to main
351380
git push origin HEAD:main
352381
@@ -356,7 +385,7 @@ jobs:
356385
echo "Successfully pushed version commit and tag"
357386
358387
- name: Download all build artifacts
359-
uses: actions/download-artifact@v7
388+
uses: actions/download-artifact@v4
360389
with:
361390
path: ./artifacts
362391

.github/workflows/ci.yml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
permissions:
1919
contents: read
2020
steps:
21-
- uses: actions/checkout@v6
21+
- uses: actions/checkout@v4
2222

2323
- name: Set up Python
24-
uses: actions/setup-python@v6
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: '3.12'
2727

2828
- name: Cache pre-commit
29-
uses: actions/cache@v5
29+
uses: actions/cache@v4
3030
with:
3131
path: ~/.cache/pre-commit
3232
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
@@ -49,20 +49,14 @@ jobs:
4949
contents: read
5050
steps:
5151
- name: Checkout Code
52-
uses: actions/checkout@v6
52+
uses: actions/checkout@v4
5353

5454
- name: Set up Python 3.10
55-
uses: actions/setup-python@v6
55+
uses: actions/setup-python@v5
5656
with:
5757
python-version: '3.10'
58-
59-
- name: Cache pip Dependencies
60-
uses: actions/cache@v5
61-
with:
62-
path: ~/.cache/pip
63-
key: ${{ runner.os }}-lint-pip-3.10-${{ hashFiles('**/pyproject.toml') }}
64-
restore-keys: |
65-
${{ runner.os }}-lint-pip-3.10-
58+
cache: 'pip'
59+
cache-dependency-path: 'pyproject.toml'
6660

6761
- name: Install Linters and Type Checker
6862
run: |
@@ -95,21 +89,14 @@ jobs:
9589

9690
steps:
9791
- name: Checkout Code
98-
uses: actions/checkout@v6
92+
uses: actions/checkout@v4
9993

10094
- name: Set up Python ${{ matrix.python-version }}
101-
uses: actions/setup-python@v6
95+
uses: actions/setup-python@v5
10296
with:
10397
python-version: ${{ matrix.python-version }}
104-
105-
- name: Cache pip Dependencies
106-
uses: actions/cache@v5
107-
with:
108-
path: ~/.cache/pip
109-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
110-
restore-keys: |
111-
${{ runner.os }}-pip-${{ matrix.python-version }}-
112-
${{ runner.os }}-pip-
98+
cache: 'pip'
99+
cache-dependency-path: 'pyproject.toml'
113100

114101
- name: Install Dependencies
115102
run: |
@@ -137,7 +124,7 @@ jobs:
137124
verbose: true
138125

139126
- name: Upload coverage for SonarCloud
140-
uses: actions/upload-artifact@v6
127+
uses: actions/upload-artifact@v4
141128
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
142129
with:
143130
name: coverage-report
@@ -158,12 +145,12 @@ jobs:
158145
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
159146

160147
steps:
161-
- uses: actions/checkout@v6
148+
- uses: actions/checkout@v4
162149
with:
163150
fetch-depth: 0
164151

165152
- name: Set up Python
166-
uses: actions/setup-python@v6
153+
uses: actions/setup-python@v5
167154
with:
168155
python-version: '3.12'
169156

@@ -189,10 +176,10 @@ jobs:
189176
contents: read
190177

191178
steps:
192-
- uses: actions/checkout@v6
179+
- uses: actions/checkout@v4
193180

194181
- name: Set up Python
195-
uses: actions/setup-python@v6
182+
uses: actions/setup-python@v5
196183
with:
197184
python-version: '3.12'
198185

@@ -227,10 +214,10 @@ jobs:
227214
contents: read
228215

229216
steps:
230-
- uses: actions/checkout@v6
217+
- uses: actions/checkout@v4
231218

232219
- name: Set up Python
233-
uses: actions/setup-python@v6
220+
uses: actions/setup-python@v5
234221
with:
235222
python-version: '3.12'
236223

.treemapperignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
.coverage
55
htmlcov
66
.treemapperignore
7-
7+
*.yaml
8+
*.yml
89
tests
910
# Build and cache
1011
build

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module = [
5151
"tree_sitter_c",
5252
"tree_sitter_cpp",
5353
"tree_sitter_ruby",
54+
"tree_sitter_c_sharp",
5455
"mistune",
5556
"pysbd",
5657
"ruamel.yaml",
@@ -178,4 +179,4 @@ where = ["src"]
178179
testpaths = ["tests"]
179180
pythonpath = ["src"]
180181
norecursedirs = ["mutants", ".git", ".mypy_cache", ".pytest_cache", "__pycache__", ".hypothesis"]
181-
addopts = "-n 14 --dist loadfile"
182+
addopts = "-n auto --dist loadfile"

scripts/migrate_tests_to_yaml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def find_diff_test_cases(tree: ast.Module) -> list[dict]:
8686

8787
class Visitor(ast.NodeVisitor):
8888
def visit_Call(self, node: ast.Call):
89-
if isinstance(node.func, ast.Name) and node.func.id == "DiffTestCase":
89+
is_direct = isinstance(node.func, ast.Name) and node.func.id == "DiffTestCase"
90+
is_attr = isinstance(node.func, ast.Attribute) and node.func.attr == "DiffTestCase"
91+
if is_direct or is_attr:
9092
case = extract_diff_test_case(node)
9193
if case:
9294
cases.append(case)

0 commit comments

Comments
 (0)