Increment dev version after v1.1.0 release #916
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit tests | |
on: | |
push: | |
branches: | |
- main | |
- v*-release | |
- v*-pre | |
pull_request: | |
branches: | |
- main | |
- v*-pre | |
workflow_dispatch: | |
jobs: | |
test_sampling: | |
name: Run unit tests | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
os: [ubuntu-latest, windows-latest] | |
requirements: ['.[tests]', '.[compat_tests]'] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Python environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Taken from https://github.com/actions/cache?tab=readme-ov-file#creating-a-cache-key | |
# Use date to invalidate cache every week | |
- name: Get date | |
id: get-date | |
run: | | |
echo "date=$(/bin/date -u "+%G%V")" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Try to load cached dependencies | |
uses: actions/cache@v3 | |
id: restore-cache | |
with: | |
path: ${{ env.pythonLocation }} | |
key: python-dependencies-${{ matrix.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.python-version }}-${{ matrix.requirements }}-${{ hashFiles('setup.py') }}-${{ env.pythonLocation }} | |
- name: Install external dependencies on cache miss | |
run: | | |
python -m pip install --no-cache-dir --upgrade pip | |
python -m pip install --no-cache-dir ${{ matrix.requirements }} | |
python -m pip install '.[codecarbon]' | |
python -m spacy download en_core_web_lg | |
python -m spacy download en_core_web_sm | |
if: steps.restore-cache.outputs.cache-hit != 'true' | |
- name: Install the checked-out setfit | |
run: python -m pip install . | |
- name: Restore HF models from cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
~/.cache/huggingface/hub | |
~/.cache/torch | |
key: hf-models-${{ matrix.os }}-${{ env.NEW_HF_CACHE_HASH }} | |
restore-keys: | | |
hf-models-${{ matrix.os }}- | |
- name: Run unit tests | |
shell: bash | |
run: | | |
echo "OLD_HF_CACHE_HASH=$(find ~/.cache/huggingface/hub ~/.cache/torch -type f -exec sha256sum {} + | LC_ALL=C sort | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_ENV | |
pytest -v tests/ | |
echo "NEW_HF_CACHE_HASH=$(find ~/.cache/huggingface/hub ~/.cache/torch -type f -exec sha256sum {} + | LC_ALL=C sort | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_ENV | |
- name: Save new HF models to cache | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
~/.cache/huggingface/hub | |
~/.cache/torch | |
key: hf-models-${{ matrix.os }}-${{ env.NEW_HF_CACHE_HASH }} | |
# Only save cache if the hash has changed | |
if: env.NEW_HF_CACHE_HASH != env.OLD_HF_CACHE_HASH |