Skip to content

Commit 9080a82

Browse files
authored
feat: use tags.json5 when generate problems (#46)
- use tags.json5 when generate problems - move logged_test - add sort_tags.py
1 parent fbab795 commit 9080a82

File tree

176 files changed

+753
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+753
-392
lines changed

.amazonq/rules/problem-creation.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ When user requests a problem by **number** or **name/slug**, the assistant will:
1313
- Images provide crucial visual context, especially for tree and graph problems
1414
- Always verify images are included in `readme_examples` and accessible
1515
4. **Create** JSON file in `leetcode_py/cli/resources/leetcode/json/problems/{problem_name}.json`
16-
5. **Update** Makefile with `PROBLEM ?= {problem_name}`
17-
6. **Generate** problem structure using `make p-gen`
18-
7. **Verify** with `make p-lint` - fix template issues in JSON if possible, or manually fix generated files if template limitations
19-
8. **Iterate** if JSON fixes: re-run `make p-gen PROBLEM={problem_name} FORCE=1` and `make p-lint` until passes to ensure reproducibility
16+
5. **Update tags.json5** - If user specifies tags, manually add problem name to corresponding tag arrays in `leetcode_py/cli/resources/leetcode/json/tags.json5`
17+
6. **Update** Makefile with `PROBLEM ?= {problem_name}`
18+
7. **Generate** problem structure using `make p-gen`
19+
8. **Verify** with `make p-lint` - fix template issues in JSON if possible, or manually fix generated files if template limitations
20+
9. **Iterate** if JSON fixes: re-run `make p-gen PROBLEM={problem_name} FORCE=1` and `make p-lint` until passes to ensure reproducibility
2021

2122
## Scraping Commands
2223

.github/workflows/ci-test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ on:
66
pull_request:
77
types: [opened, synchronize, reopened]
88

9+
env:
10+
TARGET_PYTHON_VERSION: "3.13"
11+
912
jobs:
1013
test:
1114
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1219

1320
steps:
1421
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1522

1623
- name: Set up Python
1724
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
1825
with:
19-
python-version: "3.13"
26+
python-version: ${{ matrix.python-version }}
2027

2128
- name: Install Poetry
2229
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
@@ -30,7 +37,7 @@ jobs:
3037
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
3138
with:
3239
path: .venv
33-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
40+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
3441

3542
- name: Install dependencies
3643
run: |
@@ -67,11 +74,13 @@ jobs:
6774
run: make test
6875

6976
- name: SonarQube Scan
77+
if: matrix.python-version == env.TARGET_PYTHON_VERSION
7078
uses: SonarSource/sonarqube-scan-action@1a6d90ebcb0e6a6b1d87e37ba693fe453195ae25 # v5.3.1
7179
env:
7280
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7381

7482
- name: Upload coverage reports to Codecov
83+
if: matrix.python-version == env.TARGET_PYTHON_VERSION
7584
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
7685
with:
7786
fail_ci_if_error: true

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PYTHON_VERSION = 3.13
2-
PROBLEM ?= find_all_anagrams_in_a_string
2+
PROBLEM ?= daily_temperatures
33
FORCE ?= 0
44
COMMA := ,
55

@@ -42,6 +42,7 @@ define lint_target
4242
endef
4343

4444
lint:
45+
poetry run python scripts/sort_tags.py
4546
poetry sort
4647
npx prettier --write "**/*.{ts,tsx,css,json,yaml,yml,md}"
4748
$(call lint_target,.)

leetcode/accounts_merge/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_accounts_merge, run_accounts_merge
66
from .solution import Solution

leetcode/add_binary/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_add_binary, run_add_binary
66
from .solution import Solution

leetcode/balanced_binary_tree/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_is_balanced, run_is_balanced
66
from .solution import Solution

leetcode/basic_calculator/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_calculate, run_calculate
66
from .solution import Solution

leetcode/best_time_to_buy_and_sell_stock/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_max_profit, run_max_profit
66
from .solution import Solution

leetcode/binary_search/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_search, run_search
66
from .solution import Solution

leetcode/binary_tree_level_order_traversal/test_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from leetcode_py.test_utils import logged_test
3+
from leetcode_py import logged_test
44

55
from .helpers import assert_level_order, run_level_order
66
from .solution import Solution

0 commit comments

Comments
 (0)