1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
name: ci-workflow
# run workflow for these events
on: [push, pull_request, workflow_dispatch]
env:
CORENLP: /home/runner/third/stanford-corenlp
CORENLP_MODELS: /home/runner/third/stanford-corenlp
STANFORD_PARSER: /home/runner/third/stanford-parser
STANFORD_MODELS: /home/runner/third/stanford-postagger
STANFORD_POSTAGGER: /home/runner/third/stanford-postagger
SENNA: /home/runner/third/senna
PROVER9: /home/runner/third/prover9/bin
MEGAM: /home/runner/third/megam
# TADM requires `libtaopetsc.so` from PETSc v2.3.3, and likely has more
# tricky to install requirements, so we don't run tests for it.
# TADM: /home/runner/third/tadm/bin
MALT_PARSER: /home/runner/third/maltparser
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12.3' # 3.12.4 has an issue with pyupgrade, try to upgrade later
- run: |
pip install pre-commit
pre-commit run --all-files
cache_nltk_data:
name: Cache nltk_data
needs: pre-commit
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache nltk data
uses: actions/cache@v4
id: restore-cache
with:
path: ~/nltk_data
key: nltk_data_${{ secrets.CACHE_VERSION }}
- name: Download nltk data packages on cache miss
run: |
pip install regex # dependencies needed to download nltk data
python -c "import nltk; from pathlib import Path; path = Path('~/nltk_data').expanduser(); path.mkdir(exist_ok=True); nltk.download('all', download_dir=path)"
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true'
cache_third_party:
name: Cache third party tools
needs: pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache third party tools
uses: actions/cache@v4
id: restore-cache
with:
path: ~/third
key: third_${{ hashFiles('tools/github_actions/third-party.sh') }}_${{ secrets.CACHE_VERSION }}
- name: Download third party data
run: |
chmod +x ./tools/github_actions/third-party.sh
./tools/github_actions/third-party.sh
if: steps.restore-cache.outputs.cache-hit != 'true'
test:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: [cache_nltk_data, cache_third_party]
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Restore cached dependencies
uses: actions/cache@v4
id: restore-cache
with:
path: ${{ env.pythonLocation }}
key: python-dependencies-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements-ci.txt') }}-${{ env.pythonLocation }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade --requirement requirements-ci.txt
#if: steps.restore-cache.outputs.cache-hit != 'true' # disabled due to a persistent issue with restoring cache on macos runner
- name: Use cached nltk data
uses: actions/cache@v4
with:
path: ~/nltk_data
key: nltk_data_${{ secrets.CACHE_VERSION }}
- name: Use cached third party tools
uses: actions/cache@v4
with:
path: ~/third
key: third_${{ hashFiles('tools/github_actions/third-party.sh') }}_${{ secrets.CACHE_VERSION }}
if: runner.os == 'Linux'
- name: Set up JDK 16
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '16'
if: runner.os == 'Linux'
- name: Run pytest
shell: bash
run: |
pytest --numprocesses auto -rsx --doctest-modules nltk
|