Skip to content

Commit 6a1516a

Browse files
committed
feat: switch pip to uv
1 parent d119b50 commit 6a1516a

File tree

4 files changed

+501
-59
lines changed

4 files changed

+501
-59
lines changed

.github/workflows/update-readme.yml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,39 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515

16-
- name: Set up Python 3.10
17-
uses: actions/setup-python@v5
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v5
1818
with:
19-
python-version: '3.10'
19+
enable-cache: true
2020

21-
- name: Cache pip dependencies
22-
uses: actions/cache@v4
23-
with:
24-
path: ~/.cache/pip
25-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
26-
restore-keys: |
27-
${{ runner.os }}-pip-
21+
- name: Set up Python 3.10
22+
run: uv python install 3.10
2823

2924
- name: Install dependencies
30-
run: pip install -e .[dev]
25+
run: uv sync --all-extras --dev
3126

3227
- name: Run Ruff linter
33-
run: ruff check .
28+
run: uv run ruff check .
3429

3530
test:
3631
runs-on: ubuntu-latest
3732
steps:
3833
- name: Checkout
3934
uses: actions/checkout@v4
4035

41-
- name: Set up Python 3.10
42-
uses: actions/setup-python@v5
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v5
4338
with:
44-
python-version: '3.10'
39+
enable-cache: true
4540

46-
- name: Cache pip dependencies
47-
uses: actions/cache@v4
48-
with:
49-
path: ~/.cache/pip
50-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
51-
restore-keys: |
52-
${{ runner.os }}-pip-
41+
- name: Set up Python 3.10
42+
run: uv python install 3.10
5343

5444
- name: Install dependencies
55-
run: pip install -e .[dev]
45+
run: uv sync --all-extras --dev
5646

5747
- name: Run tests
58-
run: pytest
48+
run: uv run pytest
5949

6050
update-readme:
6151
needs: [lint, test]
@@ -67,24 +57,19 @@ jobs:
6757
token: ${{ secrets.GH_PAT }}
6858
persist-credentials: true
6959

70-
- name: Set up Python 3.10
71-
uses: actions/setup-python@v5
60+
- name: Install uv
61+
uses: astral-sh/setup-uv@v5
7262
with:
73-
python-version: '3.10'
63+
enable-cache: true
7464

75-
- name: Cache pip dependencies
76-
uses: actions/cache@v4
77-
with:
78-
path: ~/.cache/pip
79-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
80-
restore-keys: |
81-
${{ runner.os }}-pip-
65+
- name: Set up Python 3.10
66+
run: uv python install 3.10
8267

8368
- name: Install dependencies
84-
run: pip install -e .[dev]
69+
run: uv sync --all-extras
8570

8671
- name: Generate README
87-
run: python scripts/update_readme.py
72+
run: uv run scripts/update_readme.py
8873

8974
- name: Commit and push if changed
9075
run: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ problem:
44
echo 'Usage: make problem <problem_number>'; \
55
exit 1; \
66
fi
7-
@python scripts/create_problem.py $(filter-out problem,$(MAKECMDGOALS))
7+
@uv run scripts/create_problem.py $(filter-out problem,$(MAKECMDGOALS))

README.md

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,46 +85,33 @@ git clone https://github.com/codewithme-py/LeetCode_solutions.git
8585
cd LeetCode_solutions
8686
```
8787

88-
#### 2. Создай и активируй виртуальное окружение
88+
#### 2. Настрой окружение
8989
```bash
90-
python3 -m venv .venv
91-
```
92-
Linux/Mac
93-
```bash
94-
source .venv/bin/activate
95-
```
96-
или на Windows
97-
```bash
98-
source .venv\Scripts\activate
99-
```
100-
101-
#### 3. Установи зависимости
102-
```bash
103-
pip install -e .[dev]
90+
uv sync
10491
```
10592

106-
#### 4. Запусти тесты (проверь, что всё работает)
93+
#### 3. Запусти тесты (проверь, что всё работает)
10794
```bash
108-
pytest && ruff check .
95+
uv run pytest && uv run ruff check .
10996
```
11097

111-
#### 5. Используй скрипт обновления README (опционально)
98+
#### 4. Используй скрипт обновления README (опционально)
11299
```bash
113-
python3 scripts/update_readme.py
100+
uv run scripts/update_readme.py
114101
```
115102
Для принудительного обновления кэша задач используйте флаг `--force-refresh-cache`:
116103
```bash
117-
python3 scripts/update_readme.py --force-refresh-cache
104+
uv run scripts/update_readme.py --force-refresh-cache
118105
```
119106

120107
- Кэш задач обновляется автоматически раз в неделю (от даты изменения файла problems_cache.json). Для принудительного обновления кэша задач используйте флаг --force-refresh-cache:
121108

122-
#### 6. Создай токен GitHub и добавь его в Secrets репозитория
109+
#### 5. Создай токен GitHub и добавь его в Secrets репозитория
123110
1) https://github.com/settings/tokens → перейди по ссылке
124111
2) Generate new token (classic) → Note: `What’s this token for?` → Expiration: `your choice` → Scopes: `repo`+`workflow` → Generate token → Скопируй токен
125112
3) Repo LeetCode_solutions Settings → Secrets and variables → Actions → New repository secret с именем `GH_PAT` → Вставь токен → Add secret
126113

127-
#### 7. Используй скрипт → Решай новую задачу → делай push → PR → merge в main → CI/CD сделает всё остальное автоматически!
114+
#### 6. Используй скрипт → Решай новую задачу → делай push → PR → merge в main → CI/CD сделает всё остальное автоматически!
128115

129116
```bash
130117
make problem <номер_задачи_без_ведущих_нулей>

0 commit comments

Comments
 (0)