Skip to content

Update transformers requirement #523

Update transformers requirement

Update transformers requirement #523

Workflow file for this run

name: Continuous integration
on:
push:
release:
types: [ published ]
workflow_dispatch:
inputs:
deploy_trigger:
description: Force a deployment to PyPI
default: "false"
required: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
pip install .
- name: Lint with ruff
run: |
pip install --upgrade ruff
# stop the build if there are Python syntax errors or undefined names
ruff check . --select=E9,F63,F7,F82 --output-format=full
# exit-zero treats all errors as warnings.
ruff check . --exit-zero --statistics
test:
needs: lint
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
- name: Get transformers and cache
id: transfo-install
run: |
python -m pip install --upgrade transformers
python -c "from transformers.file_utils import TRANSFORMERS_CACHE; print(f'dir={TRANSFORMERS_CACHE}')" >> $GITHUB_OUTPUT
echo "version=$(pip show transformers | grep Version)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.transfo-install.outputs.dir }}
key: ${{ runner.os }}-transformers-${{ steps.transfo-install.outputs.version }}
restore-keys: |
${{ runner.os }}-transformers-
- name: Run tox with tox-gh-actions
uses: ymyzk/run-tox-gh-actions@main
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
needs: test
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel build
- name: Build wheels
run: python -m build --wheel
- uses: actions/upload-artifact@v4
with:
name: dist-wheel-${{ matrix.os }}
path: ./dist/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel build
- name: Build wheels
run: python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz
upload_pypi:
environment: release
permissions:
id-token: write
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: >
(github.event_name == 'release' && github.event.action == 'published')
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_trigger == 'true')
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1