Skip to content

Commit ff8ec6d

Browse files
authored
[tooling] Migrate to uv (#279)
# Exercise Review ## Exercise Discussion Fixes #278 ## Checklist - [ ] If you require a new remote repository on the `Git-Mastery` organization, have you [created a request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.yaml) for it? - [ ] Have you written unit tests using [`repo-smith`](https://github.com/git-mastery/repo-smith) to validate the exercise grading scheme? - [ ] Have you tested your changes using the instructions posted? - [ ] Have you verified that this exercise does not already exist or is not currently in review? - [ ] Did you introduce a new grading mechanism that should belong to [`git-autograder`](https://github.com/git-mastery/git-autograder)? - [ ] Did you introduce a new dependency that should belong to [`app`](https://github.com/git-mastery/app)?
1 parent 3d58822 commit ff8ec6d

11 files changed

Lines changed: 725 additions & 75 deletions

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,54 @@ jobs:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
1717

18-
- name: Setup Python
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: "3.13"
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v7
2220

2321
- name: Run validation script
2422
run: |
25-
python scripts/validate-exercise-config.py
23+
uv run python scripts/validate-exercise-config.py
2624
2725
unit_tests:
2826
runs-on: ubuntu-latest
2927
steps:
3028
- name: Checkout repository
3129
uses: actions/checkout@v4
32-
- name: Setup Python
33-
uses: actions/setup-python@v5
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v7
3432
with:
35-
python-version: "3.13"
33+
enable-cache: true
3634
- name: Install dependencies
3735
run: |
38-
pip install -r requirements.txt
36+
uv sync --locked --group test
3937
- name: Set up Git
4038
run: |
4139
git config --global user.name "github-actions"
4240
git config --global user.email "github-actions@github.com"
4341
git config --global init.defaultBranch main
4442
- name: Run unit tests
4543
run: |
46-
python -m pytest -s -vv
44+
uv run pytest -s -vv
4745
4846
mypy:
4947
runs-on: ubuntu-latest
5048
steps:
5149
- name: Checkout repository
5250
uses: actions/checkout@v4
53-
- name: Setup Python
54-
uses: actions/setup-python@v5
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v7
5553
with:
56-
python-version: "3.13"
54+
enable-cache: true
5755
- name: Install dependencies
5856
run: |
59-
pip install -r requirements.txt
57+
uv sync --locked --group dev --group test
6058
- name: Set up Git
6159
run: |
6260
git config --global user.name "github-actions"
6361
git config --global user.email "github-actions@github.com"
6462
git config --global init.defaultBranch main
6563
- name: Run mypy
6664
run: |
67-
python -m mypy .
65+
uv run mypy .
6866
6967
format:
7068
runs-on: ubuntu-latest
@@ -75,17 +73,17 @@ jobs:
7573
with:
7674
ref: main
7775
fetch-depth: 0
78-
- name: Setup Python
79-
uses: actions/setup-python@v5
76+
- name: Install uv
77+
uses: astral-sh/setup-uv@v7
8078
with:
81-
python-version: "3.13"
79+
enable-cache: true
8280
- name: Install dependencies
8381
run: |
84-
pip install -r requirements.txt
82+
uv sync --locked --group dev
8583
- name: Run formatter using ruff
8684
run: |
87-
ruff check --fix
88-
ruff format
85+
uv run ruff check --fix
86+
uv run ruff format
8987
- name: Saving changes
9088
run: |
9189
git config --global user.name "github-actions"

.github/workflows/publish.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ jobs:
1010

1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

15-
- name: Set up Python
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: "3.11"
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v7
1917

2018
- name: Generate exercise-directory.md
2119
run: |
22-
python scripts/create-exercise-directory.py
20+
uv run python scripts/create-exercise-directory.py
2321
mv exercise-directory.md index.md
2422
2523
- name: Deploy to gh-pages

lefthook.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ pre-commit:
33
commands:
44
ruff-lint:
55
glob: "*.py"
6-
run: ruff check --fix {staged_files}
6+
run: uv run ruff check --fix {staged_files}
77
stage_fixed: true
88

99
ruff-format:
1010
glob: "*.py"
11-
run: ruff format {staged_files}
11+
run: uv run ruff format {staged_files}
1212
stage_fixed: true
1313

1414
mypy:
1515
glob: "*.py"
16-
run: mypy .
16+
run: uv run mypy .

new.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ read choice
55

66
case "$choice" in
77
"hands-on" | "h" | "H")
8-
python scripts/new-hands-on.py
8+
uv run python scripts/new-hands-on.py
99
;;
1010
"exercise" | "e" | "E")
11-
python scripts/new-exercise.py
11+
uv run python scripts/new-exercise.py
1212
;;
1313
*)
1414
echo "Invalid choice. Please enter 'hands-on' (h) or 'exercise' (e)."

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[project]
2+
name = "cs3281-exercises"
3+
version = "0.1.0"
4+
requires-python = ">=3.13"
5+
dependencies = [
6+
"git-autograder",
7+
"PyYAML",
8+
"PyGithub",
9+
"requests",
10+
"repo-smith"
11+
]
12+
13+
[dependency-groups]
14+
test = ["pytest"]
15+
dev = [
16+
"lefthook",
17+
"ruff",
18+
"mypy",
19+
"types-requests",
20+
]

requirements.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

setup.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
#!/bin/bash
22

3-
if [ ! -d venv/ ]; then
4-
python -m venv venv
5-
fi
6-
7-
source venv/bin/activate
8-
9-
pip install -r requirements.txt -U --no-cache-dir
10-
11-
if command -v lefthook >/dev/null 2>&1; then
12-
lefthook install
13-
else
14-
echo "LeftHook not installed, failed to set up LeftHook for Git Hooks."
15-
fi
3+
uv sync --all-groups
4+
uv run lefthook install

test-download.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
22

3-
# PYTHONPATH tells python to look for modules in the current directory
4-
PYTHONPATH="." python scripts/test-download.py $1
3+
PYTHONPATH=. uv run python scripts/test-download.py "$1"

test.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
#!/bin/bash
22
set -e
33

4-
if [ -f "venv/bin/activate" ]; then
5-
# Linux / macOS
6-
source venv/bin/activate
7-
elif [ -f "venv/Scripts/activate" ]; then
8-
# Windows (Git Bash, Cygwin, or WSL)
9-
source venv/Scripts/activate
10-
else
11-
echo "Error: Could not find Python virtual environment activation script."
12-
echo "Please create one with: python -m venv venv"
13-
exit 1
14-
fi
15-
16-
python -m pytest $1/test_verify.py -s -vv
4+
uv run pytest "$1/test_verify.py" -s -vv

0 commit comments

Comments
 (0)