Skip to content

Commit c54b04e

Browse files
committed
Test tests
1 parent 0703f94 commit c54b04e

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

.github/workflows/tests.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Test
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types:
7+
- completed
8+
workflow_dispatch:
9+
inputs:
10+
build_run_id:
11+
description: 'Build workflow run ID to test (leave empty for latest successful)'
12+
required: false
13+
push:
14+
branches:
15+
- edge
16+
17+
jobs:
18+
test-wheels:
19+
runs-on: ${{ matrix.os }}
20+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# os: [ubuntu-latest, windows-latest, macos-13, macos-15]
25+
# python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
26+
os: [ubuntu-latest]
27+
python-version: ["3.12", "3.13"]
28+
# exclude:
29+
# - os: macos-15
30+
# python-version: "3.8"
31+
32+
steps:
33+
- name: Set artifact name
34+
id: artifact
35+
run: |
36+
case "${{ matrix.os }}" in
37+
ubuntu-*) echo "name=wheels-linux" >> $GITHUB_OUTPUT ;;
38+
windows-*) echo "name=wheels-windows" >> $GITHUB_OUTPUT ;;
39+
macos-13) echo "name=wheels-macos-intel" >> $GITHUB_OUTPUT ;;
40+
macos-15) echo "name=wheels-macos-arm" >> $GITHUB_OUTPUT ;;
41+
esac
42+
43+
- name: Get build run ID
44+
id: get-run-id
45+
run: |
46+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.build_run_id }}" != "" ]]; then
47+
echo "run_id=${{ inputs.build_run_id }}" >> $GITHUB_OUTPUT
48+
elif [[ "${{ github.event_name }}" == "workflow_run" ]]; then
49+
echo "run_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
50+
else
51+
# Get latest successful build run
52+
RUN_ID=$(gh api repos/${{ github.repository }}/actions/workflows/build.yml/runs \
53+
--jq '.workflow_runs[] | select(.conclusion == "success") | .id' | head -1)
54+
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
55+
fi
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
59+
- uses: actions/checkout@v5
60+
61+
- name: Install just
62+
uses: taiki-e/install-action@just
63+
64+
- name: Install uv and set the python version
65+
uses: astral-sh/setup-uv@v6
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
69+
- name: Download wheel and install
70+
run: |
71+
gh run download ${{ steps.get-run-id.outputs.run_id }} --name wheels --dir wheels/
72+
# gh run download ${{ steps.get-run-id.outputs.run_id }} --name ${{ steps.artifact.outputs.name }} --dir wheels/
73+
# Only install wheel for current platform
74+
# pip install --find-links wheels/ --only-binary=:all: kaldi-active-grammar
75+
env:
76+
GH_TOKEN: ${{ github.token }}
77+
78+
- name: Setup tests
79+
run: |
80+
just setup-tests
81+
82+
- name: Run tests
83+
run: |
84+
# just test-package -v
85+
# uv venv
86+
# uv pip install -vv --find-links wheels/ --only-binary=:all: kaldi-active-grammar
87+
# uv pip install -r requirements-test.txt
88+
# uv run -v --no-project --directory tests/ -m pytest -v
89+
ls -al wheels/
90+
ls -al tests/../
91+
ls -al tests/../wheels/
92+
uv run -vv --no-project --with-requirements ../requirements-test.txt --with kaldi-active-grammar --find-links wheels/ --directory tests/ -m pytest -v

Justfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ test-model model_dir:
4343
cd {{invocation_directory()}} && rm -rf kaldi_model kaldi_model.tmp && cp -rp {{model_dir}} kaldi_model
4444

4545
trigger-build ref='master':
46-
gh api repos/:owner/:repo/actions/workflows/build.yml/dispatches -F ref={{ref}}
46+
gh workflow run build.yml --ref {{ref}}
4747

4848
setup-tests:
4949
uv run --no-project --with-requirements requirements-test.txt -m piper.download_voices --debug --download-dir tests/ '{{piper_voice}}'
5050
cd tests && [ ! -e kaldi_model ] && curl -L -C - -o kaldi_model.zip '{{kaldi_model_url}}' && unzip -o kaldi_model.zip || true
5151

5252
test *args='':
53+
uv run --no-project --with-requirements requirements-test.txt --with-requirements requirements-editable.txt -m pytest {{args}}
54+
55+
test-package *args='':
5356
uv run --no-project --with-requirements requirements-test.txt -m pytest {{args}}

requirements-editable.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-e .

requirements-test.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-e .
21
piper-tts~=1.0
32
pytest>=8.0
43
pytest-cov

0 commit comments

Comments
 (0)