.github/workflows/pythonpackage.yml
name: ci
on: [push, pull_request]
env:
CI: true
jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
timeout-minutes: 60
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7]
steps:
- uses: actions/checkout@v2
- name: Cache conda
uses: actions/cache@v1
env:
# Increase this value to reset cache
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}
- name: Install miniconda and python version ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2.0.1
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: strict
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install dependencies
run: |
conda install imagemagick poppler postgresql
# Start postgresql
initdb -D mylocal_db
pg_ctl -D mylocal_db start; sleep 5
createuser -s postgres
- name: Set up test databases and test data
run: |
cd tests && ./download_data.sh && cd ..
- name: Print Version Info
run: |
pdfinfo -v
psql --version
python --version
pip --version
- name: Install Fonduer
run: |
make dev_extra
# Use v2.3.2 for tests as v2.3.3+ has a different set of default punctuations.
pip install spacy==2.3.2
# model shortcuts are not available for models introduced recently.
# they were even deprecated by explosion/spaCy#5722
python -m spacy download ja_core_news_sm
python -m spacy link ja_core_news_sm ja
python -m spacy download zh_core_web_sm
python -m spacy link zh_core_web_sm zh
pip install -q pytest-cov
- name: Run preliminary checks
run: |
isort --version
black --version
flake8 --version
mypy --version
make check
make docs
env:
PGPASSWORD: postgres
- name: Test with pytest
run: |
python -m spacy download en
pytest --cov=./ --cov-report=xml
env:
PGPASSWORD: postgres
PGUSER: postgres
POSTGRES_PORT: 5432
# Use 127.0.0.1 instead of localhost (#351)
POSTGRES_HOST: 127.0.0.1
# https://stackoverflow.com/questions/53014306/error-15-initializing-
# libiomp5-dylib-but-found-libiomp5-dylib-already-initial
KMP_DUPLICATE_LIB_OK: true
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
build-and-publish:
name: Build and Publish Fonduer to PyPI
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Build Fonduer
run: |
pip install -U setuptools wheel pip
python setup.py sdist bdist_wheel
# - name: Publish distribution to Test PyPi
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.test_pypi_password }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}