Skip to content

Commit aa3a323

Browse files
committed
bugfixes+cleanup+idk
1 parent b4ff89a commit aa3a323

File tree

102 files changed

+6705
-3122
lines changed

Some content is hidden

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

102 files changed

+6705
-3122
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Setup FFmpeg + PG client and wait"
2+
description: "Install FFmpeg and Postgres client (Linux) and wait for pg_isready"
3+
inputs:
4+
host:
5+
description: "Postgres host"
6+
required: false
7+
default: "127.0.0.1"
8+
port:
9+
description: "Postgres port"
10+
required: true
11+
user:
12+
description: "Postgres user"
13+
required: true
14+
install-portaudio:
15+
description: "Install portaudio (Linux)"
16+
required: false
17+
default: 'false'
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Install FFmpeg + PG client (Linux)
22+
if: runner.os == 'Linux'
23+
shell: bash
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y ffmpeg postgresql-client ${PORTAUDIO:-}
27+
env:
28+
PORTAUDIO: ${{ inputs.install-portaudio == 'true' && 'portaudio19-dev' || '' }}
29+
30+
- name: Wait for Postgres
31+
shell: bash
32+
run: |
33+
host='${{ inputs.host }}'
34+
port='${{ inputs.port }}'
35+
user='${{ inputs.user }}'
36+
echo "Waiting for Postgres at ${host}:${port} as ${user}"
37+
for i in {1..60}; do
38+
if pg_isready -h "$host" -p "$port" -U "$user"; then
39+
echo "Postgres is ready"; exit 0; fi;
40+
echo "Attempt $i: waiting for Postgres..."; sleep 2;
41+
done
42+
echo "Postgres did not become ready in time" >&2; exit 1
43+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Setup FFmpeg"
2+
description: "Install FFmpeg across platforms"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install FFmpeg (Linux)
7+
if: runner.os == 'Linux'
8+
shell: bash
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install -y ffmpeg
12+
- name: Install FFmpeg (macOS)
13+
if: runner.os == 'macOS'
14+
shell: bash
15+
run: |
16+
brew install ffmpeg || true
17+
- name: Install FFmpeg (Windows)
18+
if: runner.os == 'Windows'
19+
shell: bash
20+
run: |
21+
choco install ffmpeg -y || choco upgrade ffmpeg -y || true
22+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Setup Python and install deps"
2+
description: "Setup Python with pip cache and install project deps (optionally via uv)."
3+
inputs:
4+
python-version:
5+
description: "Python version to use"
6+
required: true
7+
cache-dependency-path:
8+
description: "Files to key pip cache (newline-separated)"
9+
required: false
10+
default: |
11+
pyproject.toml
12+
uv.lock
13+
use-uv:
14+
description: "Use uv for installs (faster)"
15+
required: false
16+
default: 'true'
17+
requirements-files:
18+
description: "Optional newline-separated requirements files to install"
19+
required: false
20+
default: ''
21+
extras:
22+
description: "Optional extras to install, e.g., 'dev'"
23+
required: false
24+
default: 'dev'
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Setup Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ inputs.python-version }}
32+
cache: pip
33+
cache-dependency-path: ${{ inputs.cache-dependency-path }}
34+
35+
- name: Setup uv
36+
if: inputs.use-uv == 'true'
37+
uses: astral-sh/setup-uv@v3
38+
39+
- name: Upgrade pip
40+
if: inputs.use-uv != 'true'
41+
shell: bash
42+
run: |
43+
python -m pip install --upgrade pip
44+
45+
- name: Install project (uv)
46+
if: inputs.use-uv == 'true' && inputs.requirements-files == ''
47+
shell: bash
48+
run: |
49+
# Install editable with extras
50+
uv pip install -e ".[${{ inputs.extras }}]"
51+
52+
- name: Install from requirements (uv)
53+
if: inputs.use-uv == 'true' && inputs.requirements-files != ''
54+
shell: bash
55+
run: |
56+
while IFS= read -r req; do
57+
[ -n "$req" ] || continue
58+
uv pip install -r "$req"
59+
done << 'REQS'
60+
${{ inputs.requirements-files }}
61+
REQS
62+
63+
- name: Install project (pip)
64+
if: inputs.use-uv != 'true' && inputs.requirements-files == ''
65+
shell: bash
66+
run: |
67+
pip install -e ".[${{ inputs.extras }}]"
68+
69+
- name: Install from requirements (pip)
70+
if: inputs.use-uv != 'true' && inputs.requirements-files != ''
71+
shell: bash
72+
run: |
73+
while IFS= read -r req; do
74+
[ -n "$req" ] || continue
75+
pip install -r "$req"
76+
done << 'REQS'
77+
${{ inputs.requirements-files }}
78+
REQS
79+
80+
- name: Enforce pytest plugin isolation
81+
shell: bash
82+
run: |
83+
echo "PYTEST_DISABLE_PLUGIN_AUTOLOAD=1" >> "$GITHUB_ENV"
84+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Wait for Postgres"
2+
description: "Ensure Postgres is reachable; optionally install client"
3+
inputs:
4+
host:
5+
description: "Postgres host"
6+
required: false
7+
default: "127.0.0.1"
8+
port:
9+
description: "Postgres port"
10+
required: true
11+
user:
12+
description: "Postgres user"
13+
required: true
14+
install-client:
15+
description: "Install postgresql-client on Linux"
16+
required: false
17+
default: 'true'
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Install client (Linux)
22+
if: runner.os == 'Linux' && inputs.install-client == 'true'
23+
shell: bash
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y postgresql-client
27+
28+
- name: Wait for Postgres
29+
shell: bash
30+
run: |
31+
host='${{ inputs.host }}'
32+
port='${{ inputs.port }}'
33+
user='${{ inputs.user }}'
34+
echo "Waiting for Postgres at ${host}:${port} as ${user}"
35+
for i in {1..60}; do
36+
if pg_isready -h "$host" -p "$port" -U "$user"; then
37+
echo "Postgres is ready"; exit 0; fi;
38+
echo "Attempt $i: waiting for Postgres..."; sleep 2;
39+
done
40+
echo "Postgres did not become ready in time" >&2; exit 1
41+

.github/workflows/actionlint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint Workflows (actionlint)
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/**'
7+
- '.github/actions/**'
8+
push:
9+
branches: [ main, master ]
10+
paths:
11+
- '.github/workflows/**'
12+
- '.github/actions/**'
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
actionlint:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
24+
- name: Run actionlint
25+
uses: rhysd/actionlint@v1
26+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Audio/STT/TTS Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'tldw_Server_API/app/api/v1/endpoints/audio.py'
7+
- 'tldw_Server_API/app/core/TTS/**'
8+
- 'tldw_Server_API/tests/Audio/**'
9+
- 'tldw_Server_API/tests/STT/**'
10+
- 'tldw_Server_API/tests/TTS/**'
11+
- 'tldw_Server_API/tests/TTS_NEW/**'
12+
- '.github/workflows/audio-tts-tests.yml'
13+
push:
14+
branches: [ main, master ]
15+
paths:
16+
- 'tldw_Server_API/app/api/v1/endpoints/audio.py'
17+
- 'tldw_Server_API/app/core/TTS/**'
18+
- 'tldw_Server_API/tests/Audio/**'
19+
- 'tldw_Server_API/tests/STT/**'
20+
- 'tldw_Server_API/tests/TTS/**'
21+
- 'tldw_Server_API/tests/TTS_NEW/**'
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
audio-tts-unit:
28+
name: Audio/TTS Unit - ${{ matrix.os }} - Python ${{ matrix.python-version }}
29+
runs-on: ${{ matrix.os }}
30+
timeout-minutes: 45
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- os: ubuntu-latest
36+
python-version: "3.11"
37+
- os: ubuntu-latest
38+
python-version: "3.12"
39+
- os: ubuntu-latest
40+
python-version: "3.13"
41+
env:
42+
PYTHONUNBUFFERED: '1'
43+
TEST_MODE: 'true'
44+
DISABLE_HEAVY_STARTUP: '1'
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Setup Python and deps (with uv)
48+
uses: ./.github/actions/setup-python-deps
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
use-uv: 'true'
52+
cache-dependency-path: |
53+
pyproject.toml
54+
uv.lock
55+
- name: Install system dependencies (FFmpeg)
56+
if: runner.os == 'Linux'
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get install -y ffmpeg
60+
- name: Install system dependencies (macOS)
61+
if: runner.os == 'macOS'
62+
run: |
63+
brew install ffmpeg || true
64+
- name: Install system dependencies (Windows)
65+
if: runner.os == 'Windows'
66+
run: |
67+
choco install ffmpeg -y
68+
- name: Install Python deps (dev)
69+
run: |
70+
python -m pip install --upgrade pip
71+
pip install -e '.[dev]'
72+
- name: Run Audio/TTS unit tests
73+
run: |
74+
pytest -q -m "unit" \
75+
--junit-xml=audio-tts-unit-${{ matrix.os }}-${{ matrix.python-version }}.xml \
76+
tldw_Server_API/tests/Audio \
77+
tldw_Server_API/tests/STT \
78+
tldw_Server_API/tests/TTS \
79+
tldw_Server_API/tests/TTS_NEW/unit
80+
- name: Upload test results
81+
if: always()
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: audio-tts-tests-${{ matrix.os }}-${{ matrix.python-version }}
85+
path: audio-tts-unit-*.xml
86+
- name: Publish Audio/TTS unit results
87+
if: always()
88+
permissions:
89+
checks: write
90+
pull-requests: write
91+
uses: EnricoMi/publish-unit-test-result-action@v2
92+
with:
93+
files: audio-tts-unit-*.xml

.github/workflows/authnz-tests.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ on:
1717
jobs:
1818
authnz:
1919
runs-on: ubuntu-latest
20+
timeout-minutes: 30
2021
strategy:
2122
fail-fast: false
2223
matrix:
23-
python-version: [ '3.11', '3.12' ]
24+
python-version: [ '3.11', '3.12', '3.13' ]
2425

2526
services:
2627
postgres:
2728
image: postgres:18-bookworm
2829
ports:
29-
- 5432:5432
30+
- 5432/tcp
3031
env:
3132
POSTGRES_USER: tldw_user
3233
POSTGRES_PASSWORD: TestPassword123!
@@ -42,22 +43,24 @@ jobs:
4243
TLDW_TEST_POSTGRES_REQUIRED: '1'
4344
# Point tests to the service container
4445
TEST_DB_HOST: 127.0.0.1
45-
TEST_DB_PORT: '5432'
46+
TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }}
4647
TEST_DB_USER: tldw_user
4748
TEST_DB_PASSWORD: TestPassword123!
4849
# Keep slow suite disabled by default (pytest.ini)
4950
PYTHONWARNINGS: default
51+
PYTEST_DISABLE_PLUGIN_AUTOLOAD: '1'
5052

5153
steps:
5254
- name: Checkout
53-
uses: actions/checkout@v4
55+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
5456

5557
- name: Set up Python ${{ matrix.python-version }}
5658
uses: actions/setup-python@v5
5759
with:
5860
python-version: ${{ matrix.python-version }}
5961
cache: 'pip'
6062

63+
6164
- name: Install minimal dependencies for AuthNZ tests
6265
run: |
6366
python -m pip install --upgrade pip
@@ -84,13 +87,12 @@ jobs:
8487
exit 1
8588
fi
8689
87-
- name: Wait for Postgres
88-
run: |
89-
for i in {1..30}; do
90-
if pg_isready -h 127.0.0.1 -p 5432 -U tldw_user; then
91-
echo "Postgres is ready"; break; fi;
92-
echo "Waiting for Postgres..."; sleep 2;
93-
done
90+
- name: Install ffmpeg + pg client + wait for PG
91+
uses: ./.github/actions/ffmpeg-pg-wait
92+
with:
93+
host: 127.0.0.1
94+
port: ${{ env.TEST_DB_PORT }}
95+
user: tldw_user
9496

9597
- name: Run AuthNZ SQLite tests
9698
run: |
@@ -99,3 +101,5 @@ jobs:
99101
- name: Run AuthNZ Postgres tests (includes real-audit tests)
100102
run: |
101103
python -m pytest -q tldw_Server_API/tests/AuthNZ_Postgres -m "integration or real_audit"
104+
permissions:
105+
contents: read

0 commit comments

Comments
 (0)