Skip to content

Commit 130e6cc

Browse files
authored
feat: add mise.toml (#140)
1 parent ed604ff commit 130e6cc

9 files changed

Lines changed: 260 additions & 268 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: pre-commit
22

33
on:
44
workflow_call:
5-
inputs:
6-
python_version:
7-
description: "Python version to use"
8-
required: false
9-
type: string
10-
default: "3.14"
115

126
jobs:
137
pre-commit:
@@ -20,47 +14,33 @@ jobs:
2014
submodules: recursive
2115
token: ${{ secrets.GITHUB_TOKEN }}
2216

23-
- name: setup-uv
24-
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
25-
with:
26-
version: "latest"
27-
enable-cache: true
28-
python-version: ${{ inputs.python_version }}
17+
- name: setup-mise
18+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
2919

3020
- name: cache-deps
3121
env:
32-
CACHE_KEY_PREFIX: deps-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-py${{ inputs.python_version }}
33-
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock') }}
22+
CACHE_KEY_PREFIX: deps-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
23+
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock', '.pre-commit-config.yaml') }}
3424
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
3525
with:
3626
path: |
3727
~/.cache/pre-commit
3828
~/.cache/ruff
3929
~/.bun/install/cache
40-
~/.local
30+
~/.local/share/uv
31+
~/.cache/uv
4132
${{ github.workspace }}/.venv
4233
key: ${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-${{ github.run_attempt }}
4334
restore-keys: |
4435
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-
4536
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-
4637
${{ env.CACHE_KEY_PREFIX }}-
4738
48-
- name: install-bake
49-
run: |
50-
uv tool install "bakefile[lib]"
51-
uv tool upgrade --all
52-
bake --version
53-
5439
- name: install-dependencies
5540
run: uv sync --all-extras --all-groups --frozen
5641

5742
- name: setup-path
5843
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
5944

60-
- name: setup-bun
61-
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
62-
with:
63-
bun-version: latest
64-
6545
- name: run-pre-commit
6646
run: uv run pre-commit run --all-files

.github/workflows/publish.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
registry:
1111
required: false
1212
type: string
13-
description: "Publish index (pypi or test-pypi)"
13+
description: "Publish registry (pypi or test-pypi)"
1414
default: "test-pypi"
1515
python_version:
1616
required: false
@@ -28,18 +28,17 @@ jobs:
2828
- name: checkout
2929
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3030

31-
- name: setup-uv
32-
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
33-
with:
34-
python-version: ${{ inputs.python_version }}
35-
version: "latest"
36-
enable-cache: true
31+
- name: set-python-version
32+
run: echo "${{ inputs.python_version }}" > .python-version
3733

38-
- name: install-bake
39-
run: |
40-
uv tool install "bakefile[lib]"
41-
uv tool upgrade --all
42-
bake --version
34+
- name: setup-mise
35+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
36+
37+
- name: install-dependencies
38+
run: uv sync --all-extras --all-groups --frozen
39+
40+
- name: setup-path
41+
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
4342

4443
- name: publish
4544
run: |

.github/workflows/test-reproducibility.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: test-reproducibility
22

33
on:
44
workflow_call:
5-
inputs:
6-
python_version:
7-
description: "Python version to use"
8-
required: false
9-
type: string
10-
default: "3.14"
115

126
jobs:
137
test-reproducibility:
@@ -17,33 +11,30 @@ jobs:
1711
- name: checkout
1812
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1913

20-
- name: setup-uv
21-
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
22-
with:
23-
version: "latest"
24-
enable-cache: true
25-
python-version: ${{ matrix.python-version }}
14+
- name: setup-mise
15+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
2616

2717
- name: cache-venv
2818
env:
29-
CACHE_KEY_PREFIX: venv-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-py${{ inputs.python_version }}
19+
CACHE_KEY_PREFIX: venv-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
3020
CACHE_KEY_DEPS: ${{ hashFiles('uv.lock') }}
3121
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
3222
with:
3323
path: |
34-
~/.local
24+
~/.local/share/uv
25+
~/.cache/uv
3526
${{ github.workspace }}/.venv
3627
key: ${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-${{ github.run_attempt }}
3728
restore-keys: |
3829
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-
3930
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-
4031
${{ env.CACHE_KEY_PREFIX }}-
4132
42-
- name: install-bake
43-
run: |
44-
uv tool install "bakefile[lib]"
45-
uv tool upgrade --all
46-
bake --version
33+
- name: install-dependencies
34+
run: uv sync --all-extras --all-groups --frozen
35+
36+
- name: setup-path
37+
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
4738

4839
- name: cache-graphviz
4940
id: cache-graphviz
@@ -76,11 +67,6 @@ jobs:
7667
cp -r /usr/share/graphviz ~/graphviz-cache/share/ 2>/dev/null || true
7768
fi
7869
79-
- name: setup-bun
80-
uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
81-
with:
82-
bun-version: latest
83-
8470
- name: check-test-case-count
8571
run: bake check-test-cases
8672

.github/workflows/test.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ jobs:
2929
with:
3030
fetch-depth: 0
3131

32-
- name: update-python-version
32+
- name: set-python-version
3333
run: echo "${{ matrix.python-version }}" > .python-version
3434

35-
- name: setup-uv
36-
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
37-
with:
38-
version: "latest"
39-
enable-cache: true
40-
python-version: ${{ matrix.python-version }}
35+
- name: setup-mise
36+
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
4137

4238
- name: cache-venv
4339
env:
@@ -46,19 +42,20 @@ jobs:
4642
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
4743
with:
4844
path: |
49-
~/.local
45+
~/.local/share/uv
46+
~/.cache/uv
5047
${{ github.workspace }}/.venv
5148
key: ${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-${{ github.run_attempt }}
5249
restore-keys: |
5350
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-${{ github.run_id }}-
5451
${{ env.CACHE_KEY_PREFIX }}-${{ env.CACHE_KEY_DEPS }}-
5552
${{ env.CACHE_KEY_PREFIX }}-
5653
57-
- name: install-bake
58-
run: |
59-
uv tool install "bakefile[lib]"
60-
uv tool upgrade --all
61-
bake --version
54+
- name: install-dependencies
55+
run: uv sync --all-extras --all-groups --frozen
56+
57+
- name: setup-path
58+
run: echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
6259

6360
- name: cache-graphviz
6461
id: cache-graphviz
@@ -91,9 +88,6 @@ jobs:
9188
cp -r /usr/share/graphviz ~/graphviz-cache/share/ 2>/dev/null || true
9289
fi
9390
94-
- name: install-dependencies
95-
run: uv sync --all-extras --all-groups --frozen
96-
9791
- name: run-tests
9892
run: bake test
9993

.mise.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[settings]
2+
pipx.uvx = true
3+
4+
[tools]
5+
bun = "latest"
6+
"pipx:bakefile" = "latest"
7+
"pipx:toml-sort" = "latest"
8+
"pipx:zerv-version" = "latest"
9+
pre-commit = "latest"
10+
uv = "latest"

leetcode/linked_list_cycle_ii/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def run_detect_cycle(solution_class: type, head_vals: list[int], pos: int):
1414
# Find the node at position pos
1515
cycle_node = head
1616
for _ in range(pos):
17+
assert cycle_node is not None
1718
cycle_node = cycle_node.next
1819
# Create cycle
1920
tail.next = cycle_node

leetcode/reorder_list/solution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def reorder_list(self, head: ListNode[int] | None) -> None:
4242
# Step 3: Merge the two halves alternately
4343
first_half = head
4444
while second_half:
45+
assert first_half is not None
4546
# Store next nodes
4647
first_next = first_half.next
4748
second_next = second_half.next

src/leetcode_py/cli/resources/leetcode/json/problems/linked_list_cycle_ii.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"helpers_content": "",
2929
"helpers_run_name": "detect_cycle",
3030
"helpers_run_signature": "(solution_class: type, head_vals: list[int], pos: int)",
31-
"helpers_run_body": " head = ListNode.from_list(head_vals)\n # Keep reference to tail to break cycle later\n tail = None\n if head is not None:\n tail = head\n while tail.next is not None:\n tail = tail.next\n # Create cycle if pos is valid\n if pos >= 0 and head is not None and tail is not None:\n # Find the node at position pos\n cycle_node = head\n for _ in range(pos):\n cycle_node = cycle_node.next\n # Create cycle\n tail.next = cycle_node\n implementation = solution_class()\n result = implementation.detect_cycle(head)\n # Break the cycle to avoid infinite loop when finding index\n if tail is not None:\n tail.next = None\n # Return the index of the cycle node, or -1 if no cycle\n if result is None:\n return -1\n # Find index of result node\n index = 0\n current = head\n while current is not None and current != result:\n current = current.next\n index += 1\n return index if current is not None else -1",
31+
"helpers_run_body": " head = ListNode.from_list(head_vals)\n # Keep reference to tail to break cycle later\n tail = None\n if head is not None:\n tail = head\n while tail.next is not None:\n tail = tail.next\n # Create cycle if pos is valid\n if pos >= 0 and head is not None and tail is not None:\n # Find the node at position pos\n cycle_node = head\n for _ in range(pos):\n assert cycle_node is not None\n cycle_node = cycle_node.next\n # Create cycle\n tail.next = cycle_node\n implementation = solution_class()\n result = implementation.detect_cycle(head)\n # Break the cycle to avoid infinite loop when finding index\n if tail is not None:\n tail.next = None\n # Return the index of the cycle node, or -1 if no cycle\n if result is None:\n return -1\n # Find index of result node\n index = 0\n current = head\n while current is not None and current != result:\n current = current.next\n index += 1\n return index if current is not None else -1",
3232
"helpers_assert_name": "detect_cycle",
3333
"helpers_assert_signature": "(result: int, pos: int) -> bool",
3434
"helpers_assert_body": " assert result == pos\n return True",

0 commit comments

Comments
 (0)