Skip to content

Upgrade GitHub Actions to the latest versions #268

Upgrade GitHub Actions to the latest versions

Upgrade GitHub Actions to the latest versions #268

Workflow file for this run

name: Unit Tests
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
permissions: read-all
jobs:
build:
runs-on: ${{ matrix.os }}
env:
HANLP_HOME: ${{ github.workspace }}/data
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ 3.6, 3.7, 3.8, 3.9, '3.10' ]
exclude:
# GHA doesn't list 3.6 for ubuntu-22.04
- os: ubuntu-latest
python-version: "3.6"
# MacOS 14.4.1 for arm64 doesn't support Python < 3.8
- os: macos-latest
python-version: "3.6"
- os: macos-latest
python-version: "3.7"
include:
# GHA doesn't list 3.6 for ubuntu-22
- os: ubuntu-20.04
python-version: "3.6"
# MacOS 13 required for Python < 3.8
- os: macos-13
python-version: "3.6"
- os: macos-13
python-version: "3.7"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
python -m pip install -e plugins/hanlp_trie
python -m pip install -e plugins/hanlp_common
python -m pip install -e .
python -m pip install pytest
- name: Cache data
uses: actions/cache@v4
with:
path: ${{ env.HANLP_HOME }}
key: hanlp-data
- name: Test with pytest
shell: bash
run: |
pytest tests
pytest plugins/hanlp_trie/tests
deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install setuptools wheel twine
- name: Deploy to PyPI
run: |
python setup.py sdist bdist_wheel
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TWINE_REPOSITORY: pypi