@@ -51,91 +51,21 @@ jobs:
5151
5252 - name : Checkout repository
5353 uses : actions/checkout@v6
54- with :
55- fetch-depth : 0
5654
5755 - name : Set up Python
5856 uses : actions/setup-python@v6
5957 with :
6058 python-version : ${{ matrix.python-version }}
6159
62- - name : Install Dependencies
63- run : |
64- python -m pip install --upgrade pip
65- pip install -r requirements-dev.txt
66- playwright install
60+ - name : Set up uv
61+ uses : astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
62+ with :
63+ version : " 0.12.3"
6764
68- - name : Ruff
69- env :
70- BASE_SHA : ${{ github.event.pull_request.base.sha }}
71- HEAD_SHA : ${{ github.event.pull_request.head.sha }}
72- IS_PR : ${{ github.event_name == 'pull_request' }}
65+ - name : Install dependencies
7366 run : |
74- if [ "$IS_PR" != "true" ]; then
75- echo "Not a pull request - running full check."
76- ruff check src
77- exit $?
78- fi
79- python - <<'PY'
80- import json, os, re, subprocess, sys
81-
82- base, head = os.environ["BASE_SHA"], os.environ["HEAD_SHA"]
83-
84- # Lines added/modified by this PR, per file.
85- diff = subprocess.run(
86- ["git", "diff", "--unified=0", f"{base}...{head}", "--", "src"],
87- capture_output=True, text=True, check=True,
88- ).stdout
89-
90- changed: dict[str, set[int]] = {}
91- path = None
92- hunk = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@")
93- for line in diff.splitlines():
94- if line.startswith("+++ b/"):
95- path = line[6:]
96- elif line.startswith("@@") and path:
97- m = hunk.match(line)
98- if m:
99- start = int(m.group(1))
100- count = int(m.group(2) or 1)
101- changed.setdefault(path, set()).update(
102- range(start, start + count)
103- )
104-
105- changed = {p: lines for p, lines in changed.items() if p.endswith(".py")}
106-
107- if not changed:
108- print("No changed Python lines under src/ - nothing to lint.")
109- sys.exit(0)
110-
111- proc = subprocess.run(
112- ["ruff", "check", "src", "--output-format=json", "--no-cache"],
113- capture_output=True, text=True,
114- )
115- if proc.returncode not in (0, 1):
116- sys.stderr.write(proc.stderr)
117- sys.exit(proc.returncode)
118- diagnostics = json.loads(proc.stdout or "[]")
119-
120- repo = os.getcwd()
121- offending = []
122- for d in diagnostics:
123- rel = os.path.relpath(d["filename"], repo)
124- row = (d.get("location") or {}).get("row")
125- if row is not None and row in changed.get(rel, ()):
126- offending.append((rel, row, d["code"], d["message"]))
127-
128- total = len(diagnostics)
129- print(f"{total} violations exist in src/; gating on changed lines only.")
130-
131- if offending:
132- print(f"\n{len(offending)} violation(s) on lines this PR changed:\n")
133- for rel, row, code, msg in sorted(offending):
134- print(f" {rel}:{row}: {code} {msg}")
135- sys.exit(1)
136-
137- print("No violations on changed lines.")
138- PY
67+ uv sync --locked --no-default-groups --group test
68+ uv run --no-sync playwright install
13969
14070 - name : Set environment variables from secrets
14171 run : |
14575 # the only variable settings.py treats as mandatory, so fall back to an
14676 # ephemeral one: nothing signed during a test run outlives the job.
14777 if [ -z "${{ secrets.SECRET }}" ]; then
148- echo "SECRET=$(python -c 'import secrets; print(secrets.token_urlsafe(50))')" >> $GITHUB_ENV
78+ echo "SECRET=$(uv run --no-sync python -c 'import secrets; print(secrets.token_urlsafe(50))')" >> $GITHUB_ENV
14979 fi
15080 if [ -n "${{ secrets.TMDB_API }}" ]; then echo "TMDB_API=${{ secrets.TMDB_API }}" >> $GITHUB_ENV; fi
15181 if [ -n "${{ secrets.MAL_API }}" ]; then echo "MAL_API=${{ secrets.MAL_API }}" >> $GITHUB_ENV; fi
@@ -160,14 +90,15 @@ jobs:
16090 # flaky, and a pull request from a fork cannot read repository secrets,
16191 # so they fail there regardless of the change. Run them deliberately
16292 # with scripts/test.sh --network.
163- coverage run src/manage.py test app users integrations lists events \
93+ uv run --no-sync coverage run src/manage.py test \
94+ app users integrations lists events \
16495 --parallel --exclude-tag network
16596
16697 - name : Build Coverage Report
16798 run : |
168- coverage combine
169- coverage report
170- coverage xml
99+ uv run --no-sync coverage combine
100+ uv run --no-sync coverage report
101+ uv run --no-sync coverage xml
171102
172103 - name : Upload coverage to Codecov
173104 uses : codecov/codecov-action@v6
0 commit comments