|
1 | 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
2 | 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
3 | 3 |
|
4 | | -name: Python package |
| 4 | +name: CI |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
5 | 8 |
|
6 | 9 | on: |
7 | 10 | push: |
8 | 11 | branches: [ "main" ] |
9 | 12 | pull_request: |
10 | 13 | branches: [ "main" ] |
11 | 14 |
|
| 15 | +env: |
| 16 | + HF_HUB_CACHE: hub_cache |
| 17 | + |
12 | 18 | jobs: |
13 | 19 | build: |
14 | | - |
| 20 | + name: Build package |
15 | 21 | runs-on: ubuntu-latest |
16 | | - strategy: |
17 | | - fail-fast: false |
18 | | - matrix: |
19 | | - python-version: ["3.10", "3.11", "3.12"] |
20 | | - |
21 | 22 | steps: |
22 | 23 | - uses: actions/checkout@v4 |
23 | 24 | - uses: pdm-project/setup-pdm@v4 |
24 | | - - name: Set up Python ${{ matrix.python-version }} |
25 | | - uses: actions/setup-python@v3 |
26 | 25 | with: |
27 | | - python-version: ${{ matrix.python-version }} |
| 26 | + cache: true |
| 27 | + python-version: "3.12" |
| 28 | + - name: Cache HF models |
| 29 | + uses: actions/cache@v4 |
| 30 | + env: |
| 31 | + cache-name: cache-hf-models |
| 32 | + with: |
| 33 | + path: ${{ env.HF_HUB_CACHE }} |
| 34 | + key: build-${{ env.cache-name }}-${{ hashFiles('tests/**/*.py') }} |
| 35 | + |
28 | 36 | - name: Install dependencies |
29 | 37 | run: pdm sync |
30 | 38 | - name: Lint code with Ruff |
|
35 | 43 | run: pdm run mypy . |
36 | 44 | - name: Test with pytest |
37 | 45 | run: pdm run pytest |
| 46 | + - name: Build package dist |
| 47 | + run: pdm build |
| 48 | + |
| 49 | + - uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: wheels |
| 52 | + path: ./dist/onnx_asr-*.whl |
| 53 | + retention-days: 3 |
| 54 | + |
| 55 | + test: |
| 56 | + name: Test package |
| 57 | + needs: build |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 61 | + python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 62 | + runs-on: ${{ matrix.os }} |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - name: Set up Python ${{ matrix.python-version }} |
| 66 | + uses: actions/setup-python@v5 |
| 67 | + with: |
| 68 | + python-version: ${{ matrix.python-version }} |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + name: wheels |
| 72 | + path: ./dist |
| 73 | + - name: Cache HF models |
| 74 | + uses: actions/cache@v4 |
| 75 | + env: |
| 76 | + cache-name: cache-hf-models |
| 77 | + with: |
| 78 | + path: ${{ env.HF_HUB_CACHE }} |
| 79 | + key: build-${{ env.cache-name }}-${{ hashFiles('tests/**/*.py') }} |
| 80 | + |
| 81 | + - name: Install package |
| 82 | + shell: bash |
| 83 | + run: pip install pytest $(find ./dist -iname onnx_asr-*.whl)[cpu,hub] |
| 84 | + - name: Test with pytest |
| 85 | + run: pytest ./tests/onnx_asr |
0 commit comments