| name: tests |
|
|
| on: |
| push: |
| branches: [main] |
| paths-ignore: |
| - 'docs/**' |
| pull_request: |
| paths-ignore: |
| - 'docs/**' |
|
|
| env: |
| HF_HOME: .cache/huggingface |
| TRANSFORMERS_IS_CI: 1 |
|
|
| permissions: {} |
|
|
| jobs: |
| check_code_quality: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| persist-credentials: false |
| - name: Set up Python |
| uses: actions/setup-python@v4 |
| with: |
| python-version: "3.11" |
| cache: "pip" |
| cache-dependency-path: "setup.py" |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install .[dev] |
| - name: Check quality |
| run: | |
| make quality |
| |
| tests: |
| needs: check_code_quality |
| strategy: |
| |
| fail-fast: false |
| matrix: |
| python-version: ["3.9", "3.10", "3.11", "3.12"] |
| os: ["ubuntu-latest", "macos-13", "windows-latest"] |
| runs-on: ${{ matrix.os }} |
| steps: |
| - uses: actions/checkout@v3 |
| with: |
| persist-credentials: false |
| - name: Model cache |
| uses: actions/cache/restore@v4 |
| with: |
| |
| |
| |
| path: | |
| ${{ env.HF_HOME }}/hub/** |
| !${{ env.HF_HOME }}/**/*.pyc |
| key: model-cache-${{ github.run_id }} |
| restore-keys: model-cache- |
| enableCrossOsArchive: true |
| - name: Dump cache content |
| |
| if: matrix.os != 'windows-latest' |
| run: | |
| SHASUM=sha256sum |
| [ -f "$(which shasum)" ] && SHASUM=shasum |
| find "${{ env.HF_HOME }}/hub" -type f -exec "$SHASUM" {} \; > cache_content_initial || true |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@v4 |
| with: |
| python-version: ${{ matrix.python-version }} |
| cache: "pip" |
| cache-dependency-path: "setup.py" |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install setuptools |
| # cpu version of pytorch |
| pip install -e .[test] |
| - name: Downgrade numpy on MacOS and Windows |
| |
| shell: bash |
| if: matrix.os == 'windows-latest' || matrix.os == 'macos-13' |
| run: | |
| pip install --force-reinstall -U "numpy<2.0.0" |
| - name: Test with pytest |
| run: | |
| make test |
| - name: Dump cache content and diff |
| |
| |
| |
| if: matrix.os != 'windows-latest' |
| run: | |
| SHASUM=sha256sum |
| [ -f "$(which shasum)" ] && SHASUM=shasum |
| find "${{ env.HF_HOME }}/hub" -type f -exec "$SHASUM" {} \; > cache_content_after || true |
| diff -udp cache_content_initial cache_content_after || true |
| - name: Delete old model cache entries |
| run: | |
| # make sure that cache cleaning doesn't break the pipeline |
| python scripts/ci_clean_cache.py -d || true |
| - name: Update model cache |
| uses: actions/cache/save@v4 |
| |
| |
| |
| if: always() && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' |
| with: |
| path: | |
| ${{ env.HF_HOME }}/hub/** |
| !${{ env.HF_HOME }}/**/*.pyc |
| key: model-cache-${{ github.run_id }} |
|
|