|
| 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 |
0 commit comments