Skip to content

Enhance Security Practices for HanLP Based on OpenSSF Scorecard #266

Enhance Security Practices for HanLP Based on OpenSSF Scorecard

Enhance Security Practices for HanLP Based on OpenSSF Scorecard #266

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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
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@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- 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